#!/bin/sh get_colour() { local colour=$(xprop -id $1 | grep '_QUBES_LABEL_COLOR(CARDINAL)' | cut -d\ -f3) printf "#%06X" $colour } app_path() { if [ "$1" = "dom0" ]; then echo "$HOME/.local/share/applications/" ; else echo "$HOME/.local/share/qubes-appmenus/$1"/apps/ ; fi; } scrape_apps() { grep '^Name=\|^Exec=' "$(app_path $1)"/*.desktop | filter | grep ':Name=' \ | sed 's/'"$1"': //' | cut -d= -f2- | sort } filter() { grep -v "Qube Settings\|os\.vm\.debian-11-dvm\|os\.vm\.whonix-ws-16" } find_file() { grep "^Name=.*$2" "$(app_path $1)"/*.desktop | filter | cut -d: -f1 } # Expects the contents of a desktop file execute_app() { local cmd="$(grep '^Exec=' "$1" | cut -d= -f2-)" eval " $cmd" } win_id=$(get_id) qube="$(get_qube)" if [ -z "$qube" ]; then qube="dom0"; colour=""; else colour="-sb $(get_colour $win_id)" fi; choice=$(scrape_apps "$qube" | sort | wrap_dmenu -p "$qube" $colour $*) [ -z "$choice" ] && exit file="$(find_file "$qube" "$choice")" [ -z "$file" ] && exit execute_app "$file"