-
-
Save caio2k/e3718013017028719d321514e9d487e5 to your computer and use it in GitHub Desktop.
Support Surface Pro onboard buttons in Debian 9
This file contains hidden or 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
; Example configuration file for inputexec | |
[DEFAULT] | |
; ---traceback : Include full stack trace on exception | |
#traceback = | |
## Source | |
[source] | |
; --source-file : The source to read from (e.g /dev/input/event0) | |
file = /dev/input/by-id/usb-MICROSOFT_SAM_0.1.0000-if01-event-mouse | |
; --source-mode : Get shared/exclusive hold of the input device (evdev only) | |
; Options: exclusive, shared | |
mode = shared | |
## Formatting | |
[format] | |
; --format-pattern : Formatting pattern | |
pattern = {kind}.{symbol} | |
; --format-endline : End of line substring | |
endline = \n | |
## Action | |
[action] | |
; --action-mode : Action to perform on events | |
; Options: print, run_async, run_sync | |
mode = run_async | |
; --action-jobs : Number of jobs to run | |
jobs = 3 | |
; --action-commands : Read input/command mappings from the ACTION_COMMANDS file, section [commands] | |
commands = surface-pro.ini | |
## Filtering events | |
[filter] | |
; --filter-kinds : Comma-separated list of event kinds to keep | |
kinds = keypress,keyhold | |
## Logging | |
[logging] | |
; --logging-target : Logging target | |
; Options: file, null, stderr, syslog | |
target = stderr | |
; --logging-file : For 'file' target, write logs to FILE | |
file = | |
; --logging-level : Logging level | |
; Options: debug, error, info, warning | |
level = warning |
This file contains hidden or 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
sudo apt install pip | |
pip install inputexec | |
#copy surface-vol.py to /usr/local/bin | |
#copy surface-pro.ini to ~/ | |
#copy config.ini to ~/ | |
#copy surface-vol.desktop to ~/.config/autostart/ | |
inputexec --config config.ini | |
#add it to startup | |
echo '%sudo ALL=NOPASSWD: /usr/local/bin/surface-vol.py' >> /etc/sudoers |
This file contains hidden or 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
[commands] | |
keypress.KEY_LEFTMETA = sudo surface-vol.py KEY_LEFTMETA | |
keypress.KEY_VOLUMEDOWN = sudo surface-vol.py KEY_VOLUMEDOWN | |
keypress.KEY_VOLUMEUP = sudo surface-vol.py KEY_VOLUMEUP | |
keyhold.KEY_VOLUMEDOWN = sudo surface-vol.py KEY_VOLUMEDOWN | |
keyhold.KEY_VOLUMEUP = sudo surface-vol.py KEY_VOLUMEUP |
This file contains hidden or 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
[Desktop Entry] | |
Name=surface-vol | |
GenericName=A descriptive name | |
Comment=Some description about your script | |
Exec=/usr/local/bin/inputexec --config ~/inputexec.ini | |
Terminal=false | |
Type=Application | |
X-GNOME-Autostart-enabled=true |
This file contains hidden or 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
#!/usr/bin/env python | |
import sys | |
from time import sleep | |
from evdev import UInput, ecodes as e | |
ui = UInput() | |
key = e.ecodes[sys.argv[1]] | |
# accepts only KEY_* events by default | |
ui.write(e.EV_KEY, key, 1) # KEY down | |
sleep(0.05) | |
ui.write(e.EV_KEY, key, 0) # KEY up | |
ui.syn() | |
ui.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment