qubes=$(qvm-ls --no-spinner --all --exclude=dom0 -O name,label,template,netvm,default_dispvm,kernel | dmenu-unlinked -l 50 | cut -f1 -d\ ) if [ -n "$qubes" ]; then property=$(printf 'Default_DispVM\nKernel\nLabel\nTemplate\nNetVM' | dmenu-unlinked -i -l 5 -p "Select the property you wish to change:" | awk '{print tolower($0)}') if [ -n "$property" ]; then case $property in default_dispvm) if [ -z "$LIST_DISPTEMP" ]; then # [mediocre] Look up disposable templates in a very slow way because qvm-ls does not offer a flag for them for n in $(qvm-ls --raw-data -O NAME,FLAGS | grep '|a.....-.$' | cut -d '|' -f1); do qvm-prefs "$n" template_for_dispvms | grep -q True && LIST_DISPTEMP="$LIST_DISPTEMP\n$n" done fi value=$(printf "(Default)\n(None)$LIST_DISPTEMP" | dmenu-unlinked -l 50 -p "Select default dispvm:") if [ "$value" = '(None)' ]; then value=None elif [ "$value" = '(Default)' ]; then value=--default; fi;; kernel) value=$(echo --default | dmenu-unlinked -p "Enter kernel:");; label) value=$(printf 'Purple\nBlue\nGray\nGreen\nYellow\nOrange\nRed\nBlack' | dmenu-unlinked -i -l 8 -p "Select label:" | awk '{print tolower($0)}');; template) get_list template value=$(printf "(Default)\n$list" | dmenu-unlinked -l 50 -p "Select template:") [ "$value" = '(Default)' ] && value=--default;; netvm) get_list netvm value=$(printf "(Default)\n(None)\n$list" | dmenu-unlinked -l 50 -p "Select netvm:") if [ "$value" = '(None)' ]; then value=None elif [ "$value" = '(Default)' ]; then value=--default; fi;; *) esac if [ -n "$value" ]; then if nyprompt "Do you want to change the $property of all selected qubes to $value?"; then for qube in $qubes; do if [ "$property" = label ] || [ "$property" = template ] && qvm-check -q --running "$qube"; then echo Proceed... | dmenu-unlinked -p "Warning: Unable to change $property of $qube because it is not shut down." > /dev/null 2>&1 else qvm-prefs "$qube" "$property" "$value" || echo Proceed... | dmenu-unlinked -p "Error: Failed to set $property of $qube to '$value'!" > /dev/null 2>&1 fi done fi fi fi fi