From 3e2b439fef749a77ba5bf476367ac43d66377081 Mon Sep 17 00:00:00 2001 From: ChUrl Date: Mon, 1 May 2023 19:14:59 +0200 Subject: [PATCH] Mark running containers in green in rofi menu --- config/rofi/menus/containers.txt | 4 +++- config/rofi/menus/systemd-podman.fish | 16 +++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/config/rofi/menus/containers.txt b/config/rofi/menus/containers.txt index 517fab0a..f3412a22 100644 --- a/config/rofi/menus/containers.txt +++ b/config/rofi/menus/containers.txt @@ -1,3 +1,5 @@ jellyfin +sonarr +sabnzbd homeassistant -picard \ No newline at end of file +picard diff --git a/config/rofi/menus/systemd-podman.fish b/config/rofi/menus/systemd-podman.fish index b5f5a73a..9c67f322 100755 --- a/config/rofi/menus/systemd-podman.fish +++ b/config/rofi/menus/systemd-podman.fish @@ -1,14 +1,24 @@ #!/usr/bin/env fish -# User chooses service +# User chooses service, running services are marked in green set SERVICES (cat ~/NixFlake/config/rofi/menus/containers.txt) # TODO: This file should probably be generated by nix? -set SERVICE (echo -e (string join "\n" $SERVICES) | rofi -theme ~/NixFlake/config/rofi/rofi.rasi -dmenu -p "pod" -i) +set PROMPT "" +for SERVICE in $SERVICES + set SERVICE_RUNNING "$(systemctl list-units podman-$SERVICE.service | grep podman-$SERVICE.service)" + if test -z $SERVICE_RUNNING + set PROMPT $PROMPT$SERVICE"\n" + else + set PROMPT $PROMPT"$SERVICE\n" + end +end +set SERVICE (echo -e $PROMPT | rofi -theme ~/NixFlake/config/rofi/rofi.rasi -dmenu -p "pod" -i -markup-rows) +set SERVICE (echo -e $SERVICE | sd "<.*?>" "") if not contains $SERVICE $SERVICES exit end # User chooses action -set ACTIONS "start" "stop" "status" +set ACTIONS "start" "stop" "restart" "status" set ACTION (echo -e (string join "\n" $ACTIONS) | rofi -theme ~/NixFlake/config/rofi/rofi.rasi -dmenu -p "action" -i) if not contains $ACTION $ACTIONS exit