home: Move waybar exec commands into scripts

restic-rest-server
Simon Bruder 2020-11-08 16:03:13 +01:00
parent e6f12b0b76
commit b5616501b2
No known key found for this signature in database
GPG Key ID: 6F03E0000CC5B62F
1 changed files with 20 additions and 3 deletions

View File

@ -273,8 +273,20 @@ in
};
"custom/redshift" = {
interval = 10;
exec = "systemctl --user show redshift | grep -q ActiveState=active && echo '{\"tooltip\": \"Redshift active\", \"class\": \"active\"}' || echo '{\"tooltip\": \"Redshift inactive\", \"class\": \"inactive\"}'";
on-click = "systemctl --user show redshift | grep -q ActiveState=active && systemctl --user stop redshift || systemctl --user start redshift";
exec = pkgs.writeShellScript "waybar-redshift-state" ''
if systemctl --user show redshift | grep -q ActiveState=active; then
echo '{"tooltip": "Redshift active", "class": "active"}'
else
echo '{"tooltip": "Redshift inactive", "class": "inactive"}'
fi
'';
on-click = pkgs.writeShellScript "waybar-redshift-toggle" ''
if systemctl --user show redshift | grep -q ActiveState=active; then
systemctl --user stop redshift
else
systemctl --user start redshift
fi
'';
return-type = "json";
format = "";
tooltip = false;
@ -347,7 +359,12 @@ in
};
"custom/vpn" = {
interval = 10;
exec = "ip -j link | jq --unbuffered --compact-output '[[.[].ifname | select(. | startswith(\"mullvad\"))][] | split(\"-\")[1] + \" ${thinsp}\"] as $conns | { text: ($conns[0] // \"\"), class: (if $conns | length > 0 then \"connected\" else \"disconnected\" end) }'";
exec = pkgs.writeShellScript "vpn-state" ''
ip -j link \
| jq --unbuffered --compact-output '
[[.[].ifname | select(. | startswith("mullvad"))][] | split("-")[1] + " ${thinsp}"] as $conns
| { text: ($conns[0] // ""), class: (if $conns | length > 0 then "connected" else "disconnected" end) }'
'';
return-type = "json";
format = "{}";
tooltip = false;