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`. By default both Xft and Xinerama are enabled, if
39 you want to disable them just delete the relative `-DUSE_` from the
40 `CFLAGS` and update the `OPTIONAL` variable. Of course you can delete
41 both, or just one of them.
43 ## FAQ
45 - Does not run / Hangs
47 At the startup mymenu will read `stdin` for a list of item, only
48 then it'll display a window. Are you sure that you're passing
49 something on standard input?
51 - License
53 The code is released under GPLv3, but I don't have strong
54 preference regard licenses, so if you ask I may release the code
55 also under a different license (a free software one of course).
57 - Will feature $X be added?
59 No. Or maybe Yes. In fact, it depends. Open an issue and let's
60 discuss. If it's something that's trivial to achieve in combo with
61 other tool maybe is not the case to add it here.
63 - Is feature $Y present? What $Z do? How to achieve $W?
65 Everything is documented in the man page. To read it, simply execute
66 `man -l mymenu.1` or `mandoc mymenu.1 | less` (depending on your
67 system the `-l` option may not be present).
69 ---
71 ## TODO
73 - Command line flags
75 At the moment the X Resource Database is the only way to interact
76 with the graphic appearance of MyMenu.
78 - Opacity support
80 ## Scripts
82 I'm using this script to launch MyMenu with custom item
84 ``` shell
85 #!/bin/sh
87 cat <<EOF | /bin/sh -c "$(mymenu "$@")"
88 sct 4500
89 lock
90 connect ethernet
91 connect home
92 connect phone
93 ZZZ
94 zzz
95 ...
96 EOF
97 ```
99 You can generate a menu from the `.desktop` file with something like
100 this:
102 ``` shell
103 #!/bin/sh
105 getname() {
106 cat $1 | grep '^Name=' | sed 's/^.*=//'
109 getexec() {
110 cat $1 | grep '^Exec=' | sed 's/^.*=//'
113 desktop_files=`ls /usr/local/share/applications/*.desktop`
116 for i in $desktop_files; do
117 getname $i
118 done
119 } | mymenu "$@" | {
120 read prgname
121 for i in $desktop_files; do
122 name=`getname $i`
123 if [ "x$prgname" = "x$name" ]; then
124 exec `getexec $i`
125 fi
126 done
128 ```
130 or generate a list of executables from `$PATH` like this:
132 ``` shell
133 #!/bin/sh
135 path=`echo $PATH | sed 's/:/ /g'`
138 for i in $path; do
139 ls -F $i | grep '.*\*$' | sed 's/\*//'
140 done
141 } | sort | /bin/sh -c "$(mymenu "$@")"
142 ```
144 Of course you can as well use the `dmenu_path` and `dmenu_run` scripts
145 that (usually) comes with `dmenu`.