swaync: cleanup

This commit is contained in:
Colin 2024-04-16 02:22:34 +00:00
parent 259c3af526
commit 539fe48947
2 changed files with 16 additions and 28 deletions

View File

@ -63,15 +63,19 @@ in
};
# prevent dbus from automatically activating swaync so i can manage it as a systemd service instead
packageUnwrapped = pkgs.rmDbusServices (pkgs.pkgsDebug.swaynotificationcenter.overrideAttrs (upstream: {
packageUnwrapped = pkgs.rmDbusServices (pkgs.swaynotificationcenter.overrideAttrs (upstream: {
version = "0.10.1-unstable-2024-04-16";
src = pkgs.fetchFromGitHub {
# toggling the panel on 0.10.1 sometimes causes toggle-buttons to toggle.
# this is fixed post-0.10.1.
# see: <https://github.com/ErikReider/SwayNotificationCenter/issues/405>
src = lib.warnIf (lib.versionOlder "0.10.1" upstream.version) "swaync: safe to unpin" pkgs.fetchFromGitHub {
owner = "ErikReider";
repo = "SwayNotificationCenter";
rev = "8cb9be59708bb051616d7e14d9fa0b87b86985af";
hash = "sha256-UAegyzqutGulp6H7KplEfwHV0MfFfOHgYNNu+AQHx3g=";
};
}));
suggestedPrograms = [
"feedbackd"
"swaync-fbcli" #< used to sound ringer

View File

@ -15,8 +15,6 @@ log() {
fi
}
# child=
# kill children if killed, to allow that killing this parent process will end the real fbcli call
cleanup() {
log "aborting fbcli notification"
@ -24,13 +22,6 @@ cleanup() {
trap - SIGINT SIGQUIT SIGTERM
# "kill 0" means kill the current process group (i.e. all descendants)
kill 0
# pkill -g 0
# if [ -n "$child" ]; then
# pkill -P "$child"
# kill "$child"
# else
# pkill -P $$
# fi
exit 0 # exit cleanly to avoid swaync alerting a script failure
}
@ -53,10 +44,12 @@ startInline() {
# feedbackd stops playback when the caller exits
# and fbcli will exit immediately if it has no stdin.
# so spoof a stdin.
# so spoof a stdin
# and do so asynchronously so that we don't block our signal handler.
log "${fbcliArgs[*]}"
bash -c "sleep $((3 + ${timeout:+ + $timeout})) | ${fbcliArgs[*]}" &
# child=$!
# bash -c "sleep $((3 + ${timeout:+ + $timeout})) | ${fbcliArgs[*]}" &
# (sleep $((3 + ${timeout:+ + $timeout})) | ${fbcliArgs[*]}) &
sleep $((3 + ${timeout:+ + $timeout})) | ${fbcliArgs[*]} &
wait
}
@ -69,18 +62,13 @@ start() {
exit
fi
# startInline &
log "$0 start-inline $event"
# setsid -f "$0" start-inline "$event"
# setsid -f -w "$0" start-stage-1 "$event" || true
setsid -f -w "$0" start-stage-1 "$event" > /dev/null 2> /dev/null < /dev/null &
# "$0" start-stage-1 "$event" &
child=$!
wait
# XXX(2024/04/15): don't pass stdin/stdout/stderr, else swaync is liable to get confused and peg CPU to 100%
setsid -f "$0" start-inline "$event" > /dev/null 2> /dev/null < /dev/null || true
}
stop() {
pkill --echo --full "swaync-fbcli(-wrapped)? start-stage-2 $event" || true
pkill --echo --full "swaync-fbcli(-wrapped)? start-inline $event" || true
}
@ -88,12 +76,8 @@ case "$action" in
start)
start
;;
start-stage-1)
# setsid -f -w "$0" start-stage-2 "$event"
"$0" start-stage-2 "$event"
;;
start-stage-2)
startInline
start-inline)
startInline # used internally by the `start` action
;;
stop)
stop