I see.
- One way is to build from source code.
- Another way is to unpack the appimage and search for the relevant script there. I don’t know whether it is packed with releases, but I would guess that it is.
But given that you are on linux, using the /dev/hidraw* device will probably be the most convenient one:
Create a script with the following content. Say /usr/local/bin/uhkcmd
:
#!/bin/bash
hidraw=`grep 'UHK 60' /sys/class/hidraw/hidraw*/device/uevent | LC_ALL=C sort -rh | head -n 1 | grep -o 'hidraw[0-9][0-9]*'`
echo -e "\x14$*" > "/dev/$hidraw"
Furthermore you need to make it executable: e.g., with chmod a+x /usr/local/bin/uhkcmd
in the shell.
If you placed it at some other place, you also need to make that place be part of your PATH environment variable (which can be done by placing something like export PATH="/your/path/:$PATH"
into your ~/.profile
) or execute it using an absolute path.
Test the script with uhkcmd "setLedTxt 5000 Hey"
in your shell. (Your segment display should display “hey” for 5 seconds.)
Now you can execute the macro commands as this from your shell:
uhkcmd "ifNotKeymap QWR switchKeymap QWR"
sleep 0.1
uhkcmd "ifNotLayer base unToggleLayer"
As to hooking things in linux, that largely depends on your window manager. Personally, I am suspending my computer using a custom script that takes care of all related automation (controlling some smart light bulbs, adjusting screensaver, locking the screen, setting up an alarm using rtcwake, …).
As to global ways, here are some chatgpt recommendations: https://chatgpt.com/c/21b34e53-0eba-474a-b22c-75124b07a3e3, although I would advise against using them, as the systemd approach is very temperamental (in the sense that I remember trying to use it for some things in the past and wasn’t very successful).
Another, much more hackish way is to write a script, make your window manager to execute it on startup (or more precisely login), that will mark current time every few seconds, and if there is larger gap between the last marked time than those few seconds, then you know that your computer was sleeping.
I think I’ve found that Linux Mint will let me run a command on startup and set it within the Startup Applications menu.
My guess is that the result will be the same as with $onInit
: that it will execute only on fresh boot, but not on waking up from sleep.