Last active
February 17, 2022 22:32
-
-
Save marmarek/2552c395c1b5db56f031936f7dad9156 to your computer and use it in GitHub Desktop.
Control keyboard color based on active qube label
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/sh | |
# vim: et sw=4 ts=4 | |
# Requires https://github.com/MatMoul/g810-led installed in sys-usb (compile it and put into /usr/local/bin for example) | |
# | |
# Usage: run in dom0: | |
# qvm-run --localcmd=./control-keyboard-color.sh --pass-io -- sys-usb 'xargs -n1 g810-led -a' | |
# in Qubes 4.0, the command from qvm-run argument is ignored with --localcmd | |
# and we get raw qubes.VMShell, so echo the command on the first line | |
echo 'xargs -n1 g810-led -a' | |
# _NET_ACTIVE_WINDOW: window id # 0x4400003, 0x0 | |
xprop -root -notype -spy _NET_ACTIVE_WINDOW |\ | |
while read _x _x _x _x windowid _x; do | |
windowid="${windowid%,}" | |
if [ "$windowid" = "0x0" ]; then | |
continue | |
fi | |
# _QUBES_LABEL_COLOR = 7590422 | |
# _QUBES_LABEL_COLOR: not found. | |
color=$(xprop -notype -id "$windowid" _QUBES_LABEL_COLOR | cut -f 3 -d ' ') | |
if [ "$color" = "not" ]; then | |
color="16777215" | |
fi | |
printf '%06x\n' "$color" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment