-
Notifications
You must be signed in to change notification settings - Fork 0
/
dark.sh
executable file
·105 lines (88 loc) · 2.49 KB
/
dark.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
#!/bin/bash
#################################################################################
# Dark: Switch between system dark and light modes on macOS
# and manually switch between dark and light themes in some apps.
#################################################################################
# prevent running not on macOS
if [[ "$OSTYPE" != "darwin"* ]]; then
echo "Dark mode script only supports macOS, exiting."
exit
fi
################################# macOS dark mode
osascript -e '
tell application "System Events"
tell appearance preferences
set dark mode to not dark mode
end tell
end tell
'
################################# variable for other apps
# define variable if changing light -> dark
# 2>/dev/null to suppress error if changing dark -> light
if [[ $(defaults read -g AppleInterfaceStyle 2>/dev/null) == "Dark" ]]; then
set_dark=true
fi
################################# Marta
conf=$HOME/Library/Application\ Support/org.yanex.marta/conf.marco
if [ "$set_dark" = true ]; then
sed -i '' -e 's/theme "Classic"/theme "Igor"/g' "$conf"
else
sed -i '' -e 's/theme "Igor"/theme "Classic"/g' "$conf"
fi
################################# PDF Expert
if [[ $(pgrep "PDF Expert") ]]; then
if [ "$set_dark" = true ]; then
osascript -e '
tell application "PDF Expert" to activate
tell application "System Events"
keystroke "n" using {option down, command down}
end tell
'
else
osascript -e '
tell application "PDF Expert" to activate
tell application "System Events"
keystroke "z" using {option down, command down}
end tell
'
fi
fi
################################# VSCode
conf=$HOME/Library/Application\ Support/Cursor/User/settings.json
light_values=(
# To do highlighting
'"color": "#A74047"'
'"backgroundColor": "#A7404715"'
'"overviewRulerColor": "#A74047"'
# Git graph
'#D73A4A'
'#28A745'
'#DCAB07'
'#0366D6'
'#5B32A3'
'#1C7C82'
)
dark_values=(
# To do highlighting
'"color": "#b48ead"'
'"backgroundColor": "#b48ead30"'
'"overviewRulerColor": "#b48ead"'
# Git graph
'#5E81AC'
'#88C0D0'
'#BF616A'
'#A3BE8C'
'#EBCB8B'
'#B48EAD'
)
for i in "${!light_values[@]}"; do
if [ "$set_dark" = true ]; then
# light -> dark
sed -i '' "s/${light_values[i]}/${dark_values[i]}/g" "$conf"
else
# dark -> light
sed -i '' "s/${dark_values[i]}/${light_values[i]}/g" "$conf"
fi
done
################################# Switch back to iTerm
osascript -e 'tell application "iTerm" to activate'