dotfiles/bin/toggle

35 lines
785 B
Text
Raw Normal View History

2021-02-13 12:49:36 +00:00
#!/bin/sh
2021-12-14 12:42:27 +00:00
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"
2021-02-19 19:01:52 +00:00
fi
2021-02-13 12:49:36 +00:00
else
2021-12-14 12:42:27 +00:00
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
2021-02-13 12:49:36 +00:00
fi