-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrofi-iro
executable file
Β·114 lines (97 loc) Β· 2.85 KB
/
rofi-iro
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env bash
# keybindings
texted_mode="Alt+t"
copy_mode="Alt+c"
clean_mode="Alt+n"
provide_mode="Alt+p"
clear_palettes="Alt+C"
clean_dir="Alt+N"
highlightcolor='Aqua'
# load configs
. "$HOME/.config/rofi/script-configs/rofi-iro.conf"
opts=""
_rofi() {
rofi -sep '|' -columns 8 -lines 1 -disable-history true -cycle true \
-theme rofi-smallmenu.rasi -location 5 -width 400 -height 20 \
-dmenu -font "Hack Nerd Font 10" "$@"
}
activateTextedMode() {
opts=""
}
activateCopyMode() {
opts="-c"
}
activateCleanMode() {
opts="-n"
}
activateProvideMode() {
opts="-p"
}
printKey() {
echo "<span color='${highlightcolor}'>($1)</span>"
}
getOptionMessage() {
local mesg=""
case "${opts}" in
"") mesg="ο½ texted mode" ;;
"-c") mesg="ο
copy mode" ;;
"-n") mesg="ο clean mode" ;;
"-p") mesg="ο provide mode" ;;
esac
echo $mesg
}
π¬() {
local mesg=""
case "${opts}" in
"") mesg="ο
$(printKey ${copy_mode}) | ο $(printKey ${clean_mode}) | ο $(printKey ${provide_mode})" ;;
"-c") mesg="ο½ $(printKey ${texted_mode}) | ο $(printKey ${clean_mode}) | ο $(printKey ${provide_mode})" ;;
"-n") mesg="ο½ $(printKey ${texted_mode}) | ο
$(printKey ${copy_mode}) | ο $(printKey ${provide_mode})" ;;
"-p") mesg="ο½ $(printKey ${texted_mode}) | ο
$(printKey ${copy_mode}) | ο $(printKey ${clean_mode})" ;;
esac
echo $mesg
}
main() {
choices="hex|rgb"
mesg="π¨ <b>iro</b> - $(getOptionMessage)
$(π¬)
$(printKey ${clear_palettes}) to clear palettes
$(printKey ${clean_dir}) to clean cache"
choice=$(echo -n "${choices}" | _rofi \
-mesg "${mesg}" \
-kb-custom-1 "${texted_mode}" -kb-custom-2 "${copy_mode}" -kb-custom-3 "${clean_mode}" \
-kb-custom-4 "${provide_mode}" -kb-custom-5 "${clear_palettes}" -kb-custom-6 "${clean_dir}")
retval=$?
case "${retval}" in
1) exit 0 ;;
10) activateTextedMode && main ;;
11) activateCopyMode && main ;;
12) activateCleanMode && main ;;
13) activateProvideMode && main ;;
14) iro clear ;;
15) iro clean ;;
0)
if [ ${opts} = "-p" ]; then
color=$(rofi -dmenu -i -p "Please provide ${choice} color")
retvall=$?
case "${retval}" in
0) iro ${opts} ${choice} ${color} ;;
esac
else
iro ${opts} ${choice}
fi
;;
esac
}
main
# choice=$(echo -en "hex ο½|rgb ο½|hex ο
|rgb ο
|hex ο|rgb ο|hex ο only|rgb ο only|clear|clean" | _rofi)
# retval=$?
# if [ $retval != "1" ]; then
# case "$choice" in
# "clear" | "clean") iro "$choice" ;;
# "hex ο½" | "rgb ο½") iro "$(echo $choice | cut -d' ' -f1)" ;;
# "hex ο
" | "rgb ο
") iro -c "$(echo $choice | cut -d' ' -f1)" ;;
# "hex ο" | "rgb ο") iro -n "$(echo $choice | cut -d' ' -f1)" ;;
# "hex ο only") provideColor "hex" ;;
# "rgb ο only") provideColor "rgb" ;;
# esac
# fi