[Linux] Support manipulating template units from rofi_systemd

This commit is contained in:
Ivan Malison 2018-06-12 22:16:21 -07:00
parent 35e8743e31
commit 4c5625bb7d
No known key found for this signature in database
GPG Key ID: 62530EFBE99DC2F8

View File

@ -4,14 +4,20 @@ export SYSTEMD_COLORS=0
term=${ROFI_SYSTEMD_TERM-termite -e} term=${ROFI_SYSTEMD_TERM-termite -e}
default_action=${ROFI_SYSTEMD_DEFAULT_ACTION-"list_actions"} default_action=${ROFI_SYSTEMD_DEFAULT_ACTION-"list_actions"}
function user_units { function unit_files {
SYSTEMD_COLORS=0 systemctl --user list-unit-files | tail -n +2 | head -n -2 | systemctl "$1" list-unit-files --no-legend
awk '{print $0 " user"}'
} }
function system_units { # This is needed to list services started from template units
systemctl list-unit-files | tail -n +2 | head -n -2 | function running_units {
awk '{print $0 " system"}' systemctl "$1" list-units --all --type=service --no-legend |
awk '{print $1 " " $3}'
}
function get_units {
{ unit_files "--$1"; running_units "--$1"; } |
awk -v unit_type="$1" '{print $0 " " unit_type}'
} }
enable="Alt+e" enable="Alt+e"
@ -104,4 +110,4 @@ function get_command_with_args {
esac esac
} }
{ user_units; system_units; } | column -tc 1 | select_service_and_act { get_units user; get_units system; } | column -tc 1 | select_service_and_act