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