Blob


1 # MyMenu
3 > A drop-in replacement for dmenu, 'cause I was bored
5 ![MyMenu works!](screen.png)
7 ![MyMenu alternate layout](screen-alt.png)
9 ---
11 ## What?
13 This is a drop-in replacement for `dmenu(1)`.
15 ## Why?
17 This was the perfect excuse to learn how to make window with Xlib.
19 ## How?
21 Check out the [manpage](mymenu.1) for further documentation. Check out
22 also the [template](Xexample) for the resources.
24 ---
26 ## Dependencies
28 - Xlib
29 - Xinerama (optional)
30 For multi-monitor support
31 - pkg-config (optional)
32 used in the makefile to generate `LIBS` and `CFLAGS` correctly
34 ## Build
36 As simple as `make`. If you want to disable Xinerama support just
37 delete `-DUSE_XINERAMA` from the `CFLAGS` and `xinerama` from the
38 `pkg-config` call from the Makefile.
40 ---
42 ## TODO
44 - Command line flags
46 At the moment the X Resource Database is the only way to interact
47 with the graphic appearance of MyMenu.
49 - Optional TrueType support
51 - Opacity support
53 ## Scripts
55 I'm using this script to launch MyMenu with custom item
57 ``` shell
58 #!/bin/sh
60 cat <<EOF | /bin/sh -c "$(mymenu "$@")"
61 sct 4500
62 lock
63 connect ethernet
64 connect home
65 connect phone
66 ZZZ
67 zzz
68 ...
69 EOF
70 ```
72 You can generate a menu from the `.desktop` file with something like
73 this:
75 ``` shell
76 #!/bin/sh
78 getname() {
79 cat $1 | grep '^Name=' | sed 's/^.*=//'
80 }
82 getexec() {
83 cat $1 | grep '^Exec=' | sed 's/^.*=//'
84 }
86 desktop_files=`ls /usr/local/share/applications/*.desktop`
88 {
89 for i in $desktop_files; do
90 getname $i
91 done
92 } | mymenu "$@" | {
93 read prgname
94 for i in $desktop_files; do
95 name=`getname $i`
96 if [ "x$prgname" = "x$name" ]; then
97 exec `getexec $i`
98 fi
99 done
101 ```
103 or generate a list of executables from `$PATH` like this:
105 ``` shell
106 #!/bin/sh
108 path=`echo $PATH | sed 's/:/ /g'`
111 for i in $path; do
112 ls -F $i | grep '.*\*$' | sed 's/\*//'
113 done
114 } | sort | /bin/sh -c "$(mymenu "$@")"
115 ```
117 Of course you can as well use the `dmenu_path` and `dmenu_run` scripts
118 that (usually) comes with `dmenu`.