diff options
| author | tslil clingman <> | 2020-10-19 10:33:54 -0400 |
|---|---|---|
| committer | tslil clingman <> | 2020-10-19 10:35:56 -0400 |
| commit | 24fff7a3ceac1dfaa19518ba806f36a019e9273b (patch) | |
| tree | 69f619a5ca0b2c98366191c4111520b146fd2c34 /qubes-dwm-6.2/scripts/dmenu_cur | |
| parent | ae0602777a5739796f4bf7f2f8d47e5dfede7af4 (diff) | |
Tracking my Qubes DWM configuration
Diffstat (limited to 'qubes-dwm-6.2/scripts/dmenu_cur')
| -rwxr-xr-x | qubes-dwm-6.2/scripts/dmenu_cur | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/qubes-dwm-6.2/scripts/dmenu_cur b/qubes-dwm-6.2/scripts/dmenu_cur new file mode 100755 index 0000000..fd8f152 --- /dev/null +++ b/qubes-dwm-6.2/scripts/dmenu_cur @@ -0,0 +1,59 @@ +#!/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 | grep ':Name=' \ + | sed 's/'"$1"': //' | cut -d= -f2- | sort +} + +filter() { + grep -v "Qube Settings" +} + +tidy() { + sed 's/Rxvt Color Unicode Terminal/urxvt/' +} + +untidy() { + sed 's/urxvt/Rxvt Color Unicode Terminal/' +} + +find_file() { + grep "^Name=.*$2" "$(app_path $1)"/*.desktop | 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" | filter | tidy | sort | wrap_dmenu -p "$qube" $colour $* | untidy) +[ -z "$choice" ] && exit + +file="$(find_file "$qube" "$choice")" +[ -z "$file" ] && exit + +execute_app "$file" |
