Blob


1 # MyMenu
3 > A 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 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 ## FAQ
42 - Does not run / Hangs
44 At the startup mymenu will read `stdin` for a list of item, only
45 then it'll display a window. Are you sure that you're passing
46 something on standard input?
48 - License
50 The code is released under GPLv3, but I don't have strong
51 preference regard licenses, so if you ask I may release the code
52 also under a different license (a free software one of course).
54 - Will feature $X be added?
56 No. Or maybe Yes. In fact, it depends. Open an issue and let's
57 discuss. If it's something that's trivial to achieve in combo with
58 other tool maybe is not the case to add it here.
60 - Is feature $Y present? What $Z do? How to achieve $W?
62 Everything is documented in the man page. To read it, simply execute
63 `man -l mymenu.1` or `mandoc mymenu.1 | less` (depending on your
64 system the `-l` option may not be present).
66 ---
68 ## TODO
70 - Command line flags
72 At the moment the X Resource Database is the only way to interact
73 with the graphic appearance of MyMenu.
75 - Optional TrueType support
77 - Opacity support
79 ## Scripts
81 I'm using this script to launch MyMenu with custom item
83 ``` shell
84 #!/bin/sh
86 cat <<EOF | /bin/sh -c "$(mymenu "$@")"
87 sct 4500
88 lock
89 connect ethernet
90 connect home
91 connect phone
92 ZZZ
93 zzz
94 ...
95 EOF
96 ```
98 You can generate a menu from the `.desktop` file with something like
99 this:
101 ``` shell
102 #!/bin/sh
104 getname() {
105 cat $1 | grep '^Name=' | sed 's/^.*=//'
108 getexec() {
109 cat $1 | grep '^Exec=' | sed 's/^.*=//'
112 desktop_files=`ls /usr/local/share/applications/*.desktop`
115 for i in $desktop_files; do
116 getname $i
117 done
118 } | mymenu "$@" | {
119 read prgname
120 for i in $desktop_files; do
121 name=`getname $i`
122 if [ "x$prgname" = "x$name" ]; then
123 exec `getexec $i`
124 fi
125 done
127 ```
129 or generate a list of executables from `$PATH` like this:
131 ``` shell
132 #!/bin/sh
134 path=`echo $PATH | sed 's/:/ /g'`
137 for i in $path; do
138 ls -F $i | grep '.*\*$' | sed 's/\*//'
139 done
140 } | sort | /bin/sh -c "$(mymenu "$@")"
141 ```
143 Of course you can as well use the `dmenu_path` and `dmenu_run` scripts
144 that (usually) comes with `dmenu`.