-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautotheme.bash
executable file
·90 lines (78 loc) · 2.29 KB
/
autotheme.bash
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
#!/bin/bash
while [[ $# -gt 0 ]]; do
case $1 in
--light)
theme="light"
shift
;;
--dark)
theme="dark"
shift
;;
--config-file)
config_file="$2"
shift 2
;;
*)
wallpaper=$1
shift
;;
esac
done
if [ -z "$config_file" ]; then
config_file="wallust.toml"
fi
if [ -z "$wallpaper" ]; then
if command -v gsettings &> /dev/null; then
wallpaper=$(gsettings get org.gnome.desktop.background picture-uri | sed -e "s/^'//" -e "s/'$//")
else
echo "Error: gsettings command not found and no wallpaper URI provided."
exit 1
fi
fi
if [ -z "$theme" ]; then
if command -v gsettings &> /dev/null; then
theme=$(gsettings get org.gnome.desktop.interface color-scheme | grep -i prefer-dark > /dev/null && echo "dark" || echo "light")
echo "setting theme to $theme"
else
echo "Error: gsettings command not found and no theme specified."
exit 1
fi
fi
convert_uri_to_path() {
local uri=$1
python3 -c "import sys, urllib.parse; print(urllib.parse.unquote(sys.argv[1]).replace('file://', '').strip('\''))" "$uri"
}
file_path=$(convert_uri_to_path "$wallpaper")
if [[ "$file_path" == *.jxl ]]; then
png_path="/tmp/$(basename "$file_path" .jxl).png"
if [[ -z $png_path ]]; then
echo "Converting JXL background to PNG..."
magick "$file_path" "$png_path"
else
echo "JXL already converted to PNG at $png_path"
fi
file_path="$png_path"
elif [[ "$file_path" == *.svg ]]; then
png_path="/tmp/$(basename "$file_path" .svg).png"
if [[ -z $png_path ]]; then
echo "Converting SVG background to PNG..."
magick "$file_path" "$png_path"
else
echo "SVG already converted to PNG at $png_path"
fi
file_path="$png_path"
fi
if [[ "$theme" == "dark" ]]; then
palette="dark"
#config_file="wallust.toml"
color_space="lab"
backend="full"
else
backend="full"
palette="light"
color_space="lch"
#config_file="wallust-light.toml"
fi
~/.cargo/bin/wallust run $file_path --backend $backend --palette $palette --colorspace $color_space --config-dir ~/.config/autotheme
echo "theme changed"