-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcastlim
More file actions
184 lines (162 loc) · 8.43 KB
/
Copy pathcastlim
File metadata and controls
184 lines (162 loc) · 8.43 KB
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
#!/usr/bin/env bash
#load the hex into something i can work with
MYHEX=$1
printf "this is an alternate version of castly made to work with immersive-dark-mode https://github.com/realmazharhussain/immersive-dark-mode\n"
printf "if you do not have immersive-dark-mode installed, use castly instead!\n\n"
if ! command -v bc &> /dev/null
then
printf "bc not found, please install bc from your package manager\n\n(for example, sudo apt install bc, for debian-based distros)\n"
exit 1
fi
if [[ $1 == "info" ]]; then
printf "castlim is made by me; rgbmew, aka cthrn\n"
printf "https://github.com/rgbmew/castly/\n"
printf "my website: https://rgbmew.neocities.org/\n"
printf "and if you appreciate my work, consider giving me money via bandcamp LOL https://cthrn.bandcamp.com/\n\n"
printf "i wanted a simple way to change my accent color on GNOME, as the PR for custom accent colors is essentially dead, and alternatives like Gradience or Material You are just too complicated, and too dependency-heavy for my liking\n\n"
printf "castlim requires very few packages, just \033[1mimmersive-dark-mode\033[0m, \033[1mbash\033[0m, \033[1mgnu utils\033[0m, and \033[1mbc\033[0m\n\n\n"
printf "Q: It works on GTK4 apps, but not adw-gtk3; what shall i do\?!\?!\?\?!\?!\n"
printf "A: enable gtk symlinking in immersive-dark-mode!\n\n"
printf "Q: It works on natively-installed apps, but not flatpaks\?!\?!\?\?!\?!\n"
printf "A: flatpak override --user --filesystem=xdg-config/gtk-3.0:ro --filesystem=xdg-config/gtk-4.0:ro\n\n"
printf "Q: What's a good app for generating hex codes for my wallpaper?\n"
printf "A: I really like Paleta, in combination with Eyedropper, if I need more shades of the same color.\n"
printf "https://github.com/nate-xyz/paleta\n"
printf "https://github.com/FineFindus/eyedropper\n\n\n"
printf "known limitations that im unlikely to fix myself (consider submitting a PR!):\n"
printf " - GNOME Shell doesn't use the accent color (i would have to compile an entire shell theme, too many dependencies)\n"
printf " - you have to reload all of your apps for new accent colors to take effect\n"
printf "(more info - https://gitlab.gnome.org/GNOME/gtk/-/issues/3409)\n"
printf " - apps that force dark mode may look weird on light themes\n"
printf " - accent colors may not work on non-gtk apps, for example Telegram or KolourPaint\n\n"
printf "THE SOFTWARE IS PROVIDED “AS IS” or some shit idk im not a lawyer\n"
exit
fi
#check for errors
if ! [[ ${#MYHEX} == 6 && $2 =~ ^("all"|"title"|"sidebar"|"both"|"no")$ ]]; then
printf "usage: castlim <hex> <mode> <amount> <titlebar amount> <sidebar amount>\n\n"
printf "hex color should NOT contain #\n"
printf "all 3 amounts are optional (default 0.1, 0.2, 0.175)\n\n"
printf "modes: all, title, sidebar, both, no\n"
printf " all: tint all colors; the background, the titlebar, sidebar, and selection\n"
printf " title: tint the selection accent color & the titlebar\n"
printf " sidebar: tint the selection accent color & the sidebar\n"
printf " both: tint the titlebar, sidebar, & the selection accent color\n"
printf " no: only change the selection accent color\n\n"
printf "example: castlim 95AEA3 both 0.2 0.6 0.4\n"
printf "or: castlim 95AEA3\n\n"
printf "\033[31;4mTHIS PROGRAM WILL DELETE YOUR GTK.CSS\033[0m. \033[31;4mMAKE A BACKUP\033[0m!!!!!!!!!!!!!!!!!!\n\n"
printf "you can also run \"castlim info\" for more information about castlim!\n"
exit
fi
#I STOLE THIS HEX CONVERSION CODE FROM @nberlette ON GITHUB. THANK YOU FOR NOT SUING ME EVEN THOUGH I DIDNT ASK FOR PERMISSION
function hex() {
printf "%02X%02X%02X" ${*//','/' '}
}
[ $(basename -- $0) == "hex" ] && [ $# -gt 0 ] && echo $(hex "${*}")
#convert the hex to rgb so i can work with the values later
R=$(printf %d 0x${MYHEX:0:2})
G=$(printf %d 0x${MYHEX:2:2})
B=$(printf %d 0x${MYHEX:4:2})
#load user defined or default values
if [[ $3 != "" ]]; then
AMOUNT=$3
else
AMOUNT="0.1"
fi
HOMEAMOUNT=$(echo 1-$AMOUNT|bc)
#the titlebar can be tinted a different amount
if [[ $4 != "" ]]; then
TITLEAMOUNT=$4
else
TITLEAMOUNT=$(echo "$AMOUNT+$AMOUNT" | bc)
fi
TITLEHOMEAMOUNT=$(echo "1-$TITLEAMOUNT" | bc)
#the sidebar can be tinted a different amount
if [[ $5 != "" ]]; then
SIDEAMOUNT=$5
else
SIDEAMOUNT=$(echo "scale=3; ($AMOUNT*1.75)/1" | bc)
fi
SIDEHOMEAMOUNT=$(echo "1-$SIDEAMOUNT" | bc)
#the original adwaita ui colors so i can tint them (the R, G, and B are all the same)
COLLIGHT="255"
COLDARK="30"
#delete the original gtk.css file so im not just adding and adding and adding to make a 37mb css file lol
if test -f ~/.config/gtk-4.0/gtk-light.css; then
rm ~/.config/gtk-4.0/gtk-light.css
fi
if test -f ~/.config/gtk-4.0/gtk-dark.css; then
rm ~/.config/gtk-4.0/gtk-dark.css
fi
#and write my stuff
echo "@define-color accent_color #"$1";" >> ~/.config/gtk-4.0/gtk-dark.css
echo "@define-color accent_bg_color #"$1";" >> ~/.config/gtk-4.0/gtk-dark.css
echo "@define-color accent_color #"$1";" >> ~/.config/gtk-4.0/gtk-light.css
echo "@define-color accent_bg_color #"$1";" >> ~/.config/gtk-4.0/gtk-light.css
#TITLEBAR
if [[ $2 == "all" || $2 == "title" || $2 == "both" ]]; then
#do the tinting calculation on the RGB values
CURCOL=$COLDARK
for i in 1 2
do
COLR=$(echo "scale=0; ($CURCOL*$TITLEHOMEAMOUNT + $R*$TITLEAMOUNT)/1" | bc)
COLG=$(echo "scale=0; ($CURCOL*$TITLEHOMEAMOUNT + $G*$TITLEAMOUNT)/1" | bc)
COLB=$(echo "scale=0; ($CURCOL*$TITLEHOMEAMOUNT + $B*$TITLEAMOUNT)/1" | bc)
TITLECOL=$(hex $COLR $COLG $COLB) #then convert to hex!
if [[ $CURCOL == $COLDARK ]] then
echo "@define-color headerbar_bg_color #"$TITLECOL";" >> ~/.config/gtk-4.0/gtk-dark.css
else
echo "@define-color headerbar_bg_color #"$TITLECOL";" >> ~/.config/gtk-4.0/gtk-light.css
fi
CURCOL=$COLLIGHT
done
fi
#SIDEBAR
if [[ $2 == "all" || $2 == "sidebar" || $2 == "both" ]]; then
CURCOL=$COLDARK
for i in 1 2
do
COLR=$(echo "scale=0; ($CURCOL*$SIDEHOMEAMOUNT + $R*$SIDEAMOUNT)/1" | bc)
COLG=$(echo "scale=0; ($CURCOL*$SIDEHOMEAMOUNT + $G*$SIDEAMOUNT)/1" | bc)
COLB=$(echo "scale=0; ($CURCOL*$SIDEHOMEAMOUNT + $B*$SIDEAMOUNT)/1" | bc)
SIDECOL=$(hex $COLR $COLG $COLB)
COLR=$(echo "scale=0; ($CURCOL*$HOMEAMOUNT + $R*$AMOUNT)/1" | bc)
COLG=$(echo "scale=0; ($CURCOL*$HOMEAMOUNT + $G*$AMOUNT)/1" | bc)
COLB=$(echo "scale=0; ($CURCOL*$HOMEAMOUNT + $B*$AMOUNT)/1" | bc)
COL=$(hex $COLR $COLG $COLB)
if [[ $CURCOL == $COLDARK ]] then
if [[ $2 == "all" ]]; then
echo "@define-color window_bg_color #"$COL";" >> ~/.config/gtk-4.0/gtk-dark.css
echo "@define-color view_bg_color #"$COL";" >> ~/.config/gtk-4.0/gtk-dark.css
fi
echo "@define-color sidebar_bg_color #"$SIDECOL";" >> ~/.config/gtk-4.0/gtk-dark.css
echo "@define-color sidebar_backdrop_color #"$COL";" >> ~/.config/gtk-4.0/gtk-dark.css
echo "@define-color secondary_sidebar_bg_color #"$SIDECOL";" >> ~/.config/gtk-4.0/gtk-dark.css
echo "@define-color secondary_sidebar_backdrop_color #"$COL";" >> ~/.config/gtk-4.0/gtk-dark.css
else
if [[ $2 == "all" ]]; then
echo "@define-color window_bg_color #"$COL";" >> ~/.config/gtk-4.0/gtk-light.css
echo "@define-color view_bg_color #"$COL";" >> ~/.config/gtk-4.0/gtk-light.css
fi
echo "@define-color sidebar_bg_color #"$SIDECOL";" >> ~/.config/gtk-4.0/gtk-light.css
echo "@define-color sidebar_backdrop_color #"$COL";" >> ~/.config/gtk-4.0/gtk-light.css
echo "@define-color secondary_sidebar_bg_color #"$SIDECOL";" >> ~/.config/gtk-4.0/gtk-light.css
echo "@define-color secondary_sidebar_backdrop_color #"$COL";" >> ~/.config/gtk-4.0/gtk-light.css
fi
CURCOL=$COLLIGHT
done
fi
echo "@define-color window_fg_color rgba(0, 0, 0, 0.8);" >> ~/.config/gtk-4.0/gtk-light.css
echo "@define-color view_fg_color rgba(0, 0, 0, 0.8);" >> ~/.config/gtk-4.0/gtk-light.css
echo "@define-color headerbar_fg_color rgba(0, 0, 0, 0.8);" >> ~/.config/gtk-4.0/gtk-light.css
echo "@define-color sidebar_fg_color rgba(0, 0, 0, 0.8);" >> ~/.config/gtk-4.0/gtk-light.css
echo "@define-color secondary_sidebar_fg_color rgba(0, 0, 0, 0.8);" >> ~/.config/gtk-4.0/gtk-light.css
echo "@define-color window_fg_color #FFFFFF;" >> ~/.config/gtk-4.0/gtk-dark.css
echo "@define-color view_fg_color #FFFFFF;" >> ~/.config/gtk-4.0/gtk-dark.css
echo "@define-color headerbar_fg_color #FFFFFF;" >> ~/.config/gtk-4.0/gtk-dark.css
echo "@define-color sidebar_fg_color #FFFFFF;" >> ~/.config/gtk-4.0/gtk-dark.css
echo "@define-color secondary_sidebar_fg_color #FFFFFF;" >> ~/.config/gtk-4.0/gtk-dark.css
#yippee!
echo "done! reload your apps and it should work :)"
#created by rgbmew :)