swaync: port to s6

This commit is contained in:
Colin 2024-03-24 08:53:19 +00:00
parent ddef2d0bfc
commit 86400f45d6

View File

@ -1,5 +1,6 @@
{ pkgs }:
let
# TODO: move ALL of the scripts into just one helper.
systemctl-toggle' = pkgs.writeShellApplication {
name = "systemctl-toggle";
runtimeInputs = [
@ -30,6 +31,35 @@ let
};
print-systemd-active = "${print-systemd-active'}/bin/print-systemd-active";
s6-toggle' = pkgs.writeShellApplication {
name = "s6-toggle";
runtimeInputs = [
pkgs.s6
pkgs.s6-rc
];
text = ''
service="$1"
if [ "$(s6-svstat -o wantedup "$XDG_RUNTIME_DIR/s6/live/servicedirs/$service")" = "true" ]; then
s6-rc stop "$service"
else
s6-rc start "$service"
fi
'';
};
s6-toggle = "${s6-toggle'}/bin/s6-toggle";
print-s6-active' = pkgs.writeShellApplication {
name = "print-s6-active";
runtimeInputs = [
pkgs.s6
];
text = ''
# s6-svstat's native output is "true"/"false" as expected by swaync
s6-svstat -o wantedup "$XDG_RUNTIME_DIR/s6/live/servicedirs/$1"
'';
};
print-s6-active = "${print-s6-active'}/bin/print-s6-active";
systemServiceButton = name: label: {
# XXX: this is surely broken, due to sandboxing/perms
inherit label;
@ -41,8 +71,8 @@ let
userServiceButton = name: label: {
inherit label;
type = "toggle";
command = "${systemctl-toggle} --user ${name}";
update-command = "${print-systemd-active} --user ${name}";
command = "${s6-toggle} ${name}";
update-command = "${print-s6-active} ${name}";
active = true;
};
in