Home
       qmenu-al - qmenu - 🇶 manage qubes os via dmenu - fixed forked version
  HTML git clone https://git.drkhsh.at/qmenu.git
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
       qmenu-al (2176B)
       ---
            1 #!/bin/sh
            2 # Author: SINE3o14NNAE <https://github.com/sine3o14nnae/qmenu/>
            3 
            4 help() {
            5   printf "qmenu-al [OPTION]\nLaunch domU applications.\n\n --all\n --focused\n"
            6 }
            7 
            8 case $1 in
            9     --all)
           10         app_list=$(cat "$HOME"/.local/share/applications/*.desktop |
           11             grep '^Name=.*\|^Exec=.*' | grep -vw 'Qube Settings\|qubes-vm-settings')
           12 
           13         chosen=$(echo "$app_list" | grep '^Name=.*' | cut -c 6- |
           14             dmenu -f -m 0)
           15 
           16         if [ -n "$chosen" ]; then
           17             if ! echo "$app_list" | grep -A1 "^Name=$chosen" | grep '^Exec=.*' | cut -c 6-; then exit 2; fi
           18             exit 0
           19         fi
           20 
           21         exit 1
           22         ;;
           23 
           24     --focused)
           25         qube=$(xprop -id "$(xdotool getwindowfocus)" |
           26             grep -w "^_QUBES_VMNAME(STRING)" |
           27             cut -f2 -d\")
           28 
           29         if [ -n "$qube" ]; then
           30             qube_label=$(qvm-ls --raw-data "$qube" -O LABEL)
           31 
           32             # Change label colors according configuration file
           33             # User wide: ~/.config/qmenu.conf
           34             # System wide: /etc/qmenu/qmenu.conf
           35             if [ -e "$HOME/.config/qmenu.conf" ]; then
           36                 qmenu_conf="$HOME/.config/qmenu.conf"
           37             elif [ -e "/etc/qmenu/qmenu.conf" ]; then
           38                 qmenu_conf="/etc/qmenu/qmenu.conf"
           39             fi
           40 
           41             if [ -n "$qmenu_conf" ]; then
           42                 qube_label=$(grep "^$qube_label=" "$qmenu_conf" | cut -d= -f2)
           43             fi
           44 
           45             app_list=$(cat "$HOME"/.local/share/qubes-appmenus/"$qube"/apps/*.desktop |
           46                 grep '^Name=.*\|^Exec=.*' |
           47                 grep -vw 'Qube Settings\|qubes-vm-settings')
           48 
           49             chosen=$(echo "$app_list" | grep '^Name=.*' | cut -f2- -d: |
           50                 dmenu -p "$qube:" -f -m 0 -sb "$qube_label")
           51 
           52             if [ -n "$chosen" ]; then
           53                 if ! echo "$app_list" | grep -A1 "^Name=$chosen" | grep '^Exec=.*' | cut -c 6-; then exit 2; fi
           54                 exit 0
           55             fi
           56             exit 1
           57         fi
           58         exit 2
           59         ;;
           60     *)
           61         help
           62 
           63         if [ "$1" = "--help" ]; then exit 0; else exit 2; fi
           64         ;;
           65 esac
           66 
           67 # Note that the '-m 0' option in 'dmenu' is important
           68 # for security, as it restricts it to monitor 0.