-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmode
executable file
·181 lines (151 loc) · 4.43 KB
/
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
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
#!/usr/bin/env bash
set -Eeuo pipefail
BASE_DIR=$(dirname "${BASH_SOURCE[0]:-$0}")
cd "${BASE_DIR}/.." || exit 127
# shellcheck source=./helpers.sh
. helpers.sh
PROGRAM=$(basename "${BASH_SOURCE[0]:-$0}")
VERSION=0.4.0
function display_help() {
cat <<EOF
$(help_section Usage)
${PROGRAM} [options] (<theme> | <screen>)
$(help_section Themes)
dark
light
$(help_section Screens)
// work 2 screens stacked (eDP1 on bottom)
work 2 screens side-by-side (eDP1 on right)
home 2 screens side-by-side
pitch 2 screens 2nd on top
chill 1 screen (eDP1)
focus 1 screen (HDMI1)
demo ~2 screens mirror~, notifications off and increase font-size
$(help_section Options)
-h, --help Show this screen.
-v, --version Show version.
EOF
}
function i3restart() {
i3-msg restart >/dev/null
numlockx on
setcapslock off
setxkbmap -option ctrl:nocaps
}
function toggle_keyboard_backlight() {
declare -r brightness=$(cat /sys/class/leds/tpacpi::kbd_backlight/brightness)
if [[ $brightness -eq 0 ]]; then
echo 1 >/sys/class/leds/tpacpi::kbd_backlight/brightness
else
echo 0 >/sys/class/leds/tpacpi::kbd_backlight/brightness
fi
}
function set_notifications() {
declare -r status="$1"
case $status in
on)
# dunstctl set-paused true
gsettings set org.gnome.desktop.notifications show-banners true
;;
off)
# dunstctl set-paused false
gsettings set org.gnome.desktop.notifications show-banners false
;;
esac
}
function set_editor_font_size() {
declare -r code_settings="$DOTFILES/vscode/settings.json"
declare -r size="$1"
sed -i -e "s/\"editor.fontSize\": .*/\"editor.fontSize\": ${size},/g" "${code_settings}"
}
function set_terminal_font_size() {
# declare -r alacritty_config="$DOTFILES/alacritty/alacritty.toml"
declare -r size="$1"
declare -r wezterm_config="$DOTFILES/wezterm/wezterm.lua"
# sed -i "s/size =.*/size = ${size}/g" "${alacritty_config}"
sed -i "s/config.font_size =.*/config.font_size = ${size}/g" "${wezterm_config}"
}
function change_theme_to() {
declare -r theme="$1"
# declare -r alacritty_config="$DOTFILES/alacritty/alacritty.toml"
declare -r git_config="$DOTFILES/git/gitconfig"
# declare -r code_settings="$DOTFILES/vscode/settings.json"
# sed -i "s|^import = \[.*\]|import = [\"~/.dotfiles/alacritty/themes/google.${theme}.toml\"]|" "${alacritty_config}"
case $theme in
dark)
# sed -i -e 's/"workbench.colorTheme": ".*"/"workbench.colorTheme": "GitHub Dark"/g' "${code_settings}"
sed -i "s/light =.*/light = false/g" "${git_config}"
gsettings set org.gnome.desktop.interface color-scheme prefer-dark
;;
light)
# sed -i -e 's/"workbench.colorTheme": ".*"/"workbench.colorTheme": "GitHub Light"/g' "${code_settings}"
sed -i "s/light =.*/light = true/g" "${git_config}"
gsettings set org.gnome.desktop.interface color-scheme default
# gsettings set org.gnome.desktop.interface color-scheme prefer-light
;;
esac
# i3restart
echo "Theme changed to $theme!"
}
function get_theme() {
# declare -r config_file="$DOTFILES/alacritty/alacritty.toml"
#
# grep 'import = *' $config_file | awk -F '.' '{ print $3 }'
# gsettings get org.gnome.desktop.interface color-scheme | grep -oE 'dark|light'
case "$(gsettings get org.gnome.desktop.interface color-scheme)" in
*'dark'*) echo "dark" ;;
*'light'*) echo "light" ;;
*) echo "light" ;; # Default to light if neither is found
esac
}
function change_screen_to() {
case $1 in
work)
autorandr work
;;
home)
autorandr home
;;
chill)
change_theme_to dark
set_notifications on
set_editor_font_size 18
set_terminal_font_size 18
;;
pitch) ;;
focus) ;;
demo)
change_theme_to light
set_notifications off
set_editor_font_size 32
set_terminal_font_size 26.0
;;
esac
# nitrogen --restore 2>/dev/null
# i3restart
echo "Changed to mode $1!"
}
case ${1:-error} in
-h | --help)
display_help
;;
-v | --version)
display_version "$PROGRAM" "$VERSION"
;;
-t | --theme)
get_theme
;;
-k | --keyboard)
toggle_keyboard_backlight
;;
dark | light)
change_theme_to "$1"
;;
work | home | chill | pitch | focus | demo)
change_screen_to "$1"
;;
*)
display_help >&2
exit 1
;;
esac