-
Notifications
You must be signed in to change notification settings - Fork 6
/
MoreWaita.sh
executable file
·149 lines (129 loc) · 4.45 KB
/
MoreWaita.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
#!/bin/bash
# Function to check if directory exists
check_dir() {
if [ -d "$1" ]; then
echo "$1"
return 0
fi
return 1
}
# Detect MoreWaita and Adwaita-colors locations
possible_paths=(
"/usr/share/icons"
"/usr/local/share/icons"
"/var/usrlocal/share/icons"
"$HOME/.local/share/icons"
"$HOME/.icons"
)
# Initialize variables
MOREWAITADIR=""
ADWAITACOLORSDIR=""
# Find MoreWaita directory
for path in "${possible_paths[@]}"; do
if [ -d "$path/MoreWaita" ]; then
MOREWAITADIR="$path/MoreWaita"
break
fi
done
# Find Adwaita-colors directory (looking for any of the color variants)
for path in "${possible_paths[@]}"; do
if [ -d "$path/Adwaita-brown" ] || [ -d "$path/Adwaita-pink" ] || [ -d "$path/Adwaita-slate" ]; then
ADWAITACOLORSDIR="$path"
break
fi
done
if [ -z "$MOREWAITADIR" ]; then
echo "Error: MoreWaita icon theme not found"
exit 1
fi
if [ -z "$ADWAITACOLORSDIR" ]; then
echo "Error: Adwaita-colors icon themes not found"
exit 1
fi
# Find actually existing Adwaita variants in the directory
echo "Detecting installed Adwaita variants..."
adwaita_variants=()
for variant in "$ADWAITACOLORSDIR"/Adwaita-*; do
if [ -d "$variant" ]; then
variant_name=$(basename "$variant")
adwaita_variants+=("$variant_name")
echo "Found: $variant_name"
# Edit index.theme file
theme_file="$variant/index.theme"
if [ -f "$theme_file" ]; then
echo "Updating theme inheritance in $theme_file"
# Make backup of original file
cp "$theme_file" "$theme_file.bak"
# Use sed to modify the file in place
if grep -q "^Inherits=" "$theme_file"; then
# If Inherits line exists, replace it
sed -i 's/^Inherits=.*/Inherits=MoreWaita,Adwaita,AdwaitaLegacy,hicolor/' "$theme_file"
else
# If Inherits line doesn't exist, add it after [Icon Theme]
sed -i '/\[Icon Theme\]/a Inherits=MoreWaita,Adwaita' "$theme_file"
fi
echo "Updated $theme_file"
else
echo "Warning: index.theme not found in $variant"
fi
fi
done
if [ ${#adwaita_variants[@]} -eq 0 ]; then
echo "Error: No Adwaita color variants found in $ADWAITACOLORSDIR"
exit 1
fi
# Process each detected Adwaita color variant
for variant in "${adwaita_variants[@]}"; do
variant_path="$ADWAITACOLORSDIR/$variant"
echo "Processing $variant..."
# Create mimes directory if it doesn't exist
mkdir -p "$variant_path/scalable/mimes"
# Move specified files from mimetypes to mimes
specified_files=(
"application-certificate.svg"
"application-x-addon.svg"
"application-x-executable.svg"
"application-x-firmware.svg"
"application-x-generic.svg"
"application-x-sharedlib.svg"
"audio-x-generic.svg"
"inode-symlink.svg"
"package-x-generic.svg"
"text-x-generic.svg"
"text-x-preview.svg"
"video-x-generic.svg"
"x-office-addressbook.svg"
"x-office-document-template.svg"
"x-office-drawing.svg"
"x-office-presentation-template.svg"
"x-office-spreadsheet.svg"
"x-office-spreadsheet-template.svg"
"x-package-repository.svg"
)
for file in "${specified_files[@]}"; do
if [ -f "$variant_path/scalable/mimetypes/$file" ]; then
mv "$variant_path/scalable/mimetypes/$file" "$variant_path/scalable/mimes/"
echo "Moved $file to mimes directory"
fi
done
# Copy files from MoreWaita mimes to mimetypes, skipping existing files
if [ -d "$MOREWAITADIR/scalable/mimetypes" ]; then
for file in "$MOREWAITADIR/scalable/mimetypes"/*; do
filename=$(basename "$file")
if [ ! -f "$variant_path/scalable/mimetypes/$filename" ]; then
cp "$file" "$variant_path/scalable/mimetypes/"
echo "Copied $filename from MoreWaita to mimetypes"
fi
done
fi
done
# Update icon cache for each variant and MoreWaita
echo "Updating icon caches..."
for variant in "${adwaita_variants[@]}"; do
variant_path="$ADWAITACOLORSDIR/$variant"
echo "Updating icon cache for $variant"
gtk-update-icon-cache -f "$variant_path"
done
echo "Updating MoreWaita icon cache"
gtk-update-icon-cache -f "$MOREWAITADIR"
echo "Processing completed!"