Blame


1 1c3618fe 2020-10-14 op # mymenu
2 1c3618fe 2020-10-14 op > a menu of mine
3 1c3618fe 2020-10-14 op
4 1c3618fe 2020-10-14 op mymenu is a simple, dmenu-inspired, menu for X11. It was written because of NIH, because I was bored, and because it was the perfect opportunity to learn more about X11 and xlib. Jokes aside, is a fully functional and very customizable menu that I use every day.
5 1c3618fe 2020-10-14 op
6 1c3618fe 2020-10-14 op => https://git.omarpolo.com/mymenud Git repo
7 1c3618fe 2020-10-14 op => https://github.com/omar-polo/mymenu GitHub mirror
8 1c3618fe 2020-10-14 op
9 1c3618fe 2020-10-14 op It supports two layout: a vertical one (like rofi) and one horizontal (like dmenu). Various aspects are customizables: color, transparency, borders and window placement. It is very easily scriptable, and in the default repo you’ll find some example script (both in the manpage and in the scripts folder). Of course, you can easily adapt your dmenu/rofi scripts to mymenu if you want.
10 1c3618fe 2020-10-14 op
11 1c3618fe 2020-10-14 op For instance, here’s what I’m currently using. It has submenu and custom actions, so it could be a good example.
12 1c3618fe 2020-10-14 op
13 1c3618fe 2020-10-14 op ```
14 1c3618fe 2020-10-14 op #!/bin/ksh
15 1c3618fe 2020-10-14 op
16 1c3618fe 2020-10-14 op a-menu() {
17 1c3618fe 2020-10-14 op mymenu -f 'Go Mono-11' -l vertical -p '% ' \
18 1c3618fe 2020-10-14 op -W 50% -H 30% -P 10 -x center -y center \
19 1c3618fe 2020-10-14 op -C '#ffffea' -c '#000' -T '#ffffea' \
20 1c3618fe 2020-10-14 op -t '#000' -S '#000' -s '#fff' -b 3 \
21 1c3618fe 2020-10-14 op -a
22 1c3618fe 2020-10-14 op }
23 1c3618fe 2020-10-14 op
24 1c3618fe 2020-10-14 op # pass
25 1c3618fe 2020-10-14 op p() {
26 1c3618fe 2020-10-14 op prefix=${PASSWORD_STORE_DIR:-~/.password-store}
27 1c3618fe 2020-10-14 op set -A files -- "$prefix"/**/*.gpg "$prefix"/**/**/*.gpg
28 1c3618fe 2020-10-14 op typeit=${1:-yes}
29 1c3618fe 2020-10-14 op
30 1c3618fe 2020-10-14 op if p=$(printf '%s\n' ${files[@]} | sed -e 's/\.gpg$//' -e "s,^$prefix/,," | a-menu); then
31 1c3618fe 2020-10-14 op if [ "$typeit" = yes ]; then
32 1c3618fe 2020-10-14 op pass show "$p" | { IFS= read -r pass; printf %s "$pass"; } |
33 1c3618fe 2020-10-14 op xdotool type --clearmodifiers --file -
34 1c3618fe 2020-10-14 op else
35 1c3618fe 2020-10-14 op pass show --clip "$password"
36 1c3618fe 2020-10-14 op fi
37 1c3618fe 2020-10-14 op fi
38 1c3618fe 2020-10-14 op }
39 1c3618fe 2020-10-14 op
40 1c3618fe 2020-10-14 op # exec
41 1c3618fe 2020-10-14 op e() {
42 1c3618fe 2020-10-14 op if ! x=$(a-menu); then
43 1c3618fe 2020-10-14 op return
44 1c3618fe 2020-10-14 op elif [ "$x" = "pass" ]; then
45 1c3618fe 2020-10-14 op p yes
46 1c3618fe 2020-10-14 op elif [ "$x" = "pass copy" ]; then
47 1c3618fe 2020-10-14 op p nope
48 1c3618fe 2020-10-14 op elif [ "$x" = "keep" ]; then
49 1c3618fe 2020-10-14 op exec keepassxc
50 1c3618fe 2020-10-14 op else
51 1c3618fe 2020-10-14 op exec $x
52 1c3618fe 2020-10-14 op fi
53 1c3618fe 2020-10-14 op }
54 1c3618fe 2020-10-14 op
55 1c3618fe 2020-10-14 op (
56 1c3618fe 2020-10-14 op echo keep
57 1c3618fe 2020-10-14 op echo firefox
58 1c3618fe 2020-10-14 op # ...
59 1c3618fe 2020-10-14 op echo pass
60 1c3618fe 2020-10-14 op echo pass copy # not "copy pass" so it's after pass
61 1c3618fe 2020-10-14 op ) | e
62 1c3618fe 2020-10-14 op ```