dotfiles/bin/toggle
2021-12-14 14:42:27 +02:00

34 lines
785 B
Bash
Executable file

#!/bin/sh
if [ "$1" = "-s" ]; then
if [ "`systemctl is-active $2`" = "active" ]; then
systemctl stop $2
notify-send $2 "process now stopped"
else
systemctl start $2
notify-send $2 "process now active"
fi
elif [ "$1" = "-su" ]; then
if [ "`systemctl --user is-active $2`" = "active" ]; then
systemctl --user stop $2
notify-send $2 "process now stopped"
else
systemctl --user start $2
notify-send $2 "process now active"
fi
else
if [ -z "`pgrep -x $1`" ]; then
$@ &
if [ "$1" = mpd ]; then
sleep 1
#mpd-mpris &
mpd-rpc --no-idle --dont-broadcast-the-paused-state &
mpdscribble &
#those tho will kill themselves when mpd gets killed so we're good
fi
notify-send $1 "is now enabled"
else
notify-send $1 "is now disabled"
pkill $1
fi
fi