From 4c5625bb7d9cb3a867207c9acfd9ef98e7400386 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Tue, 12 Jun 2018 22:16:21 -0700 Subject: [PATCH] [Linux] Support manipulating template units from rofi_systemd --- dotfiles/lib/bin/rofi_systemd.sh | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/dotfiles/lib/bin/rofi_systemd.sh b/dotfiles/lib/bin/rofi_systemd.sh index 5e1e0776..d97977bb 100755 --- a/dotfiles/lib/bin/rofi_systemd.sh +++ b/dotfiles/lib/bin/rofi_systemd.sh @@ -4,14 +4,20 @@ export SYSTEMD_COLORS=0 term=${ROFI_SYSTEMD_TERM-termite -e} default_action=${ROFI_SYSTEMD_DEFAULT_ACTION-"list_actions"} -function user_units { - SYSTEMD_COLORS=0 systemctl --user list-unit-files | tail -n +2 | head -n -2 | - awk '{print $0 " user"}' +function unit_files { + systemctl "$1" list-unit-files --no-legend } -function system_units { - systemctl list-unit-files | tail -n +2 | head -n -2 | - awk '{print $0 " system"}' +# This is needed to list services started from template units +function running_units { + 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" @@ -104,4 +110,4 @@ function get_command_with_args { 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