Blame


1 be5b89f6 2018-05-18 omar.polo # MyMenu
2 be5b89f6 2018-05-18 omar.polo
3 eccc9e7a 2018-05-20 omar.polo > A replacement for dmenu, 'cause I was bored
4 be5b89f6 2018-05-18 omar.polo
5 be5b89f6 2018-05-18 omar.polo ![MyMenu works!](screen.png)
6 be5b89f6 2018-05-18 omar.polo
7 36a15a9f 2018-05-19 omar.polo ![MyMenu alternate layout](screen-alt.png)
8 36a15a9f 2018-05-19 omar.polo
9 be5b89f6 2018-05-18 omar.polo ---
10 be5b89f6 2018-05-18 omar.polo
11 be5b89f6 2018-05-18 omar.polo ## What?
12 be5b89f6 2018-05-18 omar.polo
13 eccc9e7a 2018-05-20 omar.polo This is a replacement for `dmenu(1)`.
14 be5b89f6 2018-05-18 omar.polo
15 be5b89f6 2018-05-18 omar.polo ## Why?
16 be5b89f6 2018-05-18 omar.polo
17 be5b89f6 2018-05-18 omar.polo This was the perfect excuse to learn how to make window with Xlib.
18 be5b89f6 2018-05-18 omar.polo
19 be5b89f6 2018-05-18 omar.polo ## How?
20 be5b89f6 2018-05-18 omar.polo
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.
23 be5b89f6 2018-05-18 omar.polo
24 be5b89f6 2018-05-18 omar.polo ---
25 be5b89f6 2018-05-18 omar.polo
26 be5b89f6 2018-05-18 omar.polo ## Dependencies
27 be5b89f6 2018-05-18 omar.polo
28 be5b89f6 2018-05-18 omar.polo - Xlib
29 be5b89f6 2018-05-18 omar.polo - Xinerama (optional)
30 be5b89f6 2018-05-18 omar.polo For multi-monitor support
31 c9a3bfaa 2018-05-21 omar.polo - Xft (optional)
32 c9a3bfaa 2018-05-21 omar.polo For TrueType (r) font support
33 be5b89f6 2018-05-18 omar.polo - pkg-config (optional)
34 be5b89f6 2018-05-18 omar.polo used in the makefile to generate `LIBS` and `CFLAGS` correctly
35 be5b89f6 2018-05-18 omar.polo
36 be5b89f6 2018-05-18 omar.polo ## Build
37 be5b89f6 2018-05-18 omar.polo
38 75faf30e 2018-05-22 omar.polo As simple as `make` (or `make gnu` if you're using GNU libc). Keep in
39 75faf30e 2018-05-22 omar.polo mind that, by default, both Xft and Xinerama are enabled. So, you may
40 75faf30e 2018-05-22 omar.polo want to run:
41 be5b89f6 2018-05-18 omar.polo
42 75faf30e 2018-05-22 omar.polo - `make no_xft` to build without xft support;
43 75faf30e 2018-05-22 omar.polo - `make no_xinerama` to build without xinerama support;
44 75faf30e 2018-05-22 omar.polo - `make no_xft_xinerama` to build without xinerama *and* no xft support.
45 75faf30e 2018-05-22 omar.polo
46 75faf30e 2018-05-22 omar.polo #### ignore case completion / don't have `strcasestr(3)`
47 75faf30e 2018-05-22 omar.polo
48 75faf30e 2018-05-22 omar.polo If you want to build without the ignore case completion or on your
49 75faf30e 2018-05-22 omar.polo platform `strcasestr(3)` isn't available, you have to update the
50 75faf30e 2018-05-22 omar.polo `Makefile` and remove `-DUSE_STRCASESTR`. A simple
51 75faf30e 2018-05-22 omar.polo ``` shell
52 75faf30e 2018-05-22 omar.polo sed -i.orig 's/-DUSE_STRCASESTR//g' Makefile
53 75faf30e 2018-05-22 omar.polo ```
54 75faf30e 2018-05-22 omar.polo should be enough.
55 75faf30e 2018-05-22 omar.polo
56 75faf30e 2018-05-22 omar.polo
57 9c241438 2018-05-20 omar.polo ## FAQ
58 9c241438 2018-05-20 omar.polo
59 9c241438 2018-05-20 omar.polo - Does not run / Hangs
60 9c241438 2018-05-20 omar.polo
61 9c241438 2018-05-20 omar.polo At the startup mymenu will read `stdin` for a list of item, only
62 9c241438 2018-05-20 omar.polo then it'll display a window. Are you sure that you're passing
63 9c241438 2018-05-20 omar.polo something on standard input?
64 9c241438 2018-05-20 omar.polo
65 9c241438 2018-05-20 omar.polo - License
66 9c241438 2018-05-20 omar.polo
67 9c241438 2018-05-20 omar.polo The code is released under GPLv3, but I don't have strong
68 9c241438 2018-05-20 omar.polo preference regard licenses, so if you ask I may release the code
69 9c241438 2018-05-20 omar.polo also under a different license (a free software one of course).
70 9c241438 2018-05-20 omar.polo
71 9c241438 2018-05-20 omar.polo - Will feature $X be added?
72 9c241438 2018-05-20 omar.polo
73 9c241438 2018-05-20 omar.polo No. Or maybe Yes. In fact, it depends. Open an issue and let's
74 9c241438 2018-05-20 omar.polo discuss. If it's something that's trivial to achieve in combo with
75 9c241438 2018-05-20 omar.polo other tool maybe is not the case to add it here.
76 9c241438 2018-05-20 omar.polo
77 9c241438 2018-05-20 omar.polo - Is feature $Y present? What $Z do? How to achieve $W?
78 9c241438 2018-05-20 omar.polo
79 9c241438 2018-05-20 omar.polo Everything is documented in the man page. To read it, simply execute
80 9c241438 2018-05-20 omar.polo `man -l mymenu.1` or `mandoc mymenu.1 | less` (depending on your
81 9c241438 2018-05-20 omar.polo system the `-l` option may not be present).
82 9c241438 2018-05-20 omar.polo
83 be5b89f6 2018-05-18 omar.polo ---
84 be5b89f6 2018-05-18 omar.polo
85 be5b89f6 2018-05-18 omar.polo ## TODO
86 be5b89f6 2018-05-18 omar.polo
87 75faf30e 2018-05-22 omar.polo - Improve UTF8 support
88 75faf30e 2018-05-22 omar.polo
89 75faf30e 2018-05-22 omar.polo The whole UTF8 support is still kinda naïve and should definitely
90 75faf30e 2018-05-22 omar.polo be improved.
91 75faf30e 2018-05-22 omar.polo
92 75faf30e 2018-05-22 omar.polo - Opacity support
93 75faf30e 2018-05-22 omar.polo
94 be5b89f6 2018-05-18 omar.polo - Command line flags
95 9c241438 2018-05-20 omar.polo
96 be5b89f6 2018-05-18 omar.polo At the moment the X Resource Database is the only way to interact
97 be5b89f6 2018-05-18 omar.polo with the graphic appearance of MyMenu.
98 be5b89f6 2018-05-18 omar.polo
99 b836b1ec 2018-05-18 omar.polo ## Scripts
100 b836b1ec 2018-05-18 omar.polo
101 8880d5e3 2018-05-19 omar.polo I'm using this script to launch MyMenu with custom item
102 b836b1ec 2018-05-18 omar.polo
103 b836b1ec 2018-05-18 omar.polo ``` shell
104 b836b1ec 2018-05-18 omar.polo #!/bin/sh
105 b836b1ec 2018-05-18 omar.polo
106 b836b1ec 2018-05-18 omar.polo cat <<EOF | /bin/sh -c "$(mymenu "$@")"
107 b836b1ec 2018-05-18 omar.polo sct 4500
108 b836b1ec 2018-05-18 omar.polo lock
109 b836b1ec 2018-05-18 omar.polo connect ethernet
110 b836b1ec 2018-05-18 omar.polo connect home
111 b836b1ec 2018-05-18 omar.polo connect phone
112 8880d5e3 2018-05-19 omar.polo ZZZ
113 b836b1ec 2018-05-18 omar.polo zzz
114 b836b1ec 2018-05-18 omar.polo ...
115 b836b1ec 2018-05-18 omar.polo EOF
116 b836b1ec 2018-05-18 omar.polo ```
117 b836b1ec 2018-05-18 omar.polo
118 8880d5e3 2018-05-19 omar.polo You can generate a menu from the `.desktop` file with something like
119 8880d5e3 2018-05-19 omar.polo this:
120 8880d5e3 2018-05-19 omar.polo
121 8880d5e3 2018-05-19 omar.polo ``` shell
122 8880d5e3 2018-05-19 omar.polo #!/bin/sh
123 8880d5e3 2018-05-19 omar.polo
124 8880d5e3 2018-05-19 omar.polo getname() {
125 8880d5e3 2018-05-19 omar.polo cat $1 | grep '^Name=' | sed 's/^.*=//'
126 8880d5e3 2018-05-19 omar.polo }
127 8880d5e3 2018-05-19 omar.polo
128 8880d5e3 2018-05-19 omar.polo getexec() {
129 8880d5e3 2018-05-19 omar.polo cat $1 | grep '^Exec=' | sed 's/^.*=//'
130 8880d5e3 2018-05-19 omar.polo }
131 8880d5e3 2018-05-19 omar.polo
132 8880d5e3 2018-05-19 omar.polo desktop_files=`ls /usr/local/share/applications/*.desktop`
133 8880d5e3 2018-05-19 omar.polo
134 8880d5e3 2018-05-19 omar.polo {
135 8880d5e3 2018-05-19 omar.polo for i in $desktop_files; do
136 8880d5e3 2018-05-19 omar.polo getname $i
137 8880d5e3 2018-05-19 omar.polo done
138 8880d5e3 2018-05-19 omar.polo } | mymenu "$@" | {
139 8880d5e3 2018-05-19 omar.polo read prgname
140 8880d5e3 2018-05-19 omar.polo for i in $desktop_files; do
141 8880d5e3 2018-05-19 omar.polo name=`getname $i`
142 8880d5e3 2018-05-19 omar.polo if [ "x$prgname" = "x$name" ]; then
143 8880d5e3 2018-05-19 omar.polo exec `getexec $i`
144 8880d5e3 2018-05-19 omar.polo fi
145 8880d5e3 2018-05-19 omar.polo done
146 8880d5e3 2018-05-19 omar.polo }
147 8880d5e3 2018-05-19 omar.polo ```
148 8880d5e3 2018-05-19 omar.polo
149 8880d5e3 2018-05-19 omar.polo or generate a list of executables from `$PATH` like this:
150 8880d5e3 2018-05-19 omar.polo
151 8880d5e3 2018-05-19 omar.polo ``` shell
152 8880d5e3 2018-05-19 omar.polo #!/bin/sh
153 8880d5e3 2018-05-19 omar.polo
154 8880d5e3 2018-05-19 omar.polo path=`echo $PATH | sed 's/:/ /g'`
155 8880d5e3 2018-05-19 omar.polo
156 8880d5e3 2018-05-19 omar.polo {
157 8880d5e3 2018-05-19 omar.polo for i in $path; do
158 8880d5e3 2018-05-19 omar.polo ls -F $i | grep '.*\*$' | sed 's/\*//'
159 8880d5e3 2018-05-19 omar.polo done
160 75faf30e 2018-05-22 omar.polo } | sort -f | /bin/sh -c "$(mymenu "$@")"
161 8880d5e3 2018-05-19 omar.polo ```
162 8880d5e3 2018-05-19 omar.polo
163 b836b1ec 2018-05-18 omar.polo Of course you can as well use the `dmenu_path` and `dmenu_run` scripts
164 b836b1ec 2018-05-18 omar.polo that (usually) comes with `dmenu`.