From be27c5d37d7bba27b79fa6674f6f4a6a8f488d3e Mon Sep 17 00:00:00 2001 From: ChUrl Date: Mon, 24 Apr 2023 20:07:36 +0200 Subject: [PATCH] Add rofi podman-systemd menu --- config/rofi/menus/containers.txt | 3 +++ config/rofi/menus/systemd-podman.fish | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 config/rofi/menus/containers.txt create mode 100755 config/rofi/menus/systemd-podman.fish diff --git a/config/rofi/menus/containers.txt b/config/rofi/menus/containers.txt new file mode 100644 index 00000000..517fab0a --- /dev/null +++ b/config/rofi/menus/containers.txt @@ -0,0 +1,3 @@ +jellyfin +homeassistant +picard \ No newline at end of file diff --git a/config/rofi/menus/systemd-podman.fish b/config/rofi/menus/systemd-podman.fish new file mode 100755 index 00000000..ae6b22f3 --- /dev/null +++ b/config/rofi/menus/systemd-podman.fish @@ -0,0 +1,25 @@ +#!/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) +if not contains $SERVICE $SERVICES + exit +end + +# User chooses action +set OPS "start" "stop" "status" +set OP (echo -e (string join "\n" $OPS) | rofi -theme ~/NixFlake/config/rofi/rofi.rasi -dmenu) +if not contains $OP $OPS + exit +end + +# Execute command +set COMMAND_ROOT "pkexec --user root systemctl $OP podman-$SERVICE.service" +set COMMAND_USER "systemctl $OP podman-$SERVICE.service" +set EVAL_RESULT "$(eval $COMMAND_USER)" + +# Display result if it exists +if test -n "$EVAL_RESULT" + rofi -theme ~/NixFlake/config/rofi/rofi.rasi -e "$EVAL_RESULT" +end