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