swaync-service-dispatcher: fix start/stop inversion
This commit is contained in:
@@ -1,10 +1,20 @@
|
|||||||
#!/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 -p systemd
|
||||||
|
|
||||||
|
# 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.
|
||||||
|
export PATH="/etc/profiles/per-user/$(whoami)/bin:/run/current-system/sw/bin:$PATH"
|
||||||
|
|
||||||
action="$1"
|
action="$1"
|
||||||
type="$2"
|
type="$2"
|
||||||
service="$3"
|
service="$3"
|
||||||
|
|
||||||
|
log() {
|
||||||
|
if [ -n "$SWAYNC_SERVICES_DEBUG" ]; then
|
||||||
|
printf "%s\n" "$1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
checkActive() {
|
checkActive() {
|
||||||
case "$type" in
|
case "$type" in
|
||||||
systemd)
|
systemd)
|
||||||
@@ -16,6 +26,7 @@ checkActive() {
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
startService() {
|
startService() {
|
||||||
|
log "startService: $service"
|
||||||
case "$type" in
|
case "$type" in
|
||||||
systemd)
|
systemd)
|
||||||
/run/wrappers/bin/sudo systemctl start "$service"
|
/run/wrappers/bin/sudo systemctl start "$service"
|
||||||
@@ -26,6 +37,7 @@ startService() {
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
stopService() {
|
stopService() {
|
||||||
|
log "stopService: $service"
|
||||||
case "$type" in
|
case "$type" in
|
||||||
systemd)
|
systemd)
|
||||||
/run/wrappers/bin/sudo systemctl stop "$service"
|
/run/wrappers/bin/sudo systemctl stop "$service"
|
||||||
@@ -43,11 +55,11 @@ case "$action" in
|
|||||||
toggle)
|
toggle)
|
||||||
case "$(checkActive)" in
|
case "$(checkActive)" in
|
||||||
false)
|
false)
|
||||||
stopService
|
|
||||||
;;
|
|
||||||
true)
|
|
||||||
startService
|
startService
|
||||||
;;
|
;;
|
||||||
|
true)
|
||||||
|
stopService
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
Reference in New Issue
Block a user