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 use Xlib.
19 ## How?
21 Check out the [manpage](mymenu.1.md) for further documentation. Check
22 out also the [template](Xexample) for the resources.
24 ---
26 ## Dependencies
28 - Xlib
29 - Xinerama (optional) for multi-monitor support
30 - Xft (optional) for TrueType font support
31 - pkg-config (optional) used in the makefile to generate `LIBS` and
32 `CFLAGS` correctly
34 ## Build
36 As simple as `make` (or `make gnu` if you're using GNU libc). Keep in
37 mind that, by default, both Xft and Xinerama are enabled. So, you may
38 want to run:
40 - `make no_xft` to build without xft support;
41 - `make no_xinerama` to build without xinerama support;
42 - `make no_xft_xinerama` to build without xinerama *and* no xft support.
44 #### ignore case completion / don't have `strcasestr(3)`
46 If you want to build without the ignore case completion or on your
47 platform `strcasestr(3)` isn't available, you have to update the
48 `Makefile` and remove `-DUSE_STRCASESTR`. A simple
49 ``` shell
50 sed -i.orig 's/-DUSE_STRCASESTR//g' Makefile
51 ```
52 should be enough.
55 ## FAQ
57 - Does not run / Hangs
59 At the startup mymenu will read `stdin` for a list of item, only
60 then it'll display a window. Are you sure that you're passing
61 something on standard input?
63 - Will feature $X be added?
65 No. Or maybe yes. In fact, it depends. Open an issue and let's
66 discuss. If it's something that's trivial to achieve in combo with
67 other tool maybe is not the case to add it here.
69 - Is feature $Y present? What $Z do? How to achieve $W?
71 Everything is documented in the [man page](mymenu.1.md). To read
72 it, simply execute `man -l mymenu.1` or `mandoc mymenu.1 | less`
73 (depending on your system the `-l` option may not be present).
75 ---
77 ## TODO
79 - Improve UTF8 support
81 The whole UTF8 support is still kinda naïve and should definitely
82 be improved.
84 - Opacity support
86 - Command line flags
88 At the moment the X Resource Database is the only way to interact
89 with the graphic appearance of MyMenu.
91 ## Scripts
93 I'm using this script to launch MyMenu with custom item
95 ``` shell
96 #!/bin/sh
98 cat <<EOF | /bin/sh -c "$(mymenu "$@")"
99 sct 4500
100 lock
101 connect ethernet
102 connect home
103 connect phone
104 ZZZ
105 zzz
106 ...
107 EOF
108 ```
110 You can generate a menu from the `.desktop` file with something like
111 this:
113 ``` shell
114 #!/bin/sh
116 getname() {
117 cat $1 | grep '^Name=' | sed 's/^.*=//'
120 getexec() {
121 cat $1 | grep '^Exec=' | sed 's/^.*=//'
124 desktop_files=`ls /usr/local/share/applications/*.desktop`
127 for i in $desktop_files; do
128 getname $i
129 done
130 } | mymenu "$@" | {
131 read prgname
132 for i in $desktop_files; do
133 name=`getname $i`
134 if [ "x$prgname" = "x$name" ]; then
135 exec `getexec $i`
136 fi
137 done
139 ```
141 or generate a list of executables from `$PATH` like this:
143 ``` shell
144 #!/bin/sh
146 path=`echo $PATH | sed 's/:/ /g'`
149 for i in $path; do
150 ls -F $i | grep '.*\*$' | sed 's/\*//'
151 done
152 } | sort -f | /bin/sh -c "$(mymenu "$@")"
153 ```
155 Of course you can as well use the `dmenu_path` and `dmenu_run` scripts
156 that (usually) comes with `dmenu`.