swaync: remove unused systemd integrations

it's all s6 now
This commit is contained in:
Colin 2024-05-27 00:06:03 +00:00
parent 1b4300dbeb
commit 133c1b3699
3 changed files with 21 additions and 61 deletions

View File

@ -8,11 +8,11 @@
{ pkgs }: { pkgs }:
let let
serviceButton = svcType: name: label: { serviceButton = name: label: {
inherit label; inherit label;
type = "toggle"; type = "toggle";
command = "swaync-service-dispatcher toggle ${svcType} ${name}"; command = "swaync-service-dispatcher toggle ${name}";
update-command = "swaync-service-dispatcher print ${svcType} ${name}"; update-command = "swaync-service-dispatcher print ${name}";
active = true; active = true;
}; };
in in
@ -46,14 +46,14 @@ in
# 🇲 𝐌 ₘ m̄ m⃞ m̋⃞ M⃞ 󰫺 󰬔 # 🇲 𝐌 ₘ m̄ m⃞ m̋⃞ M⃞ 󰫺 󰬔
# - discord # - discord
#  󰙯 󰊴 󰺷 🎮 #  󰙯 󰊴 󰺷 🎮
gps = serviceButton "s6" "eg25-control-gps" ""; gps = serviceButton "eg25-control-gps" "";
cell-modem = serviceButton "s6" "eg25-control-powered" "󰺐"; cell-modem = serviceButton "eg25-control-powered" "󰺐";
gnome-calls = serviceButton "s6" "gnome-calls" ""; gnome-calls = serviceButton "gnome-calls" "";
geary = serviceButton "s6" "geary" ""; geary = serviceButton "geary" "";
abaddon = serviceButton "s6" "abaddon" " "; abaddon = serviceButton "abaddon" " ";
dissent = serviceButton "s6" "dissent" " "; dissent = serviceButton "dissent" " ";
signal-desktop = serviceButton "s6" "signal-desktop" "󰭻"; signal-desktop = serviceButton "signal-desktop" "󰭻";
dino = serviceButton "s6" "dino" "󰟿"; dino = serviceButton "dino" "󰟿";
fractal = serviceButton "s6" "fractal" "[m]"; fractal = serviceButton "fractal" "[m]";
} }

View File

@ -10,7 +10,7 @@
# configuration: # configuration:
# - defaults: /run/current-system/etc/profiles/per-user/colin/etc/xdg/swaync/ # - defaults: /run/current-system/etc/profiles/per-user/colin/etc/xdg/swaync/
# - `man 5 swaync` # - `man 5 swaync`
# - view document tree: `GTK_DEBUG=interactive swaync` (`systemctl stop --user swaync` first) # - view document tree: `GTK_DEBUG=interactive swaync` (`s6 stop swaync` first)
# - examples: # - examples:
# - thread: <https://github.com/ErikReider/SwayNotificationCenter/discussions/183> # - thread: <https://github.com/ErikReider/SwayNotificationCenter/discussions/183>
# - buttons-grid and menubar: <https://gist.github.com/JannisPetschenka/fb00eec3efea9c7fff8c38a01ce5d507> # - buttons-grid and menubar: <https://gist.github.com/JannisPetschenka/fb00eec3efea9c7fff8c38a01ce5d507>
@ -28,7 +28,6 @@ in
pkgs = [ pkgs = [
"s6" "s6"
"s6-rc" "s6-rc"
"systemd"
]; ];
}; };
}; };
@ -62,7 +61,7 @@ in
default = {}; default = {};
}; };
# prevent dbus from automatically activating swaync so i can manage it as a systemd service instead # prevent dbus from automatically activating swaync so i can manage it as a service instead
packageUnwrapped = pkgs.rmDbusServices (pkgs.swaynotificationcenter.overrideAttrs (upstream: { packageUnwrapped = pkgs.rmDbusServices (pkgs.swaynotificationcenter.overrideAttrs (upstream: {
version = "0.10.1-unstable-2024-04-16"; version = "0.10.1-unstable-2024-04-16";
# toggling the panel on 0.10.1 sometimes causes toggle-buttons to toggle. # toggling the panel on 0.10.1 sometimes causes toggle-buttons to toggle.
@ -102,23 +101,6 @@ in
"/sys/class/backlight" "/sys/class/backlight"
"/sys/devices" "/sys/devices"
]; ];
sandbox.extraRuntimePaths = [
# systemd/private allows one to `systemctl --user {status,start,stop,...}`
# notably, it does *not* allow for `systemd-run` (that's dbus: org.freedesktop.systemd1.Manager.StartTransientUnit).
# that doesn't necessarily mean this is entirely safe against privilege escalation though.
# TODO: audit the safety of this systemd sandboxing.
# few alternatives:
# - superd
# - simply `xdg-open app://dino`, etc. `pkill` to stop, `pgrep` to query.
# - more robust: `xdg-open sane-service://start?service=dino`
# - still need `pgrep` to query if it's running, or have the service mark a pid file
# - dbus activation for each app
"systemd/private"
];
sandbox.extraConfig = [
# systemctl calls seem to require same pid namespace
"--sanebox-keep-namespace" "pid"
];
# glib/gio applications support many notification backends ("portal", "gtk", "freedesktop", ...). # glib/gio applications support many notification backends ("portal", "gtk", "freedesktop", ...).
# swaync implements only the `org.freedesktop.Notifications` dbus interface ("freedesktop"/fdo). # swaync implements only the `org.freedesktop.Notifications` dbus interface ("freedesktop"/fdo).

View File

@ -1,13 +1,12 @@
#!/usr/bin/env nix-shell #!/usr/bin/env nix-shell
#!nix-shell -i bash -p s6 -p s6-rc -p systemd #!nix-shell -i bash -p s6 -p s6-rc
# for default $PATH to take precedence over nix-shell PATH if invoked interactively, # for default $PATH to take precedence over nix-shell PATH if invoked interactively,
# otherwise we invoke a s6-rc which does not know where to find files. # otherwise we invoke a s6-rc which does not know where to find files.
export PATH="/etc/profiles/per-user/$(whoami)/bin:/run/current-system/sw/bin:$PATH" export PATH="/etc/profiles/per-user/$(whoami)/bin:/run/current-system/sw/bin:$PATH"
action="$1" action="$1"
type="$2" service="$2"
service="$3"
log() { log() {
if [ -n "$SWAYNC_DEBUG" ]; then if [ -n "$SWAYNC_DEBUG" ]; then
@ -16,38 +15,17 @@ log() {
} }
checkActive() { checkActive() {
case "$type" in # simulate a dry-run start. if no actions would be performed, then the service is up.
systemd) # alternative is s6-svstat, but that doesn't support oneshots
systemctl is-active "$service.service" > /dev/null && echo true || echo false test -z "$(s6-rc -n 0 -b start "$service")" && echo true || echo false
;;
s6)
# simulate a dry-run start. if no actions would be performed, then the service is up.
# alternative is s6-svstat, but that doesn't support oneshots
test -z "$(s6-rc -n 0 -b start "$service")" && echo true || echo false
;;
esac
} }
startService() { startService() {
log "startService: $service" log "startService: $service"
case "$type" in s6-rc -b start "$service"
systemd)
/run/wrappers/bin/sudo systemctl start "$service"
;;
s6)
s6-rc -b start "$service"
;;
esac
} }
stopService() { stopService() {
log "stopService: $service" log "stopService: $service"
case "$type" in s6-rc -b stop "$service"
systemd)
/run/wrappers/bin/sudo systemctl stop "$service"
;;
s6)
s6-rc -b stop "$service"
;;
esac
} }
case "$action" in case "$action" in