25 lines
819 B
Fish
Executable File
25 lines
819 B
Fish
Executable File
#!/usr/bin/env fish
|
|
|
|
# User chooses service
|
|
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)
|
|
if not contains $SERVICE $SERVICES
|
|
exit
|
|
end
|
|
|
|
# User chooses action
|
|
set ACTIONS "start" "stop" "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
|
|
end
|
|
|
|
# Execute command
|
|
set COMMAND "systemctl $ACTION podman-$SERVICE.service"
|
|
set EVAL_RESULT "$(eval $COMMAND)"
|
|
|
|
if test $ACTION = "status" && test -n "$EVAL_RESULT"
|
|
# Display result if it exists
|
|
rofi -theme ~/NixFlake/config/rofi/rofi.rasi -e "$EVAL_RESULT"
|
|
end
|