Created
August 4, 2019 22:57
-
-
Save rien333/fde2c62ba702731092a091aa2f7b521b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/sh | |
# disable some processes from showing | |
systemctl -t service --plain --no-legend --no-pager list-unit-files --state enabled,disabled | grep -Fv -e freedesktop -e systemd | sed 's/\..*//' > /tmp/sysunits & | |
systemctl list-unit-files -t service --no-legend --user --state enabled,disabled | sed 's/\..*//' > /tmp/usrunits & | |
action=$(dmenu <<EOF | |
start | |
stop | |
restart | |
status | |
disable | |
enable | |
EOF | |
) | |
[ -z "$action" ] && exit 0 # if no action, quit | |
wait | |
unit=$(cat /tmp/sysunits /tmp/usrunits | /usr/local/bin/dmenu) | |
[ -z $unit ] && exit 0 # if no unit, quit | |
if grep -q $unit /tmp/usrunits; then | |
if echo $action | grep "status"; then | |
notify-send "Systemd" "$unit is "$(systemctl --user is-active $unit) | |
exit 0 | |
fi | |
systemctl --user $action $unit && notify-send "Systemd" "$action '" $unit "' succesful" | |
else | |
if echo $action | grep "status"; then | |
notify-send "Systemd" "$unit is "$(systemctl is-active $unit) | |
exit 0 | |
fi | |
sudo systemctl $action $unit && notify-send "Systemd" "$action '"$unit"' succesful" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment