summaryrefslogtreecommitdiff
path: root/debian/.local/bin/dmenuvirt
diff options
context:
space:
mode:
authorTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-12-24 13:54:03 +0900
committerTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-12-24 13:54:03 +0900
commit28e8bdf7f8286bd431b7f3b709e79f3827b31469 (patch)
tree85b44eff6da4d8443198fb6e04dfb6ee55244588 /debian/.local/bin/dmenuvirt
parent8470ff001befcfd0f626dea69a9e76d43aee0511 (diff)
updates
Diffstat (limited to 'debian/.local/bin/dmenuvirt')
-rwxr-xr-xdebian/.local/bin/dmenuvirt28
1 files changed, 28 insertions, 0 deletions
diff --git a/debian/.local/bin/dmenuvirt b/debian/.local/bin/dmenuvirt
new file mode 100755
index 0000000..bc90680
--- /dev/null
+++ b/debian/.local/bin/dmenuvirt
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+# Select action
+choice=$(printf "virt-manager\nstart\nshutdown" | dmenu -i -p "Choose an action:")
+[ -z "$choice" ] && exit 1
+
+# Get list of VMs based on state
+case "$choice" in
+virt-manager) setsid -f virt-manager && exit ;;
+start) vmlist=$(virsh --connect qemu:///system list --all | awk '/shut off/ {print $2}') ;;
+shutdown) vmlist=$(virsh --connect qemu:///system list --all | awk '/running/ {print $2}') ;;
+*) exit 1 ;;
+esac
+
+# Select a VM from the list
+vm=$(printf "%s\n" "$vmlist" | dmenu -i -p "$choice which VM?")
+[ -z "$vm" ] && exit 1
+
+# Perform the action
+case "$choice" in
+start)
+ virsh --connect qemu:///system start "$vm" &&
+ setsid -f virt-viewer --connect qemu:///system "$vm" >/dev/null 2>&1
+ ;;
+shutdown)
+ virsh --connect qemu:///system shutdown "$vm"
+ ;;
+esac