-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrofiwpg
executable file
·101 lines (85 loc) · 2.04 KB
/
rofiwpg
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
#!/usr/bin/env bash
wpgc=$(which wpg)
editor=$(which nvim-qt)
fm=$(which thunar)
if [ -z $wpgc ]; then
echo "wpg not found in path. Make sure that wpgtk is installed wpg is in your path."
exit 1
fi
wpgcfgpath="$HOME/.config/wpg"
wpgprompt=" wpgtk"
template="Alt+t"
schemes="Alt+s"
config="Alt+c"
delete="Alt+d"
openinfm="Alt+t"
highlightcolor="Aqua"
# Configuration
. "$HOME/.config/rofi/script-configs/rofiwpg.conf"
printKey() {
echo -n "<b><span color='${highlightcolor}'>($1)</span></b>"
}
_rofi() {
rofi -dmenu -markup-rows -i -p "${wpgprompt}" "$@"
}
helpmsg="Actions:
$(printKey ${template}) edit templates | $(printKey ${schemes}) edit schemes
$(printKey ${config}) edit config | $(printKey ${delete}) delete theme"
edittemplate() {
choice=$(${wpgc} -lt | _rofi -kb-custom-1 "${openinfm}" \
-mesg "$(printKey ${openinfm}) open templates in file manager")
retval=$?
case "$retval" in
10)
${fm} ${wpgcfgpath}/templates/
;;
1) exit 0 ;;
0)
${editor} ${wpgcfgpath}/templates/${choice}
;;
esac
}
editschemes() {
choice=$(ls ${wpgcfgpath}/schemes | _rofi)
retval=$?
case "$retval" in
1) exit 0 ;;
0)
${editor} ${wpgcfgpath}/schemes/${choice}
;;
esac
}
deletetheme() {
choice=$(${wpgc} -l | _rofi -mesg "Which theme to delete?")
retval=$?
case "$retval" in
1) exit 0 ;;
0)
confirm=$(echo "No|Yes" | _rofi -sep '|' -mesg "Really delete ${choice}?")
retval=$?
case "$retval" in
1) exit 0 ;;
0)
if [ "$confirm" = "Yes" ]; then
${wpgc} -d ${choice}
rofi -e "${choice} theme deleted"
fi
;;
esac
esac
}
main() {
choice=$(${wpgc} -l | _rofi -mesg "${helpmsg}" \
-kb-custom-1 "${template}" -kb-custom-2 "${schemes}" \
-kb-custom-3 "${config}" -kb-custom-4 "${delete}")
retval=$?
case "$retval" in
10) edittemplate ;;
11) editschemes ;;
12) ${editor} ${wpgcfgpath}/wpg.conf ;;
13) deletetheme ;;
1) exit 0 ;;
0) ${wpgc} -s ${choice}
esac
}
main