Created
August 1, 2020 11:58
-
-
Save clemos/6ffdb72b2aef3da1758fe158b0f85711 to your computer and use it in GitHub Desktop.
scripts for Odroid Go Advance
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
#!/bin/python3 | |
""" | |
sets F6 + vertical pad to set volume, F6 + horizontal pad to set brightness | |
""" | |
import evdev | |
import subprocess | |
BRIGHTNESS_PATH = "/sys/class/backlight/backlight/brightness" | |
def set_volume(v): | |
subprocess.call(["amixer","sset","Playback",v]) | |
def set_brightness(v): | |
current = int(open(BRIGHTNESS_PATH,'r').read()) | |
open(BRIGHTNESS_PATH,'w').write(str(current+v)) | |
device = evdev.InputDevice('/dev/input/event2') | |
for event in device.read_loop(): | |
if event.type == evdev.ecodes.EV_KEY: | |
print(evdev.categorize(event)) | |
if event.code == evdev.ecodes.BTN_TRIGGER_HAPPY6 and event.value == 1: | |
device.grab() | |
if event.code == evdev.ecodes.BTN_TRIGGER_HAPPY6 and event.value == 0: | |
device.ungrab() | |
if event.code == evdev.ecodes.BTN_DPAD_UP and event.value == 1: | |
if evdev.ecodes.BTN_TRIGGER_HAPPY6 in device.active_keys(): | |
print('volume up') | |
set_volume('5%+') | |
if event.code == evdev.ecodes.BTN_DPAD_DOWN and event.value == 1: | |
if evdev.ecodes.BTN_TRIGGER_HAPPY6 in device.active_keys(): | |
print('volume down') | |
set_volume('5%-') | |
if event.code == evdev.ecodes.BTN_DPAD_LEFT and event.value == 1: | |
if evdev.ecodes.BTN_TRIGGER_HAPPY6 in device.active_keys(): | |
set_brightness(-10) | |
if event.code == evdev.ecodes.BTN_DPAD_RIGHT and event.value == 1: | |
if evdev.ecodes.BTN_TRIGGER_HAPPY6 in device.active_keys(): | |
set_brightness(+10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment