Skip to content

Commit

Permalink
Changed capslock input for current UN5401QAB & fixed triggering only …
Browse files Browse the repository at this point in the history
…by event key & added camera led by asus_wmi_devs
  • Loading branch information
ldrahnik committed Jan 7, 2024
1 parent 8ef83dc commit 81f777c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
9 changes: 6 additions & 3 deletions asus_fliplock.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ def search_devices():
fd_t_wmi_hotkeys = open('/dev/input/event' + str(wmi_hotkeys), 'rb')
d_t_wmi_hotkeys = Device(fd_t_wmi_hotkeys)

# When we listen only key we predict start state is laptop mode
intel_hid_switches_tablet_mode = 1

def execute_cmd(cmd):
try:
Expand All @@ -102,14 +104,14 @@ def execute_cmds_in_array(cmds):
execute_cmd(cmd)


def flip(intel_hid_switches_tablet_mode):
def flip(intel_hid_switches_tablet_mode):
if intel_hid_switches_tablet_mode:
execute_cmds_in_array(fliplock_layouts.tablet_mode_actions)
else:
execute_cmds_in_array(fliplock_layouts.laptop_mode_actions)


# If mode has been changed, do something
# If mode has been changed, do something
if switches is None and wmi_hotkeys is not None:

for e in d_t_wmi_hotkeys.events():
Expand All @@ -119,9 +121,10 @@ def flip(intel_hid_switches_tablet_mode):
if switches is not None:
break

# Pressed and released event is called during one! flipping simultanously
if e.matches(fliplock_layouts.flip_key) and e.value == 1:
intel_hid_switches_tablet_mode = 1
flip(intel_hid_switches_tablet_mode)
intel_hid_switches_tablet_mode = not intel_hid_switches_tablet_mode

search_devices()

Expand Down
12 changes: 9 additions & 3 deletions conf/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
# setting up saved keyboard backlight brightness (restore from backup)
"test -f /tmp/kbd_backlight_brightness && cat /tmp/kbd_backlight_brightness | sudo tee /sys/class/leds/asus::kbd_backlight/brightness",
# setting up saved capslock backlight brightness (restore from backup)
"test -f /tmp/input3_capslock_brightness && cat /tmp/input3_capslock_brightness | sudo tee /sys/class/leds/input3::capslock/brightness",
"test -f /tmp/input2_capslock_brightness && cat /tmp/input2_capslock_brightness | sudo tee /sys/class/leds/input2::capslock/brightness",
# setting up saved micmute backlight brightness (restore from backup)
"test -f /tmp/micmute_brightness && cat /tmp/micmute_brightness | sudo tee /sys/class/leds/platform::micmute/brightness",
# setting up saved camera backlight brightness (restore from backup)
"test -f /tmp/camera_brightness && echo '0x60079' | sudo tee '/sys/kernel/debug/asus-nb-wmi/dev_id' >/dev/null && cat /tmp/camera_brightness | sudo tee '/sys/kernel/debug/asus-nb-wmi/ctrl_param' && sudo cat '/sys/kernel/debug/asus-nb-wmi/devs' >/dev/null"
]

tablet_mode_actions = [
Expand All @@ -15,13 +17,17 @@
# disable keyboard backlight brightness
"echo 0 | sudo tee /sys/class/leds/asus::kbd_backlight/brightness",
# save capslock led brightness (do a backup)
"cat /sys/class/leds/input3::capslock/brightness | sudo tee /tmp/input3_capslock_brightness",
"cat /sys/class/leds/input2::capslock/brightness | sudo tee /tmp/input2_capslock_brightness",
# disable capslock led brightness
"echo 0 | sudo tee /sys/class/leds/input3::capslock/brightness",
"echo 0 | sudo tee /sys/class/leds/input2::capslock/brightness",
# save micmute led brightness (do a backup)
"cat /sys/class/leds/platform::micmute/brightness | sudo tee /tmp/micmute_brightness",
# disable micmute led brightness
"echo 0 | sudo tee /sys/class/leds/platform::micmute/brightness",
# save camera led brightness (do a backup)
"echo '0x60079' | sudo tee '/sys/kernel/debug/asus-nb-wmi/dev_id' >/dev/null && VALUE=$(sudo cat '/sys/kernel/debug/asus-nb-wmi/dsts' | rev | cut -d' ' -f1 | rev) && echo -n $VALUE | tail -c 1 | sudo tee /tmp/camera_brightness",
# disable camera led brightness
"echo '0x60079' | sudo tee '/sys/kernel/debug/asus-nb-wmi/dev_id' >/dev/null && echo '0' | sudo tee '/sys/kernel/debug/asus-nb-wmi/ctrl_param' && sudo cat '/sys/kernel/debug/asus-nb-wmi/devs' >/dev/null"
]

flip_key = EV_KEY.KEY_PROG2

0 comments on commit 81f777c

Please sign in to comment.