-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrandom.sh
executable file
·211 lines (188 loc) · 5.97 KB
/
random.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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#!/usr/bin/env bash
## Copyright (C) 2020-2023 Aditya Shakya <[email protected]>
##
## Apply Random Theme With Pywal
## Theme ------------------------------------
TDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
THEME="${TDIR##*/}"
# Set you wallpaper directory here.
WALLDIR="`xdg-user-dir PICTURES`/wallpapers"
WALFILE="$HOME/.cache/wal/colors.sh"
## Directories ------------------------------
PATH_CONF="$HOME/.config"
PATH_I3WM="$PATH_CONF/i3"
PATH_TERM="$PATH_I3WM/alacritty"
PATH_PBAR="$PATH_I3WM/themes/$THEME/polybar"
PATH_ROFI="$PATH_I3WM/themes/$THEME/rofi"
## Pywal ------------------------------------
check_wallpaper() {
if [[ -d "$WALLDIR" ]]; then
WFILES="`ls --format=single-column $WALLDIR | wc -l`"
if [[ "$WFILES" == 0 ]]; then
dunstify -u normal -h string:x-dunst-stack-tag:noimage -i /usr/share/archcraft/icons/dunst/picture.png "There are no wallpapers in : $WALLDIR"
exit
fi
else
mkdir -p "$WALLDIR"
dunstify -u normal -h string:x-dunst-stack-tag:noimage -i /usr/share/archcraft/icons/dunst/picture.png "Put some wallpapers in : $WALLDIR"
exit
fi
}
generate_colors() {
check_wallpaper
if [[ `which wal` ]]; then
dunstify -t 50000 -h string:x-dunst-stack-tag:runpywal -i /usr/share/archcraft/icons/dunst/hourglass.png "Generating Colorscheme. Please wait..."
wal -q -n -s -t -e -i "$WALLDIR"
if [[ "$?" != 0 ]]; then
dunstify -u normal -h string:x-dunst-stack-tag:runpywal -i /usr/share/archcraft/icons/dunst/palette.png "Failed to generate colorscheme."
exit
fi
else
dunstify -u normal -h string:x-dunst-stack-tag:runpywal -i /usr/share/archcraft/icons/dunst/palette.png "'pywal' is not installed."
exit
fi
}
generate_colors
source "$WALFILE"
altbackground="`pastel color $background | pastel lighten 0.05 | pastel format hex`"
altforeground="`pastel color $foreground | pastel darken 0.30 | pastel format hex`"
backgroundtrans="#aa${background#'#'}"
accent="$color4"
## Wallpaper ---------------------------------
apply_wallpaper() {
sed -i -e "s#WALLPAPER=.*#WALLPAPER='$wallpaper'#g" ${PATH_I3WM}/themes/wallpaper.sh
}
## Polybar -----------------------------------
apply_polybar() {
# rewrite colors file
cat > ${PATH_PBAR}/colors.ini <<- EOF
[color]
BACKGROUND = ${backgroundtrans}
FOREGROUND = ${foreground}
ALTBACKGROUND = ${altbackground}
ALTFOREGROUND = ${altforeground}
ACCENT = ${accent}
BLACK = ${color0}
RED = ${color1}
GREEN = ${color2}
YELLOW = ${color3}
BLUE = ${color4}
MAGENTA = ${color5}
CYAN = ${color6}
WHITE = ${color7}
ALTBLACK = ${color8}
ALTRED = ${color9}
ALTGREEN = ${color10}
ALTYELLOW = ${color11}
ALTBLUE = ${color12}
ALTMAGENTA = ${color13}
ALTCYAN = ${color14}
ALTWHITE = ${color15}
EOF
}
# Rofi --------------------------------------
apply_rofi() {
# rewrite colors file
cat > ${PATH_ROFI}/shared/colors.rasi <<- EOF
* {
background: #aa000000;
background-alt: #aa000000;
foreground: ${foreground};
selected: ${accent};
active: ${color2};
urgent: ${color1};
}
EOF
}
# Terminal ----------------------------------
apply_terminal() {
# alacritty : colors
cat > ${PATH_TERM}/colors.yml <<- _EOF_
## Colors configuration
colors:
# Default colors
primary:
background: '${background}'
foreground: '${foreground}'
# Normal colors
normal:
black: '${color0}'
red: '${color1}'
green: '${color2}'
yellow: '${color3}'
blue: '${color4}'
magenta: '${color5}'
cyan: '${color6}'
white: '${color7}'
# Bright colors
bright:
black: '${color8}'
red: '${color9}'
green: '${color10}'
yellow: '${color11}'
blue: '${color12}'
magenta: '${color13}'
cyan: '${color14}'
white: '${color15}'
_EOF_
}
# Dunst -------------------------------------
apply_dunst() {
# modify colors
sed -i '/urgency_low/Q' ${PATH_I3WM}/dunstrc
cat >> ${PATH_I3WM}/dunstrc <<- _EOF_
[urgency_low]
timeout = 2
background = "${background}"
foreground = "${foreground}"
frame_color = "${altbackground}"
[urgency_normal]
timeout = 5
background = "${background}"
foreground = "${foreground}"
frame_color = "${altbackground}"
[urgency_critical]
timeout = 0
background = "${background}"
foreground = "${color1}"
frame_color = "${color1}"
_EOF_
}
# I3WM -------------------------------------
apply_i3wm() {
# modify i3theme file
sed -i ${PATH_I3WM}/config.d/01_theme.conf \
-e "s/set \$i3_cl_col_bg.*/set \$i3_cl_col_bg $background/g" \
-e "s/set \$i3_cl_col_fg.*/set \$i3_cl_col_fg $foreground/g" \
-e "s/set \$i3_cl_col_in.*/set \$i3_cl_col_in $color2/g" \
-e "s/set \$i3_cl_col_afoc.*/set \$i3_cl_col_afoc $accent/g" \
-e "s/set \$i3_cl_col_ifoc.*/set \$i3_cl_col_ifoc $color4/g" \
-e "s/set \$i3_cl_col_ufoc.*/set \$i3_cl_col_ufoc $altbackground/g" \
-e "s/set \$i3_cl_col_urgt.*/set \$i3_cl_col_urgt $color5/g" \
-e "s/set \$i3_cl_col_phol.*/set \$i3_cl_col_phol $background/g"
# modify i3bar file
sed -i ${PATH_I3WM}/i3status/statusbar.conf \
-e "s/set \$i3_bar_bg.*/set \$i3_bar_bg $background/g" \
-e "s/set \$i3_bar_fg.*/set \$i3_bar_fg $foreground/g" \
-e "s/set \$i3_bar_sep.*/set \$i3_bar_sep $altbackground/g" \
-e "s/set \$i3_bar_foc.*/set \$i3_bar_foc $accent/g" \
-e "s/set \$i3_bar_act.*/set \$i3_bar_act $color4/g" \
-e "s/set \$i3_bar_ina.*/set \$i3_bar_ina $altbackground/g" \
-e "s/set \$i3_bar_urg.*/set \$i3_bar_urg $color5/g" \
-e "s/set \$i3_bar_mod.*/set \$i3_bar_mod $color2/g"
# modify i3status file
sed -i ${PATH_I3WM}/i3status/config \
-e "s/color_good =.*/color_good = \"$color2\"/g" \
-e "s/color_degraded =.*/color_degraded = \"$color3\"/g" \
-e "s/color_bad =.*/color_bad = \"$color1\"/g" \
-e "s/color_separator =.*/color_separator = \"$altbackground\"/g"
# restart i3wm
i3-msg restart
}
## Execute Script ---------------------------
apply_wallpaper
apply_polybar
apply_rofi
apply_terminal
apply_dunst
apply_i3wm