alpha
Login
or
Join now
yemou.pink
/
scripts
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
This repository has no description
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
Pipelines
avoid using rm and small fixes
author
yemou
date
5 years ago
(Oct 12, 2020, 3:45 AM UTC)
commit
33d6bbe9
33d6bbe9a6d8452a0e4a521783c62ce15fa91c03
parent
8a580e2a
8a580e2a5142aba026bad2917d329fa9d8685bfb
+7
-8
1 changed file
Expand all
Collapse all
Unified
Split
thm
+7
-8
thm
Reviewed
···
10
10
hex2rgb() {
11
11
hex=$1
12
12
hex_r=${hex%????}
13
13
-
hex_g=${hex#??}
14
14
-
hex_g=${hex_g%??}
13
13
+
hex_g=${hex#??}; hex_g=${hex_g%??}
15
14
hex_b=${hex#????}
16
15
printf '%d,%d,%d' "0x$hex_r" "0x$hex_g" "0x$hex_b"
17
16
}
···
21
20
&& conf_dir="$THM_CONFIG_DIR" \
22
21
|| conf_dir="${XDG_CONFIG_HOME:-$HOME/.config}/thm"
23
22
[ "$THM_DEST_DIR" ] \
24
24
-
&& conf_dir="$THM_DEST_DIR" \
23
23
+
&& dest_dir="$THM_DEST_DIR" \
25
24
|| dest_dir="${XDG_CACHE_HOME:-$HOME/.cache}/thm"
26
25
27
26
err() {
···
59
58
color14_rgb="$(hex2rgb "$color14")"
60
59
color15_rgb="$(hex2rgb "$color15")"
61
60
62
62
-
# Make sure the dest_dir exist
63
63
-
[ -d "$dest_dir" ] || { mkdir -p "$dest_dir" || err "failed to create $dest_dir"; }
61
61
+
# Make sure the dest_dir and dest_dir/thm_old exist
62
62
+
[ -d "$dest_dir/thm_old" ] || { mkdir -p "$dest_dir/thm_old" || err "failed to create $dest_dir/thm_old"; }
64
63
65
65
-
# Ensure the dest_dir is empty before populating it
66
66
-
rm "$dest_dir/"*
64
64
+
# Try and empty the dest_dir before populating it
65
65
+
mv "$dest_dir/"* "$dest_dir/thm_old" 2> /dev/null
67
66
68
67
# Make a file with the name of the new theme
69
68
printf '%s\n' "$theme_file" > "$dest_dir/current_thm"
···
115
114
done
116
115
117
116
# Run extra user scripts
118
118
-
[ -d "$conf_dir/scripts" ] || return 0
117
117
+
[ -d "$conf_dir/scripts" ] || exit 0
119
118
for i in "$conf_dir/scripts/"*
120
119
do
121
120
[ -x "$i" ] && $i > /dev/null 2>&1 &