diff options
| -rwxr-xr-x | ar/.local/bin/dmenuvirt | 28 | ||||
| -rw-r--r-- | ar/.local/bin/refreshbrowser | 42 |
2 files changed, 28 insertions, 42 deletions
diff --git a/ar/.local/bin/dmenuvirt b/ar/.local/bin/dmenuvirt new file mode 100755 index 0000000..615c557 --- /dev/null +++ b/ar/.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 diff --git a/ar/.local/bin/refreshbrowser b/ar/.local/bin/refreshbrowser deleted file mode 100644 index ef3809a..0000000 --- a/ar/.local/bin/refreshbrowser +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh - -###################################################################### -# @author : Gavin Jaeger-Freeborn (gavinfreeborn@gmail.com) -# @file : test.sh -# @created : Wed 25 Mar 2020 05:49:29 PM -# -# @description : simple xdotool script used to reload browsers -###################################################################### - -browserclass="${qutebrowser:-firefox}" - -#=== FUNCTION ====================================================== -# NAME: moveto -# DESCRIPTION: move to the center of the specified window id -#===================================================================== -moveto() { - geom=$(xdotool getwindowgeometry "${1}") - local=$(echo "${geom}" | awk NR==2 | cut -d: -f 2 | cut -d\( -f 1) - dimentions=$(echo "${geom}" | awk NR==3 | cut -d: -f 2 | cut -d\( -f 1 | cut -d, -f1) - x=$(echo "${local}" | cut -d, -f1) - y=$(echo "${local}" | cut -d, -f2) - w=$(echo "${dimentions}" | cut -dx -f1) - h=$(echo "${dimentions}" | cut -dx -f2) - - xdotool mousemove $((x + w / 2)) $((y + h / 2)) -} - -# Save the current window -cwid=$(xdotool getwindowfocus) -# Find the browser window -twid=$(xdotool search --onlyvisible --class "${browserclass}") -[ -z "${twid}" ] && notify-send 'failed to determine browser window' && exit -[ -z "${cwid}" ] && notify-send 'failed to determine current window' && exit - -moveto "${twid}" - -xdotool key F5 - -moveto "${cwid}" - -# vim: set tw=78 ts=2 et sw=2 sr: |
