mirror of
https://github.com/Ahwxorg/nixos-config.git
synced 2025-12-04 15:00:13 +01:00
feat: adds script for yubikey-touch-detector to show in waybar
This commit is contained in:
parent
ceecc26968
commit
61a34f4061
1 changed files with 43 additions and 0 deletions
|
|
@ -2,6 +2,49 @@
|
||||||
|
|
||||||
{
|
{
|
||||||
home.file = {
|
home.file = {
|
||||||
|
"/home/${username}/.local/bin/waybar-yubikey" = {
|
||||||
|
executable = true;
|
||||||
|
text = ''
|
||||||
|
socket="''${XDG_RUNTIME_DIR:-/run/user/$UID}/yubikey-touch-detector.socket"
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
touch_reasons=()
|
||||||
|
|
||||||
|
if [ ! -e "$socket" ]; then
|
||||||
|
printf '{"text": "Waiting for YubiKey socket"}\n'
|
||||||
|
while [ ! -e "$socket" ]; do sleep 1; done
|
||||||
|
fi
|
||||||
|
printf '{"text": ""}\n'
|
||||||
|
|
||||||
|
nc -U "$socket" | while read -n5 cmd; do
|
||||||
|
reason="''${cmd:0:3}"
|
||||||
|
|
||||||
|
if [ "''${cmd:4:1}" = "1" ]; then
|
||||||
|
touch_reasons+=("$reason")
|
||||||
|
else
|
||||||
|
for i in "''${!touch_reasons[@]}"; do
|
||||||
|
if [ "''${touch_reasons[i]}" = "$reason" ]; then
|
||||||
|
unset 'touch_reasons[i]'
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "''${#touch_reasons[@]}" -eq 0 ]; then
|
||||||
|
printf '{"text": ""}\n'
|
||||||
|
else
|
||||||
|
if [ "$1" == "0" ]; then
|
||||||
|
printf '{"text": ""}\n'
|
||||||
|
else
|
||||||
|
printf '{"text":"%s"}\n' "''${touch_reasons[@]}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
'';
|
||||||
|
};
|
||||||
"/home/${username}/.local/bin/waybar-screenrecord" = {
|
"/home/${username}/.local/bin/waybar-screenrecord" = {
|
||||||
executable = true;
|
executable = true;
|
||||||
text = ''
|
text = ''
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue