-
-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New package: auto lock the attached keyboard when flipped behind tablet #565
Open
ScottFreeCode
wants to merge
2
commits into
dreemurrs-embedded:master
Choose a base branch
from
ScottFreeCode:pt2-kbd-autolock
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Maintainer: ScottFreeCode <scottfreecode@gmail.com> | ||
pkgname=acpi-kbd-autolock-pinetab2 | ||
pkgver=0.1.0 | ||
pkgrel=1 | ||
pkgdesc="Automatically turn off the hardware/case keyboard when it is flipped shut (or behind the tablet), for the PineTab 2" | ||
arch=(any) | ||
url="https://github.com/dreemurrs-embedded/Pine64-Arch" | ||
license=('BSD') | ||
depends=('acpid') | ||
source=(lid toggle-keyboard.sh) | ||
|
||
package() { | ||
install -D -m644 "$srcdir"/lid \ | ||
"$pkgdir"/etc/acpi/events/lid | ||
install -D -m755 "$srcdir"/toggle-keyboard.sh \ | ||
"$pkgdir"/etc/acpi/toggle-keyboard.sh | ||
} | ||
|
||
install=acpi-kbd-autolock-pinetab2.install | ||
|
||
md5sums=('fdac6076a6c9cf9e3fad89302fc06cf9' | ||
'c8862783b76c9addf604ba095c9814b4') |
3 changes: 3 additions & 0 deletions
3
PKGBUILDS/pine64/acpi-kbd-autolock-pinetab2/acpi-kbd-autolock-pinetab2.install
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
post_install() { | ||
systemctl enable --now acpid | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
event=button/lid | ||
action=/etc/acpi/toggle-keyboard.sh %e | ||
20 changes: 20 additions & 0 deletions
20
PKGBUILDS/pine64/acpi-kbd-autolock-pinetab2/toggle-keyboard.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,20 @@ | ||||||
#!/bin/sh | ||||||
|
||||||
ACTION=bind | ||||||
MESSAGE=on | ||||||
if [[ "$3" = "close" ]] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we had a command (let's just call it
Suggested change
|
||||||
then | ||||||
ACTION=unbind | ||||||
MESSAGE=off | ||||||
fi | ||||||
|
||||||
KEYBOARD=4-1 | ||||||
#KEYBOARD=`grep -r --include=uevent Touchpad /sys/devices/ | cut -d/ -f7 | grep -v : | sort | uniq` | ||||||
|
||||||
echo "$KEYBOARD" > /sys/bus/usb/drivers/usb/"$ACTION" | ||||||
|
||||||
for user in `who | cut -f1 -d\ | sort | uniq` | ||||||
do | ||||||
sudo -u "$user" DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/"`id -u $user`"/bus \ | ||||||
notify-send -a 'PineTab2 case' "Keyboard turned $MESSAGE." | ||||||
done |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to use logind for this? iirc it has an option to handle lid switch events, and that way you don't need to add an extra dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll have to dig up my research, but from what I read the systemd login interface only lets you choose from a predefined list of behaviors – screen off, suspend, shutdown, etc. – and there's theoretically a way to redefine those behaviors (suspend.target, etc.) but I didn't really think that was appropriate (anything more than screen off, e.g. suspend, should prevent keyboard usage anyway; and more importantly people's screens might be configured to turn off via other conditions as well), plus I didn't see an event that can turn the keyboard back on. As far as I was able to find out, ACPI is intended to be the lower level interface for more control of customization like this.