forked from colonelpanic/dotfiles
[Linux] Support restarting system services with rofi_restart_service
This commit is contained in:
parent
52834ce809
commit
b96713de1b
@ -1,4 +1,30 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
systemctl --user list-unit-files | tail -n +2 | head -n -2 |
|
||||
rofi -dmenu -i | get_cols 1 | xargs systemctl --user restart
|
||||
export SYSTEMD_COLORS=0
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user