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 - Xft (optional)
32 For TrueType (r) font support
33 - pkg-config (optional)
34 used in the makefile to generate `LIBS` and `CFLAGS` correctly
36 ## Build
38 As simple as `make` (or `make gnu` if you're using GNU libc). Keep in
39 mind that, by default, both Xft and Xinerama are enabled. So, you may
40 want to run:
42 - `make no_xft` to build without xft support;
43 - `make no_xinerama` to build without xinerama support;
44 - `make no_xft_xinerama` to build without xinerama *and* no xft support.
46 #### ignore case completion / don't have `strcasestr(3)`
48 If you want to build without the ignore case completion or on your
49 platform `strcasestr(3)` isn't available, you have to update the
50 `Makefile` and remove `-DUSE_STRCASESTR`. A simple
51 ``` shell
52 sed -i.orig 's/-DUSE_STRCASESTR//g' Makefile
53 ```
54 should be enough.
57 ## FAQ
59 - Does not run / Hangs
61 At the startup mymenu will read `stdin` for a list of item, only
62 then it'll display a window. Are you sure that you're passing
63 something on standard input?
65 - License
67 The code is released under GPLv3, but I don't have strong
68 preference regard licenses, so if you ask I may release the code
69 also under a different license (a free software one of course).
71 - Will feature $X be added?
73 No. Or maybe Yes. In fact, it depends. Open an issue and let's
74 discuss. If it's something that's trivial to achieve in combo with
75 other tool maybe is not the case to add it here.
77 - Is feature $Y present? What $Z do? How to achieve $W?
79 Everything is documented in the man page. To read it, simply execute
80 `man -l mymenu.1` or `mandoc mymenu.1 | less` (depending on your
81 system the `-l` option may not be present).
83 ---
85 ## TODO
87 - Improve UTF8 support
89 The whole UTF8 support is still kinda naïve and should definitely
90 be improved.
92 - Opacity support
94 - Command line flags
96 At the moment the X Resource Database is the only way to interact
97 with the graphic appearance of MyMenu.
99 ## Scripts
101 I'm using this script to launch MyMenu with custom item
103 ``` shell
104 #!/bin/sh
106 cat <<EOF | /bin/sh -c "$(mymenu "$@")"
107 sct 4500
108 lock
109 connect ethernet
110 connect home
111 connect phone
112 ZZZ
113 zzz
114 ...
115 EOF
116 ```
118 You can generate a menu from the `.desktop` file with something like
119 this:
121 ``` shell
122 #!/bin/sh
124 getname() {
125 cat $1 | grep '^Name=' | sed 's/^.*=//'
128 getexec() {
129 cat $1 | grep '^Exec=' | sed 's/^.*=//'
132 desktop_files=`ls /usr/local/share/applications/*.desktop`
135 for i in $desktop_files; do
136 getname $i
137 done
138 } | mymenu "$@" | {
139 read prgname
140 for i in $desktop_files; do
141 name=`getname $i`
142 if [ "x$prgname" = "x$name" ]; then
143 exec `getexec $i`
144 fi
145 done
147 ```
149 or generate a list of executables from `$PATH` like this:
151 ``` shell
152 #!/bin/sh
154 path=`echo $PATH | sed 's/:/ /g'`
157 for i in $path; do
158 ls -F $i | grep '.*\*$' | sed 's/\*//'
159 done
160 } | sort -f | /bin/sh -c "$(mymenu "$@")"
161 ```
163 Of course you can as well use the `dmenu_path` and `dmenu_run` scripts
164 that (usually) comes with `dmenu`.