[Linux] Support restarting system services with rofi_restart_service

This commit is contained in:
Ivan Malison 2017-02-28 12:04:04 -08:00
parent 52834ce809
commit b96713de1b
No known key found for this signature in database
GPG Key ID: 62530EFBE99DC2F8

View File

@ -1,4 +1,30 @@
#!/usr/bin/env zsh #!/usr/bin/env zsh
systemctl --user list-unit-files | tail -n +2 | head -n -2 | export SYSTEMD_COLORS=0
rofi -dmenu -i | get_cols 1 | xargs systemctl --user restart
function user_units {
SYSTEMD_COLORS=0 systemctl --user list-unit-files | tail -n +2 | head -n -2 |
awk '{print $0 " user"}'
}
function system_units {
systemctl list-unit-files | tail -n +2 | head -n -2 |
awk '{print $0 " system"}'
}
function restart_service {
result=$(get_cols 1 3)
service_name="$(printf $result | get_cols 1 | tr -d ' ')"
is_user="$(printf $result | get_cols 2)"
echo "$service_name"
case "$is_user" in
user*)
systemctl restart --user "$service_name"
;;
system*)
sudo systemctl restart "$service_name"
;;
esac
}
{ user_units; system_units } | rofi -dmenu -i | restart_service