summaryrefslogtreecommitdiff
path: root/bin/menuscripts/mhelp
blob: 5963a8822963ce4e5ec77e731a0a10210559e943 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env sh

if [ "$MENUCMD" = "tofi" ]
then
	program="$(tofi-run --prompt-text "program: ")"
	menucmd="tofi --width 50% --height 30% --matching-algorithm normal --prompt-text $program:"
elif [ "$MENUCMD" = "dmenu" ]
then
	program="$(dmenu_path | dmenu -l 4 -g 5 -p "program:")" 
	menucmd="dmenu -l 20 -g 1 -x -i -p $program:" 
else
	program="$(dmenu_path | fzf)"
	menucmd="fzf"
fi

test -z "$program" && exit 1

option="$($program --help |
	# Parse options
	grep "^ *-[-a-zA-Z0-9]* " |
	tr -s ' ' |
	sort | uniq |
	column -l 2 -t |
	$menucmd |
	awk '{print $1}')"

test -z "$option" && exit 1

setsid $program $option