URI:
       Improve readability - qmenu - manage qubes os via dmenu (drkhsh fork)
  HTML git clone git://git.drkhsh.at/qmenu.git
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit 8e395cfd6f687834f4d4d3bb97f355e3155f8ad3
   DIR parent beb41b955abffc4773d36fa5362964ef9a59dec2
  HTML Author: sine3o14nnae <3o14@pm.me>
       Date:   Fri, 23 Aug 2019 18:50:24 +0200
       
       Improve readability
       
       Diffstat:
         M qmenu-vm                            |      60 ++++++++++++++++----------------
       
       1 file changed, 30 insertions(+), 30 deletions(-)
       ---
   DIR diff --git a/qmenu-vm b/qmenu-vm
       @@ -38,7 +38,7 @@ fqvm_preferences() {
                  
                 if [ -n "${LIST_OF_DISPTEMP}" ]; then unset LIST_OF_DISPTEMP; fi 
        
       -         # [mediocre] Look up disposable templates
       +         # [mediocre] Look up disposable templates.
                 for n in `qvm-ls --no-spinner --raw-data -O NAME,FLAGS |\
                   grep '|a.......$' | cut -d '|' -f1`; do
        
       @@ -207,7 +207,7 @@ fqvm_preferences() {
        
               netvm) 
                 
       -         # List netvm's via 'qvm-ls'
       +         # List netvm's via 'qvm-ls'.
                 local value_selected=`echo -e "(Default)\n(None)\n$(qvm-ls --no-spinner --raw-data --fields NAME,FLAGS |\
                   grep '|...N....$' | cut -d '|' -f1)" |\
                   dmenu -l 50 -p "Select netvm for $target_qube" $dmenu_fmc`
       @@ -284,7 +284,7 @@ fqvm_preferences() {
                     $dmenu_fmc &>/dev/null 
                 else
        
       -           # List templatevm's via 'qvm-ls'
       +           # List templatevm's via 'qvm-ls'.
                   local value_selected=`echo -e "(Default)\n$(qvm-ls --no-spinner --raw-data --fields NAME,FLAGS |\
                     grep '|t.......$' | cut -d '|' -f1)" |\
                     dmenu -l 50 -p "Select template for $target_qube" $dmenu_fmc`
       @@ -425,8 +425,8 @@ fqvm_pci() {
        
                 if [ "$answer" = "Yes" ]; then
                   
       -           # Check if there are more than one functions
       -           # that belong to the same device
       +           # Check if there is more than one function
       +           # that belongs to the same device.
                   local bdf_count=`echo "$list_pci" | awk '{ print $1 }' |\
                     grep $(echo $device_bdf | sed 's/\..*//') | wc -l` 
        
       @@ -479,7 +479,7 @@ fqvm_firewall() {
           if [ -n "$rule_selected" ]; then
                 
             # This will equal "NO" if the user selects the top row,
       -     # instead of any existing rule
       +     # instead of any existing rule.
             if [ "$rulenumber_selected" != "NO" ]; then 
                    
               local option=`echo -e "Add new rule above rule $rulenumber_selected\nRemove rule $rulenumber_selected" |\
       @@ -608,7 +608,7 @@ fqvm_devices() {
         else
        
           # Depending on the device type, we have to 
       -   # 'awk' different fields later on
       +   # 'awk' different fields later on.
           if [ "$chosefrom" = "Audio" ]; then
        
             local device_type="device mic"
       @@ -632,7 +632,7 @@ fqvm_devices() {
             local awk_devicename0=2
             local awk_devicename1=10
             local awk_targetqube=3
       -fi
       +   fi
            
           local devices_list=`qvm-$device_type`
        
       @@ -704,14 +704,14 @@ fqvm_applications() {
        
             while [ -n "$application" ]; do
                     
       -       # Only show applications that arent already selected for $target_qube via 'grep -v'
       +       # Only show applications that arent already selected for $target_qube via 'grep -v'.
               local application=`qvm-appmenus --get-available --i-understand-format-is-unstable $target_qube |\
                 grep -v "$(qvm-appmenus --get-whitelist --i-understand-format-is-unstable $target_qube)" |\
                 dmenu -l 50 -p "$target_qube:" $dmenu_fmc | awk '{ print $1 }'`
                     
               if [ -n "$application" ]; then
                
       -         # Check validity of input
       +         # Check validity of input.
                 if qvm-appmenus --get-available --i-understand-format-is-unstable $target_qube |\
                   awk '{ print $1 }' | grep -w $application; then
        
       @@ -728,14 +728,14 @@ fqvm_applications() {
        
             while [ -n "$application" ]; do
        
       -       # Show complete application and .desktop names via 'grep'
       +       # Show complete application and .desktop names via 'grep'.
               local application=`qvm-appmenus --get-available --i-understand-format-is-unstable $target_qube |\
                 grep "$(qvm-appmenus --get-whitelist --i-understand-format-is-unstable $target_qube)" |\
                 dmenu -l 50 -p "$target_qube:" $dmenu_fmc | awk '{ print $1 }'`
        
               if [ -n "$application" ]; then
        
       -         # Look up linenumber above $application in /whitelisted-appmenus.list and delete whitespace
       +         # Look up linenumber above $application in /whitelisted-appmenus.list and delete whitespace.
                 local whitespace_app=`cat $HOME/.local/share/qubes-appmenus/$target_qube/whitelisted-appmenus.list |\
                   grep -n $application | cut -c 1`
        
       @@ -771,7 +771,7 @@ fqvm_service() {
           if [ -n "$service" ]; then
        
             # If the service has already been added to the list,
       -     # give option to unset it
       +     # give option to unset it.
             if qvm-service $target_qube --list | grep -w $service; then
                 
               local unset="\nUnset"
       @@ -813,7 +813,7 @@ fqvm_service() {
        
        fqvm_disk() {
         
       - # If $target_qube is template or standalone, give option to extend root storage 
       + # If $target_qube is template or standalone, give option to extend root storage.
         if [[ "$(qvm-ls -O flags $target_qube | sed '2q;d' | cut -c 1)" =~ ^(t|S)$ ]]; then
        
           local volume=`echo -e "Root\nPrivate" |\
       @@ -863,7 +863,7 @@ fqvm_keyboard() {
         # 'qmenu-vm' does not get informed about the installed layouts by the vm itself
         # so there is a chance that the selected layout is missing inside the vm.
         # Getting the info from the vm itself however would have security implications
       - # so we will not switch to use that method
       + # so we will not switch to use that method.
         local LAYOUT+=$(ls /usr/share/X11/xkb/symbols |\
           dmenu -l 50 -p "$target_qube:" $dmenu_fmc)
         
       @@ -970,14 +970,14 @@ fqvm_run() {
        
        
        
       +# Change black, yellow and green to a more readable color if needed.
        correct_qube_label() {
        
       - # Change black, yellow and green to a more readable color if needed
         if [ "$qube_label" = "black" ]; then
        
           qube_label='#373737'
         
       - # Change only if dark theme is selected
       + # Change only if dark theme is selected.
         elif [ "$theme_1" = "#ffffff" ]; then
        
           if [ "$qube_label" = "yellow" ]; then 
       @@ -1018,7 +1018,7 @@ fdom0_preferences() {
        
             clockvm)
        
       -       # List netvm's via 'qvm-ls'
       +       # List netvm's via 'qvm-ls'.
               local value_selected=`echo -e "$(qvm-ls --no-spinner --raw-data --fields NAME,FLAGS |\
                 grep '|...N....$' | cut -d '|' -f1)" |\
                 dmenu -l 50 -p "Select new ClockVM" $dmenu_d0`
       @@ -1032,7 +1032,7 @@ fdom0_preferences() {
        
               if [ -n "${LIST_OF_DISPTEMP}" ]; then unset LIST_OF_DISPTEMP; fi
        
       -       # [mediocre] Look up disposable templates
       +       # [mediocre] Look up disposable templates.
               for n in `qvm-ls --no-spinner --raw-data -O NAME,FLAGS |\
                 grep '|a.......$' | cut -d '|' -f1`; do
        
       @@ -1083,7 +1083,7 @@ fdom0_preferences() {
        
             default_netvm)
        
       -       # List netvm's via 'qvm-ls'
       +       # List netvm's via 'qvm-ls'.
               local value_selected=`echo -e "$(qvm-ls --no-spinner --raw-data --fields NAME,FLAGS |\
                 grep '|...N....$' | cut -d '|' -f1)" |\
                 dmenu -l 50 -p "Select netvm for $target_qube" $dmenu_d0`
       @@ -1172,7 +1172,7 @@ fdom0_preferences() {
        
             default_template)
        
       -       # List templatevm's via 'qvm-ls'
       +       # List templatevm's via 'qvm-ls'.
               local value_selected=`qvm-ls --no-spinner --raw-data --fields NAME,FLAGS |\
                 grep '|t.......$' | cut -d '|' -f1 |\
                 dmenu -l 50 -p "Select default template for" $dmenu_d0`
       @@ -1186,7 +1186,7 @@ fdom0_preferences() {
        
               if [ -n "${LIST_OF_DISPTEMP}" ]; then unset LIST_OF_DISPTEMP; fi
        
       -         # [mediocre] Look up disposable templates
       +         # [mediocre] Look up disposable templates.
                 for n in `qvm-ls --no-spinner --raw-data -O NAME,FLAGS |\
                   grep '|a.......$' | cut -d '|' -f1`; do
        
       @@ -1223,7 +1223,7 @@ fdom0_preferences() {
        
             updatevm) 
        
       -       # List netvm's via 'qvm-ls'
       +       # List netvm's via 'qvm-ls'.
               local value_selected=`echo -e "$(qvm-ls --no-spinner --raw-data --fields NAME,FLAGS |\
                 grep '|...N....$' | cut -d '|' -f1)" |\
                 dmenu -l 50 -p "Select new UpdateVM" $dmenu_d0`
       @@ -1280,8 +1280,8 @@ rearrange_qube_list() {
         local QUBE_LIST_REARRANGED+=`echo "\n$(echo "$qube_list" |\
           awk '$1 == "dom0"')"`
        
       - # "\n" will create blank lines if an option 
       - # other than '--all' is selected so we remove them with 'sed'
       + # "\n" will create blank lines if a label is missing,
       + # so we remove them with 'sed'.
         qube_list=`echo -e "$QUBE_LIST_REARRANGED" | sed "{/^$/d;}"`
        }
        
       @@ -1295,9 +1295,9 @@ if [ -z "$show_qubes" ]; then
        
          exit 2
        
       -# 'qvm-ls --all' will not list dom0 because of a bug.
       +# As of 2019.08.23, 'qvm-ls --all' will not list dom0 because of a bug.
        # As a workaround, we will output $1 into a variable
       -# and unset it when '--all' is used
       +# and unset it when '--all' is used.
        elif [ "$show_qubes" = "--all" ]; then
        
          unset show_qubes
       @@ -1316,7 +1316,7 @@ fi
        while true; do
            
          # Load 'qvm-ls' into a variable so that it doesnt 
       -  # need to reload again after every user operation
       +  # need to reload again after every user operation.
          qube_list=`qvm-ls --no-spinner $show_qubes -O NAME,STATE,LABEL,CLASS\
        ,TEMPLATE,NETVM,IP,PRIV-MAX,PRIV-CURR,PRIV-USED,ROOT-MAX\
        ,ROOT-CURR,ROOT-USED,KERNEL,KERNELOPTS`
       @@ -1326,7 +1326,7 @@ while true; do
          if [ -n "$target_qube" ]; then unset target_qube; fi 
        
          # Get out of the while loop and refresh 'qvm-ls' by loading it again
       -  # into $qube_list whenever the user selects the 'qvm-ls' top row
       +  # into $qube_list, whenever the user selects the 'qvm-ls' top row.
          while [ "$target_qube" != "NAME" ]; do
        
            target_qube=`echo "$qube_list" | dmenu -f -m 0 -l 69 \
       @@ -1350,7 +1350,7 @@ while true; do
                correct_qube_label
                    
                # Note that the '-m 0' option in 'dmenu' is important
       -        # for security as it restricts it to monitor 0
       +        # for security, as it restricts it to monitor 0.
                dmenu_fmc="-m 0 -nb $theme_0 -nf $theme_1 -sb $qube_label -sf $theme_1"
        
                chosefrom=0