1 be5b89f6 2018-05-18 omar.polo # MyMenu
3 68145755 2018-07-01 omar.polo > A menu for Xorg, '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 68145755 2018-07-01 omar.polo This is a simple menu for Xorg, like `dmenu(1)`.
15 be5b89f6 2018-05-18 omar.polo ## Why?
17 c1be85dd 2018-06-14 omar.polo This was the perfect excuse to learn how to use Xlib.
19 be5b89f6 2018-05-18 omar.polo ## How?
21 c1be85dd 2018-06-14 omar.polo Check out the [manpage](mymenu.1.md) for further documentation. Check
22 c1be85dd 2018-06-14 omar.polo out also the [template](Xexample) for the resources.
26 be5b89f6 2018-05-18 omar.polo ## Dependencies
29 e9107672 2018-07-01 omar.polo - Xinerama *(optional)* for multi-monitor support
30 e9107672 2018-07-01 omar.polo - Xft *(optional)* for TrueType font support
31 e9107672 2018-07-01 omar.polo - pkg-config *(optional)* to generate `LIBS` and `CFLAGS`
32 e9107672 2018-07-01 omar.polo - mandoc *(optional)* to generate the
33 e9107672 2018-07-01 omar.polo [markdown version of the manpage](mymenu.1.md)
35 be5b89f6 2018-05-18 omar.polo ## Build
37 75faf30e 2018-05-22 omar.polo As simple as `make` (or `make gnu` if you're using GNU libc). Keep in
38 75faf30e 2018-05-22 omar.polo mind that, by default, both Xft and Xinerama are enabled. So, you may
39 75faf30e 2018-05-22 omar.polo want to run:
41 75faf30e 2018-05-22 omar.polo - `make no_xft` to build without xft support;
42 75faf30e 2018-05-22 omar.polo - `make no_xinerama` to build without xinerama support;
43 75faf30e 2018-05-22 omar.polo - `make no_xft_xinerama` to build without xinerama *and* no xft support.
45 e9107672 2018-07-01 omar.polo Or you can update the first lines of the `Makefile` customizing
46 e9107672 2018-07-01 omar.polo `OPTIONAL` and `CDEFS` to your needs.
48 75faf30e 2018-05-22 omar.polo #### ignore case completion / don't have `strcasestr(3)`
50 75faf30e 2018-05-22 omar.polo If you want to build without the ignore case completion or on your
51 75faf30e 2018-05-22 omar.polo platform `strcasestr(3)` isn't available, you have to update the
52 75faf30e 2018-05-22 omar.polo `Makefile` and remove `-DUSE_STRCASESTR`. A simple
53 75faf30e 2018-05-22 omar.polo ``` shell
54 75faf30e 2018-05-22 omar.polo sed -i.orig 's/-DUSE_STRCASESTR//g' Makefile
56 75faf30e 2018-05-22 omar.polo should be enough.
61 9c241438 2018-05-20 omar.polo - Does not run / Hangs
63 9c241438 2018-05-20 omar.polo At the startup mymenu will read `stdin` for a list of item, only
64 9c241438 2018-05-20 omar.polo then it'll display a window. Are you sure that you're passing
65 9c241438 2018-05-20 omar.polo something on standard input?
67 9c241438 2018-05-20 omar.polo - Will feature $X be added?
69 c1be85dd 2018-06-14 omar.polo No. Or maybe yes. In fact, it depends. Open an issue and let's
70 9c241438 2018-05-20 omar.polo discuss. If it's something that's trivial to achieve in combo with
71 9c241438 2018-05-20 omar.polo other tool maybe is not the case to add it here.
73 9c241438 2018-05-20 omar.polo - Is feature $Y present? What $Z do? How to achieve $W?
75 c1be85dd 2018-06-14 omar.polo Everything is documented in the [man page](mymenu.1.md). To read
76 c1be85dd 2018-06-14 omar.polo it, simply execute `man -l mymenu.1` or `mandoc mymenu.1 | less`
77 c1be85dd 2018-06-14 omar.polo (depending on your system the `-l` option may not be present).
81 be5b89f6 2018-05-18 omar.polo ## TODO
83 75faf30e 2018-05-22 omar.polo - Improve UTF8 support
85 75faf30e 2018-05-22 omar.polo The whole UTF8 support is still kinda naïve and should definitely
86 75faf30e 2018-05-22 omar.polo be improved.
88 75faf30e 2018-05-22 omar.polo - Opacity support
90 be5b89f6 2018-05-18 omar.polo - Command line flags
92 be5b89f6 2018-05-18 omar.polo At the moment the X Resource Database is the only way to interact
93 be5b89f6 2018-05-18 omar.polo with the graphic appearance of MyMenu.
95 b836b1ec 2018-05-18 omar.polo ## Scripts
97 8880d5e3 2018-05-19 omar.polo I'm using this script to launch MyMenu with custom item
99 b836b1ec 2018-05-18 omar.polo ``` shell
100 b836b1ec 2018-05-18 omar.polo #!/bin/sh
102 b836b1ec 2018-05-18 omar.polo cat <<EOF | /bin/sh -c "$(mymenu "$@")"
103 b836b1ec 2018-05-18 omar.polo sct 4500
105 b836b1ec 2018-05-18 omar.polo connect ethernet
106 b836b1ec 2018-05-18 omar.polo connect home
107 b836b1ec 2018-05-18 omar.polo connect phone
114 8880d5e3 2018-05-19 omar.polo You can generate a menu from the `.desktop` file with something like
117 8880d5e3 2018-05-19 omar.polo ``` shell
118 8880d5e3 2018-05-19 omar.polo #!/bin/sh
120 8880d5e3 2018-05-19 omar.polo getname() {
121 8880d5e3 2018-05-19 omar.polo cat $1 | grep '^Name=' | sed 's/^.*=//'
124 8880d5e3 2018-05-19 omar.polo getexec() {
125 8880d5e3 2018-05-19 omar.polo cat $1 | grep '^Exec=' | sed 's/^.*=//'
128 8880d5e3 2018-05-19 omar.polo desktop_files=`ls /usr/local/share/applications/*.desktop`
131 8880d5e3 2018-05-19 omar.polo for i in $desktop_files; do
132 8880d5e3 2018-05-19 omar.polo getname $i
134 8880d5e3 2018-05-19 omar.polo } | mymenu "$@" | {
135 8880d5e3 2018-05-19 omar.polo read prgname
136 8880d5e3 2018-05-19 omar.polo for i in $desktop_files; do
137 8880d5e3 2018-05-19 omar.polo name=`getname $i`
138 8880d5e3 2018-05-19 omar.polo if [ "x$prgname" = "x$name" ]; then
139 8880d5e3 2018-05-19 omar.polo exec `getexec $i`
145 8880d5e3 2018-05-19 omar.polo or generate a list of executables from `$PATH` like this:
147 8880d5e3 2018-05-19 omar.polo ``` shell
148 8880d5e3 2018-05-19 omar.polo #!/bin/sh
150 8880d5e3 2018-05-19 omar.polo path=`echo $PATH | sed 's/:/ /g'`
153 8880d5e3 2018-05-19 omar.polo for i in $path; do
154 8880d5e3 2018-05-19 omar.polo ls -F $i | grep '.*\*$' | sed 's/\*//'
156 75faf30e 2018-05-22 omar.polo } | sort -f | /bin/sh -c "$(mymenu "$@")"
159 b836b1ec 2018-05-18 omar.polo Of course you can as well use the `dmenu_path` and `dmenu_run` scripts
160 b836b1ec 2018-05-18 omar.polo that (usually) comes with `dmenu`.