-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoggle-theme
More file actions
executable file
·144 lines (115 loc) · 3.19 KB
/
Copy pathtoggle-theme
File metadata and controls
executable file
·144 lines (115 loc) · 3.19 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
#!/bin/bash
XDG_CONFIG_DIR="$HOME/.config/"
LOG_FILE="/tmp/toggle-theme.log"
# Function to log messages
log() {
echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" >> "$LOG_FILE"
}
log "starting script"
function gtk_dark() {
gsettings set org.gnome.desktop.interface color-scheme prefer-dark
gsettings set org.gnome.desktop.interface gtk-theme Adwaita-dark
}
function gtk_light() {
gsettings set org.gnome.desktop.interface color-scheme prefer-light
gsettings set org.gnome.desktop.interface gtk-theme Adwaita
}
function kitty_apply() {
ss -l -x | grep 'kitty' | awk '{ print($5) }' | xargs -I % kitten @ load-config --to unix:%
kitty @ set-colors --all "$XDG_CONFIG_DIR/kitty/colors.conf"
}
function kitty_dark() {
ln --symbolic --force "$XDG_CONFIG_DIR/kitty/sakura.conf" "$XDG_CONFIG_DIR/kitty/colors.conf"
}
function kitty_light() {
ln --symbolic --force "$XDG_CONFIG_DIR/kitty/tokyonight_day.conf" "$XDG_CONFIG_DIR/kitty/colors.conf"
}
function nvim_dark() {
echo 'return { flavour = "mocha" }' > "$XDG_CONFIG_DIR/nvim/theme.lua"
}
function nvim_light() {
echo 'return { flavour = "latte" }' > "$XDG_CONFIG_DIR/nvim/theme.lua"
}
function mako_apply() {
makoctl reload
log "mako reload"
}
function mako_dark() {
cat "$XDG_CONFIG_DIR/mako/config-base" "$XDG_CONFIG_DIR/mako/themes/catppuccin-mocha/catppuccin-mocha-flamingo" > "$XDG_CONFIG_DIR/mako/config"
log "mako dark"
}
function mako_light() {
cat "$XDG_CONFIG_DIR/mako/config-base" "$XDG_CONFIG_DIR/mako/themes/catppuccin-latte/catppuccin-latte-flamingo" > "$XDG_CONFIG_DIR/mako/config"
log "mako light"
}
function sway_apply() {
swaymsg reload
}
function sway_dark() {
ln --symbolic --force "$XDG_CONFIG_DIR/sway/colors-catpuccin-mocha" "$XDG_CONFIG_DIR/sway/colors"
}
function sway_light() {
ln --symbolic --force "$XDG_CONFIG_DIR/sway/colors-catpuccin-latte" "$XDG_CONFIG_DIR/sway/colors"
}
function wofi_dark() {
ln --symbolic --force "$XDG_CONFIG_DIR/wofi/config-catpuccin-mocha" "$XDG_CONFIG_DIR/wofi/style.css"
}
function wofi_light() {
ln --symbolic --force "$XDG_CONFIG_DIR/wofi/config-catpuccin-latte" "$XDG_CONFIG_DIR/wofi/style.css"
}
STATE_FILE="$HOME/.local/state/theme-toggle/state.json"
function setup() {
if [ -f "$STATE_FILE" ]
then
return
fi
mkdir -p "$(dirname $STATE_FILE)"
echo '{"theme": "dark"}' > "$STATE_FILE"
}
function set_theme() {
state="$(cat $STATE_FILE)"
echo "$state" | jq --arg t "$theme" '.theme = $t' > "$STATE_FILE"
}
function get_theme() {
current="$(jq -r '.theme' "$STATE_FILE")"
echo "$current"
}
theme=""
function process_args() {
if [ -z "$1" ]
then
echo "Please provide the argument 'dark', 'light' or 'switch'"
exit 1
fi
if [ "$1" == "light" ] || [ "$1" == "dark" ]
then
theme="$1"
elif [ "$1" == "switch" ]; then
current="$(get_theme)"
theme="dark"
if [ "$current" == "dark" ]
then
theme="light"
fi
echo "$theme"
else
echo "Unkown argument, please provide the argument 'dark', 'light' or 'switch'"
exit 1
fi
}
function main() {
for f in $(declare -F | grep "$theme" | awk '{ print($3) }')
do
echo "$f"
"$f"
done
for f in $(declare -F | grep 'apply' | awk '{ print($3) }')
do
echo "$f"
"$f"
done
}
setup
process_args "$@"
main
set_theme