1

Mark running containers in green in rofi menu

This commit is contained in:
2023-05-01 19:14:59 +02:00
parent b12346eec3
commit 3e2b439fef
2 changed files with 16 additions and 4 deletions

View File

@ -1,3 +1,5 @@
jellyfin
sonarr
sabnzbd
homeassistant
picard

View File

@ -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"<span foreground=\"green\">$SERVICE</span>\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