-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathset-kitty-mode
executable file
·97 lines (75 loc) · 2.24 KB
/
set-kitty-mode
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
#!/bin/bash
state_path="$HOME"/.local/state/TERMINAL_MODE
dark_theme=Catppuccin-Mocha
light_theme=Catppuccin-Latte
if [ ! -f "$state_path" ]; then
echo 'dark' > "$state_path"
fi
print_usage () {
echo 'set-kitty-mode [-m] [system|light|dark]
-m
--start-monitoring: monitors gnome light/dark mode and automaticaly changes
kitty theme accordingly (requires system)
system: use current system mode
light: use light mode
dark: use dark mode
When no argument is passed, the last mode set with this script is used'
exit 1
}
if [[ $# -ge 3 ]]; then
print_usage
fi
case $1 in
-m | --start-monitoring )
# start daemon that matches Gnome's light/dark mode change (will be running on startup)
shift
case $1 in
system )
systemctl --user start kitty-gnome-mode-monitor.service
systemctl --user enable kitty-gnome-mode-monitor.service
;;
* )
print_usage
;;
esac
;;
esac
case $1 in
system )
mode=$(gsettings get org.gnome.desktop.interface color-scheme)
;;
light | dark )
mode=$1
# disable daemon that matches Gnome's light/dark mode change (won't be running on startup)
if systemctl --user is-enabled kitty-gnome-mode-monitor.service | grep -q 'enabled'; then
echo 'Disable kitty-gnome-mode-monitor.service...'
systemctl --user stop kitty-gnome-mode-monitor.service
systemctl --user disable kitty-gnome-mode-monitor.service
# kill running gsettings monitor
kitty-gnome-mode-monitor -k
fi
;;
'' ) # defaults to TERMINAL_THEME
mode=$(cat "$state_path")
;;
* )
print_usage
;;
esac
# sets kitty light/dark mode
case $mode in
*dark* )
kitty +kitten themes --cache-age=14 --reload-in=all "$dark_theme" 2>/dev/null || {
# do not refresh cache if theme repository cannot be joined (if offline for example)
kitty +kitten themes --cache-age=-1 --reload-in=all "$dark_theme"
}
echo dark > "$state_path"
;;
*default* | *light* )
kitty +kitten themes --cache-age=14 --reload-in=all "$light_theme" 2>/dev/null || {
# do not refresh cache if theme repository cannot be joined (if offline for example)
kitty +kitten themes --cache-age=-1 --reload-in=all "$light_theme"
}
echo light > "$state_path"
;;
esac