nix-files/hosts/common/programs/swaynotificationcenter/buttons.nix
2024-03-24 08:54:27 +00:00

62 lines
2.0 KiB
Nix

{ pkgs }:
let
systemctl-toggle' = pkgs.writeShellApplication {
name = "systemctl-toggle";
runtimeInputs = [
pkgs.systemd
];
text = ''
if systemctl is-active "$@"; then
systemctl stop "$@"
else
systemctl start "$@"
fi
'';
};
systemctl-toggle = "${systemctl-toggle'}/bin/systemctl-toggle";
print-is-active' = pkgs.writeShellApplication {
name = "print-is-active";
runtimeInputs = [
pkgs.systemd
];
text = ''
if systemctl is-active "$@"; then
echo true
else
echo false
fi
'';
};
print-is-active = "${print-is-active'}/bin/print-is-active";
systemServiceButton = name: label: {
# XXX: this is surely broken, due to sandboxing/perms
inherit label;
type = "toggle";
command = "/run/wrappers/bin/sudo ${systemctl-toggle} ${name}";
update-command = "${print-is-active} ${name}.service";
active = true;
};
userServiceButton = name: label: {
inherit label;
type = "toggle";
command = "${systemctl-toggle} --user ${name}";
update-command = "${print-is-active} --user ${name}";
active = true;
};
in
{
gps = systemServiceButton "eg25-control-gps" ""; # GPS services; other icons: gps, ⌖, 🛰, 🌎, 
cell-modem = systemServiceButton "eg25-control-powered" "󰺐"; # icons: 5g, 📡, 📱, ᯤ, ⚡, , 🌐, 📶, 🗼, 󰀂, , 󰺐, 󰩯
vpn = systemServiceButton "wg-quick-vpn-servo" "vpn::hn";
gnome-calls = userServiceButton "gnome-calls" "SIP";
geary = userServiceButton "geary" "󰇮"; # email (Geary); other icons: ✉, [E], 📧, 󰇮
abaddon = userServiceButton "abaddon" "󰊴"; # Discord chat client; icons: 󰊴, 🎮
dissent = userServiceButton "dissent" "󰊴"; # Discord chat client; icons: 󰊴, 🎮
signal-desktop = userServiceButton "signal-desktop" "💬"; # Signal messenger; other icons: 󰍦
dino = userServiceButton "dino" "XMPP"; # XMPP calls (jingle)
fractal = userServiceButton "fractal" "[m]"; # Matrix messages
}