This repository has been archived by the owner on Jul 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
i3menu
executable file
·77 lines (61 loc) · 1.97 KB
/
i3menu
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
: "${XDG_CONFIG_HOME:=$HOME/.config}"
: "${I3MENU_DIR:=$XDG_CONFIG_HOME/i3menu}"
main(){
_menu_command=(
rofi
${_o[options]:+${_o[options]}}
${_o[filter]:+-filter "${_o[filter]}"}
${_o[show]:+-show "${_o[show]}"}
${_o[modi]:+-modi "${_o[modi]}"}
${_o[prompt]:+-p "${_o[prompt]} "}
)
[[ ${_o[fallback]} ]] \
&& ERR "--fallback option is deprecated"$'\n' \
"its functionality has been removed from i3list"
[[ -n ${_o[modi]}${_o[show]} ]] || {
_menu_command+=(-dmenu)
# if we have stuff on stdin, put
# that in a tempfile that way we can do stuff ( wc in setincludes() )
# without worrying that we close and lose whats in stdin
_tmp_list_file=$(mktemp)
trap 'rm -f "$_tmp_list_file"' EXIT INT
if [[ -d ${_o[list-directory]} ]]; then
l=("${_o[list-directory]%/}/"*)
printf "%s\n" "${l[@]##*/}" > "$_tmp_list_file"
elif [[ ! -t 0 ]]; then
cp /dev/stdin "$_tmp_list_file"
# if STDIN was empty, delete tmp file
[[ $(< "$_tmp_list_file") ]] || rm "$_tmp_list_file"
else
rm "$_tmp_list_file"
fi
}
# default includes
: "${_o[include]:=pel}"
declare -A i3list
eval "$(eval i3list "${_o[target]}")"
[[ ${_o[layout]} =~ ^[ABCD]$ ]] \
&& _o[layout]=$(getvirtualpos "${_o[layout]}")
setgeometry "${_o[layout]:-default}"
setincludes
selected=$(
if [[ -f $_tmp_list_file && ${_o[top]} ]]; then
gawk -f <(topsort) "$_tmp_list_file"
elif [[ -f $_tmp_list_file ]]; then
cat "$_tmp_list_file"
else
: echo # use this if menu is dmenu (needs stdin)
fi | {
((_o[verbose])) && verbose_outro
((_o[dryrun])) || "${_menu_command[@]}" -theme <(themefile)
}
)
[[ $selected ]] && {
[[ -d ${_o[list-directory]} ]] \
&& echo -n "${_o[list-directory]%/}/"
echo "$selected"
}
}
__dir=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")") #bashbud
source "$__dir/_init.sh" #bashbud