-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpicker.spell
executable file
·83 lines (76 loc) · 2.23 KB
/
picker.spell
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
78
79
80
81
82
83
#!/bin/bash
set -x
use_tofi() {
args=()
[ "$prompt" ] && args+=(--prompt "$prompt ")
[ "$bg_color" ] && args+=(--background-color "${bg_color}DD")
[ "$text_color" ] && args+=(--text-color "$text_color")
[ "$selection_bg_color" ] && args+=(
--border-color "$selection_bg_color"
--selection-background "$selection_bg_color"
)
[ "$selection_text_color" ] && args+=(--selection-color "$selection_text_color")
[ "$lines" ] && args+=(--num-results "$lines")
[ "$require_match" ] && args+=(--require-match "$require_match")
tofi "${args[@]}"
}
use_dmenu() {
args=()
[ "$prompt" ] && args+=(-p "$prompt")
[ "$bg_color" ] && args+=(-nb "$bg_color")
[ "$text_color" ] && args+=(-nf "$text_color")
[ "$selection_bg_color" ] && args+=(-sb "$selection_bg_color")
[ "$selection_text_color" ] && args+=(-sf "$selection_text_color")
[ "$case_insensitive" ] && args+=(-i)
[ "$lines" ] && args+=(-l "$lines")
[ "$font" ] && args+=(-fn "$font")
dmenu "${args[@]}"
}
use_fzf() {
args+=()
[ "$prompt" ] && args+=(--prompt "$prompt")
[ "$require_match" = true ] && args+=(--print-query)
fzf "${args[@]}"
}
mapfile -t wall_colors < <(tr ' ' '\n' < "/tmp/$LOGNAME/wall_colors")
selection_bg_color=${wall_colors[0]}
selection_text_color=${wall_colors[1]}
bg_color="${wall_colors[4]}"
text_color=${wall_colors[5]}
while [[ "$#" -gt 0 ]]; do
case "$1" in
-i)
case_insensitive=1
shift
continue
;;
-fn) font="$2" ;;
-l) lines=$2 ;;
--print-query)
require_match=true
shift
continue
;;
--require-match) require_match=$2 ;;
-p|--prompt) prompt=$2 ;;
-nb|--background-color) bg_color=$2 ;;
-nf|--text-color) text_color=$2 ;;
-sb|--border-color|--selection-background) selection_bg_color=$2 ;;
-sf|--selection-color) selection_text_color=$2 ;;
*)
echo "unrecognized option $1"
exit 1
esac
shift
shift
done
if [ -t 0 ]; then
use_fzf
elif [ "$WAYLAND_DISPLAY" ]; then
if [[ "$0" = *dmenu* ]]; then
require_match=false
fi
use_tofi
else
use_dmenu
fi