diff --git a/dotfiles/lib/bin/rofi_restart_service.sh b/dotfiles/lib/bin/rofi_restart_service.sh index 864c0e8e..5f3314b2 100755 --- a/dotfiles/lib/bin/rofi_restart_service.sh +++ b/dotfiles/lib/bin/rofi_restart_service.sh @@ -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