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