forked from 3o14r473/qmenu
-
Notifications
You must be signed in to change notification settings - Fork 2
/
qmenu-al
executable file
·76 lines (61 loc) · 2.36 KB
/
qmenu-al
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/sh
# Author: SINE3o14NNAE <https://github.com/sine3o14nnae/qmenu/>
help() {
printf "qmenu-al [OPTION] (--light-theme)\nLaunch domU applications.\n\n --all\n --focused\n"
}
if [ "$2" = "--light-theme" ]; then
theme_0='#ffffff'
theme_1='#000000'
else
theme_0='#000000'
theme_1='#ffffff'
fi
case $1 in
--all)
app_list=$(cat "$HOME"/.local/share/applications/*.desktop |
grep '^Name=.*\|^Exec=.*' | grep -vw 'Qube Settings\|qubes-vm-settings')
chosen=$(echo "$app_list" | grep '^Name=.*' | cut -c 6- |
dmenu -f -m 0 -nb $theme_0 -nf $theme_1 -sb $theme_1 -sf $theme_0)
if [ -n "$chosen" ]; then
if ! echo "$app_list" | grep -A1 "$chosen" | grep '^Exec=.*' | cut -c 6-; then exit 2; fi
exit 0
fi
exit 1
;;
--focused)
qube=$(xprop -id "$(xdotool getwindowfocus)" |
grep -w "^_QUBES_VMNAME(STRING)" |
cut -f2 -d\")
if [ -n "$qube" ]; then
qube_label=$(qvm-ls --raw-data "$qube" -O LABEL)
# Change label colors according configuration file
# User wide: ~/.config/qmenu.conf
# System wide: /etc/qmenu/qmenu.conf
if [ -e "$HOME/.config/qmenu.conf" ]; then
qmenu_conf="$HOME/.config/qmenu.conf"
elif [ -e "/etc/qmenu/qmenu.conf" ]; then
qmenu_conf="/etc/qmenu/qmenu.conf"
fi
if [ -n "$qmenu_conf" ]; then
qube_label=$(grep "^$qube_label=" "$qmenu_conf" | cut -d= -f2)
fi
app_list=$(cat "$HOME"/.local/share/qubes-appmenus/"$qube"/apps/*.desktop |
grep '^Name=.*\|^Exec=.*' |
grep -vw 'Qube Settings\|qubes-vm-settings')
chosen=$(echo "$app_list" | grep '^Name=.*' | cut -f2- -d: |
dmenu -p "$qube:" -f -m 0 -nb $theme_0 -nf $theme_1 -sb "$qube_label" -sf $theme_1)
if [ -n "$chosen" ]; then
if ! echo "$app_list" | grep -A1 "$chosen" | grep '^Exec=.*' | cut -c 6-; then exit 2; fi
exit 0
fi
exit 1
fi
exit 2
;;
*)
help
if [ "$1" = "--help" ]; then exit 0; else exit 2; fi
;;
esac
# Note that the '-m 0' option in 'dmenu' is important
# for security, as it restricts it to monitor 0.