Rofi menu organization

So I recently installed i3wm in my Qubes desktop because it feels better for me.
I’ve coded some shitty bash scripts to help me organize the rofi menu, because dmenu sucks for me.
It’s still buggy because is just a vague idea of what i want to do, but the base is here and maybe somebody get’s an idea to customize it and make it a stable piece of code for their use case.
In dom0:

  • Install rofi in dom0 with sudo qubes-dom0-update rofi
  • Create the folder ~/rofi_qubes_appmenu
  • Create these files inside that folder:

main_menu.sh

#!/bin/bash

# Get a list of all available qubes VMs
qubes=$(ls -la ~/.local/share/applications/ | grep "org.qubes-os.qubes-vm-settings.*" | cut -d '.' -f 4 | cut -b 2- | sed -r 's/_d/-/g')

# Open a VM menu. There, it is possible to select one of them
chosen=$(echo -e "Exit\ndom0\n$qubes" | rofi -dmenu -p "Select qube")

# Run an app menu of that qube VM
#~/rofi_qubes_appmenu/app_menu.sh $chosen

if [ "$chosen" = "Exit" ]; then
	exit
elif [ "$chosen" = "dom0" ]; then
    	~/rofi_qubes_appmenu/dom0_menu.sh
else
	#ls ~/.local/share/applications/org.qubes-os.vm._$chosen.* | rofi -show drun
	~/rofi_qubes_appmenu/app_menu.sh $chosen
fi

app_menu.sh

#!/bin/bash
# Rebuild the name format used by the .desktop files
qube=$(echo "$1" | sed -r 's/-/_d/g')

# Get the name of available apps
apps=$(grep -h "^Name=" ~/.local/share/applications/org.qubes-os.vm._$qube.* | sed 's/^Name=//')

# Let the user select the app. Also, make a settings option available
chosen=$(echo -e "Back\n$apps\nSettings" | rofi -dmenu -p "$1 - Select app")

if [ "$chosen" = "Back" ]; then
	~/rofi_qubes_appmenu/main_menu.sh
elif [ "$chosen" = "Settings" ]; then
	exo-open ~/.local/share/applications/org.qubes-os.qubes-vm-settings._$qube.desktop
else
	#exo-open $(ls ~/.local/share/applications/org.qubes-os.vm._$qube.* | grep $chosen.desktop)
	#grep -h "^Exec=" $(grep -rl "^Name=$1: $chosen" ~/.local/share/applications/org.qubes-os.vm._$qube.* | head -n1) | sed 's/^Exec=//'
	$(grep -h "^Exec=" $(grep -rl "^Name=$chosen" ~/.local/share/applications/org.qubes-os.vm._$qube.* | head -n1) | sed 's/^Exec=//')
fi

disposable_menu.sh

#!/bin/bash
# Rebuild the name format used by the .desktop files
qube=$(echo "$1" | sed -r 's/-/_d/g')

# Get the name of available apps
apps=$(grep -h "^Name=" ~/.local/share/applications/org.qubes-os.dispvm._$qube.* | sed 's/^Name=//')

# Let the user select the app. Also, make a settings option available
chosen=$(echo -e "$apps\nSettings" | rofi -dmenu -p "$1 - Select app")


if [[ "$chosen" = "Settings" ]]
then
	exo-open ~/.local/share/applications/org.qubes-os.qubes-vm-settings._$qube.desktop
else
	#exo-open $(ls ~/.local/share/applications/org.qubes-os.vm._$qube.* | grep $chosen.desktop)
	#grep -h "^Exec=" $(grep -rl "^Name=$1: $chosen" ~/.local/share/applications/org.qubes-os.vm._$qube.* | head -n1) | sed 's/^Exec=//'
	$(grep -h "^Exec=" $(grep -rl "^Name=$chosen" ~/.local/share/applications/org.qubes-os.dispvm._$qube.* | head -n1) | sed 's/^Exec=//')
fi
  • Last, create a keybind in ~/.config/i3/config to launch rofi (or replace the one used by dmenu). Example: bindsym $mod+d exec --no-startup-id ~/rofi_qubes_appmenu/main_menu.sh

Notes: I haven’t implemented the disposable_menu.sh yet, so it wont be used from the keybind. This means you are not spawning dispXXX from the rofi menu, but a default-dvm qube. My temporal workaround is to launch from dom0 ~/rofi_qubes_appmenu/disposable_menu.sh default-dvm.

The idea behind this config was to have a menu a little bit more similar to the one I had in XFCE, which i loved, but being easier to use with only the keyboard.
Anyways, this is probably a waste of time and default rofi -drun is easier than getting things over-complicated (and i think i will end up doing this), but anyway, if this is useful for somebody that’s great