-
Notifications
You must be signed in to change notification settings - Fork 0
/
pywal.sh
executable file
·184 lines (164 loc) · 5.21 KB
/
pywal.sh
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#!/bin/bash
WAL_FILE="$HOME/.cache/wal/colors.sh"
KONSOLE_FILE="$HOME/.local/share/konsole/pywal.colorscheme"
KONSOLE_COLOR_SCHEME="$HOME/.cache/wal/colors-konsole.colorscheme"
PLASMA_FILE="pywal"
PLASMA_COLORS_DIR="$HOME/.local/share/color-schemes/"
PLASMA_SHELL_EXECUTABLE="plasmashell"
pywal_get() {
echo "[func: pywal_get] >> wal -i ${1}"
wal -i "$1" -e
return 1
}
copy_konsole_colorscheme() {
sed -i -e "s/Opacity=.*/Opacity=0.95/g" $KONSOLE_COLOR_SCHEME
cp -f $KONSOLE_COLOR_SCHEME $KONSOLE_FILE
}
merge_xresources_color() {
xrdb -merge $HOME/.cache/wal/colors.Xresources
}
get_xres_rgb() {
hex=$(xrdb -query | grep "$1" | awk '{print $2}' | cut -d# -f2)
printf "%d,%d,%d\n" "0x${hex:0:2}" "0x${hex:2:2}" "0x${hex:4:2}"
}
plasma_color_scheme() {
[[ -d "$PLASMA_COLORS_DIR" ]] || mkdir -pv "$PLASMA_COLORS_DIR"
output="$(
cat <<THEME
[ColorEffects:Disabled]
Color=$(get_xres_rgb color9:)
[ColorEffects:Inactive]
Color=$(get_xres_rgb color9:)
[Colors:Button]
BackgroundNormal=$(get_xres_rgb color8:)
ForegroundNormal=$(get_xres_rgb background:)
[Colors:Complementary]
[Colors:Selection]
BackgroundAlternate=
BackgroundNormal=$(get_xres_rgb color2:)
DecorationFocus=
DecorationHover=
ForegroundActive=
ForegroundInactive=
ForegroundLink=
ForegroundNegative=
ForegroundNeutral=
ForegroundNormal=$(get_xres_rgb foreground:)
ForegroundPositive=
ForegroundVisited=
[Colors:Tooltip]
BackgroundAlternate=
BackgroundNormal=$(get_xres_rgb color2:)
DecorationFocus=
DecorationHover=
ForegroundActive=
ForegroundInactive=
ForegroundLink=
ForegroundNegative=
ForegroundNeutral=
ForegroundNormal=$(get_xres_rgb foreground:)
ForegroundPositive=
ForegroundVisited=
[Colors:View]
# BackgroundAlternate=
BackgroundNormal=$(get_xres_rgb color0:)
# DecorationFocus=
# DecorationHover=
# ForegroundActive=
# ForegroundInactive=
# ForegroundLink=
# ForegroundNegative=
# ForegroundNeutral=
ForegroundNormal=$(get_xres_rgb foreground:)
# ForegroundPositive=
# ForegroundVisited=
[Colors:Window]
# BackgroundAlternate=
BackgroundNormal=$(get_xres_rgb color0:)
# DecorationFocus=
# DecorationHover=
# ForegroundActive=
# ForegroundInactive=
# ForegroundLink=
# ForegroundNegative=
# ForegroundNeutral=
ForegroundNormal=$(get_xres_rgb foreground:)
# ForegroundPositive=
# ForegroundVisited=
[General]
ColorScheme=${PLASMA_FILE}
Name=${PLASMA_FILE}
shadeSortColumn=true
[KDE]
contrast=0
[WM]
activeBackground=$(get_xres_rgb background:)
activeForeground=$(get_xres_rgb foreground:)
inactiveBackground=$(get_xres_rgb background:)
inactiveForeground=$(get_xres_rgb color15:)
THEME
)"
printf '%s' "$output" >"${PLASMA_COLORS_DIR}${PLASMA_FILE}.colors"
plasma-apply-colorscheme BreezeDark
sleep 0.2s
plasma-apply-colorscheme pywal
}
if [[ -x "$(which wal)" ]]; then
if [[ "$1" ]]; then
pywal_get "$1"
if [[ -e "$WAL_FILE" ]]; then
. "$WAL_FILE"
else
echo 'Color file does not exist, exiting...'
echo '1) Is ImageMagick installed?'
echo '2) Try to run wal --> f.e. wal -i ~/Pictures/<yourimage>.jpg'
echo 'should result in ~/.cache/wal dir being filled with files (also the color.sh file)'
exit 1
fi
BG=$(printf "%s\n" "$background")
FG=$(printf "%s\n" "$foreground")
AC1=$(printf "%s\n" "$color1")
AC2=$(printf "%s\n" "$color2")
AC3=$(printf "%s\n" "$color3")
AC4=$(printf "%s\n" "$color4")
AC5=$(printf "%s\n" "$color5")
AC6=$(printf "%s\n" "$color6")
AC7=$(printf "%s\n" "$color7")
AC8=$(printf "%s\n" "$color8")
AC9=$(printf "%s\n" "$color9")
AC10=$(printf "%s\n" "$color10")
AC11=$(printf "%s\n" "$color11")
AC12=$(printf "%s\n" "$color12")
AC13=$(printf "%s\n" "$color13")
AC14=$(printf "%s\n" "$color14")
AC15=$(printf "%s\n" "$color15")
AC66=$(printf "%s\n" "$color66")
merge_xresources_color
if [ -x "$(which ${PLASMA_SHELL_EXECUTABLE})" ]; then
plasma_color_scheme
copy_konsole_colorscheme
else
echo "ERROR plasmashell is NOT installed! Cannot set plasma's (kde) color scheme"
fi
sleep 0.1s
if [[ -x "$(which pywalfox)" ]]; then
pywalfox update
else
echo "[!] 'pywalfox' is not installed. https://github.com/Frewacom/pywalfox"
fi
if [[ -x "$(which zathura)" ]]; then
zathura_template="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/zathurarc.template"
mv "$HOME/.config/zathura/zathurarc" "$HOME/.config/zathura/zathurarc.bak"
cp $zathura_template "$HOME/.config/zathura/zathurarc"
sed -i 's/{background}/'"$background"'/g' "$HOME/.config/zathura/zathurarc"
sed -i 's/{foreground}/'"$foreground"'/g' "$HOME/.config/zathura/zathurarc"
sed -i 's/{color3}/'"$color3"'/g' "$HOME/.config/zathura/zathurarc"
sed -i 's/{color4}/'"$color4"'/g' "$HOME/.config/zathura/zathurarc"
fi
else
echo -e "[!] Please enter the path to wallpaper. \n"
echo "Usage : ./pywal.sh path/to/image"
fi
else
echo "[!] 'pywal' is not installed. https://github.com/the404devs/pywal-kde"
fi