Blame
Date:
Fri Oct 18 20:47:53 2019 UTC
Message:
improved command example

that grep | sed can be reduced to a single sed
001
2018-05-18
omar.pol
# MyMenu
002
2018-05-18
omar.pol
003
2018-07-01
omar.pol
> A menu for Xorg, 'cause I was bored
004
2018-05-18
omar.pol
005
2018-05-18
omar.pol
![MyMenu works!](screen.png)
006
2018-05-18
omar.pol
007
2018-05-19
omar.pol
![MyMenu alternate layout](screen-alt.png)
008
2018-05-19
omar.pol
009
2018-05-18
omar.pol
---
010
2018-05-18
omar.pol
011
2018-05-18
omar.pol
## What?
012
2018-05-18
omar.pol
013
2018-07-01
omar.pol
This is a simple menu for Xorg, like `dmenu(1)`.
014
2018-05-18
omar.pol
015
2018-05-18
omar.pol
## Why?
016
2018-05-18
omar.pol
017
2018-06-14
omar.pol
This was the perfect excuse to learn how to use Xlib.
018
2018-05-18
omar.pol
019
2018-05-18
omar.pol
## How?
020
2018-05-18
omar.pol
021
2018-06-14
omar.pol
Check out the [manpage](mymenu.1.md) for further documentation. Check
022
2018-06-14
omar.pol
out also the [template](Xexample) for the resources.
023
2018-05-18
omar.pol
024
2018-05-18
omar.pol
---
025
2018-05-18
omar.pol
026
2018-09-19
omar.pol
## Features
027
2018-09-19
omar.pol
028
2018-09-19
omar.pol
- two layout: `horizontal` (a là dmenu) and `vertical` (a là rofi);
029
2018-09-19
omar.pol
- highly customizable (width, height, position on the screen, colors, borders, ...);
030
2018-09-19
omar.pol
- transparency support
031
2018-09-19
omar.pol
- support for both Xft and bitmap font
032
2018-09-19
omar.pol
033
2018-05-18
omar.pol
## Dependencies
034
2018-05-18
omar.pol
035
2018-05-18
omar.pol
- Xlib
036
2018-07-01
omar.pol
- Xinerama *(optional)* for multi-monitor support
037
2018-07-01
omar.pol
- Xft *(optional)* for TrueType font support
038
2018-07-01
omar.pol
- pkg-config *(optional)* to generate `LIBS` and `CFLAGS`
039
2018-07-01
omar.pol
- mandoc *(optional)* to generate the
040
2018-07-01
omar.pol
[markdown version of the manpage](mymenu.1.md)
041
2018-05-18
omar.pol
042
2018-05-18
omar.pol
## Build
043
2018-05-18
omar.pol
044
2018-05-22
omar.pol
As simple as `make` (or `make gnu` if you're using GNU libc). Keep in
045
2018-05-22
omar.pol
mind that, by default, both Xft and Xinerama are enabled. So, you may
046
2018-05-22
omar.pol
want to run:
047
2018-05-18
omar.pol
048
2018-05-22
omar.pol
- `make no_xft` to build without xft support;
049
2018-05-22
omar.pol
- `make no_xinerama` to build without xinerama support;
050
2018-05-22
omar.pol
- `make no_xft_xinerama` to build without xinerama *and* no xft support.
051
2018-05-22
omar.pol
052
2018-07-01
omar.pol
Or you can update the first lines of the `Makefile` customizing
053
2018-07-01
omar.pol
`OPTIONAL` and `CDEFS` to your needs.
054
2018-07-01
omar.pol
055
2018-05-22
omar.pol
#### ignore case completion / don't have `strcasestr(3)`
056
2018-05-22
omar.pol
057
2018-05-22
omar.pol
If you want to build without the ignore case completion or on your
058
2018-05-22
omar.pol
platform `strcasestr(3)` isn't available, you have to update the
059
2018-05-22
omar.pol
`Makefile` and remove `-DUSE_STRCASESTR`. A simple
060
2018-05-22
omar.pol
``` shell
061
2018-05-22
omar.pol
sed -i.orig 's/-DUSE_STRCASESTR//g' Makefile
062
2018-05-22
omar.pol
```
063
2018-05-22
omar.pol
should be enough.
064
2018-05-22
omar.pol
065
2018-05-22
omar.pol
066
2018-05-20
omar.pol
## FAQ
067
2018-05-20
omar.pol
068
2018-05-20
omar.pol
- Does not run / Hangs
069
2018-05-20
omar.pol
070
2018-05-20
omar.pol
At the startup mymenu will read `stdin` for a list of item, only
071
2018-05-20
omar.pol
then it'll display a window. Are you sure that you're passing
072
2018-05-20
omar.pol
something on standard input?
073
2018-05-20
omar.pol
074
2018-05-20
omar.pol
- Will feature $X be added?
075
2018-05-20
omar.pol
076
2018-06-14
omar.pol
No. Or maybe yes. In fact, it depends. Open an issue and let's
077
2018-05-20
omar.pol
discuss. If it's something that's trivial to achieve in combo with
078
2018-05-20
omar.pol
other tool maybe is not the case to add it here.
079
2018-05-20
omar.pol
080
2018-05-20
omar.pol
- Is feature $Y present? What $Z do? How to achieve $W?
081
2018-05-20
omar.pol
082
2018-06-14
omar.pol
Everything is documented in the [man page](mymenu.1.md). To read
083
2018-06-14
omar.pol
it, simply execute `man -l mymenu.1` or `mandoc mymenu.1 | less`
084
2018-06-14
omar.pol
(depending on your system the `-l` option may not be present).
085
2018-05-20
omar.pol
086
2018-05-18
omar.pol
---
087
2018-05-18
omar.pol
088
2018-05-18
omar.pol
## Scripts
089
2018-05-18
omar.pol
090
2018-05-19
omar.pol
I'm using this script to launch MyMenu with custom item
091
2018-05-18
omar.pol
092
2018-05-18
omar.pol
``` shell
093
2018-05-18
omar.pol
#!/bin/sh
094
2018-05-18
omar.pol
095
2018-05-18
omar.pol
cat <<EOF | /bin/sh -c "$(mymenu "$@")"
096
2018-05-18
omar.pol
sct 4500
097
2018-05-18
omar.pol
lock
098
2018-05-18
omar.pol
connect ethernet
099
2018-05-18
omar.pol
connect home
100
2018-05-18
omar.pol
connect phone
101
2018-05-19
omar.pol
ZZZ
102
2018-05-18
omar.pol
zzz
103
2018-05-18
omar.pol
...
104
2018-05-18
omar.pol
EOF
105
2018-05-18
omar.pol
```
106
2018-05-18
omar.pol
107
2018-09-19
omar.pol
You can generate a list of executables from `$PATH` like this:
108
2018-05-19
omar.pol
109
2018-05-19
omar.pol
``` shell
110
2018-05-19
omar.pol
#!/bin/sh
111
2018-05-19
omar.pol
112
2018-05-19
omar.pol
path=`echo $PATH | sed 's/:/ /g'`
113
2018-05-19
omar.pol
114
2018-05-19
omar.pol
{
115
2018-05-19
omar.pol
for i in $path; do
116
2019-10-18
omar.pol
ls -F $i | sed -n 's/\*$//p'
117
2018-05-19
omar.pol
done
118
2018-05-22
omar.pol
} | sort -f | /bin/sh -c "$(mymenu "$@")"
119
2018-05-19
omar.pol
```
120
2018-05-19
omar.pol
121
2018-09-19
omar.pol
You can, for example, select a song to play from the current queue (in mpd), with
122
2018-09-19
omar.pol
123
2018-09-19
omar.pol
```shell
124
2018-09-19
omar.pol
fmt="%position% %artist% - %title%"
125
2018-09-19
omar.pol
if song=$(mpc playlist -f "$fmt" | mymenu -p "Song: " -A -d " "); then
126
2018-09-19
omar.pol
mpc play $(echo $song | sed "s/ .*$//")
127
2018-09-19
omar.pol
fi
128
2018-09-19
omar.pol
```
129
2018-09-19
omar.pol
130
2018-05-18
omar.pol
Of course you can as well use the `dmenu_path` and `dmenu_run` scripts
131
2018-05-18
omar.pol
that (usually) comes with `dmenu`.
Omar Polo