switch between global dark and light themes (super + F6)
This commit is contained in:
parent
d81399a25e
commit
f3d07932e4
@ -1,13 +1,17 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
action = 'switch'
|
||||||
|
if len(sys.argv) > 1:
|
||||||
|
action = sys.argv[1]
|
||||||
path = os.path.join(os.getenv('HOME'), '.config/alacritty/alacritty.yml')
|
path = os.path.join(os.getenv('HOME'), '.config/alacritty/alacritty.yml')
|
||||||
with open(path, 'r+') as f:
|
with open(path, 'r+') as f:
|
||||||
cfg = f.read()
|
cfg = f.read()
|
||||||
if "colors: *dark" in cfg:
|
if "colors: *dark" in cfg and action in ['switch', 'light']:
|
||||||
cfg = cfg.replace("colors: *dark", "colors: *light")
|
cfg = cfg.replace("colors: *dark", "colors: *light")
|
||||||
else:
|
elif "colors: *light" in cfg and action in ['switch', 'dark']:
|
||||||
cfg = cfg.replace("colors: *light", "colors: *dark")
|
cfg = cfg.replace("colors: *light", "colors: *dark")
|
||||||
f.seek(0)
|
f.seek(0)
|
||||||
f.write(cfg)
|
f.write(cfg)
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
|
|
||||||
sxhkd &
|
xdo kill $(xdo id -N Polybar)
|
||||||
|
|
||||||
i=0
|
i=0
|
||||||
monitors=$(bspc query -M --names)
|
monitors=$(bspc query -M --names)
|
||||||
for monitor in $monitors; do
|
for monitor in $monitors; do
|
||||||
@ -20,11 +19,9 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
bspc config border_width 4
|
bspc config border_width 4
|
||||||
bspc config window_gap 8
|
bspc config window_gap 12
|
||||||
|
|
||||||
bspc config normal_border_color '#808080'
|
sh ~/.config/bspwm/commands.sh dark-colors
|
||||||
bspc config focused_border_color '#3585ce'
|
|
||||||
bspc config presel_feedback_color '#3585ce'
|
|
||||||
|
|
||||||
bspc config split_ratio 0.50
|
bspc config split_ratio 0.50
|
||||||
bspc config single_monocle true
|
bspc config single_monocle true
|
||||||
|
71
.config/bspwm/commands.sh
Normal file
71
.config/bspwm/commands.sh
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
CMD="$1"
|
||||||
|
shift
|
||||||
|
|
||||||
|
is_light() {
|
||||||
|
bspc config focused_border_color | grep '#068c70' > /dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$CMD" = switch-colors ]; then
|
||||||
|
if is_light; then
|
||||||
|
CMD=dark-colors
|
||||||
|
SCHEME=dark
|
||||||
|
else
|
||||||
|
CMD=light-colors
|
||||||
|
SCHEME=light
|
||||||
|
fi
|
||||||
|
elif is_light; then
|
||||||
|
SCHEME=light
|
||||||
|
else
|
||||||
|
SCHEME=dark
|
||||||
|
fi
|
||||||
|
|
||||||
|
FONT=Iosevka:pixelsize=30
|
||||||
|
if [ "$SCHEME" = light ]; then
|
||||||
|
ROOT_BG=#c1e6c2
|
||||||
|
BAR_BG=#e1e6d2
|
||||||
|
BAR_FG=#1a343a
|
||||||
|
BAR_ACTIVE=#b0decc
|
||||||
|
BAR_URGENT=#9b0640
|
||||||
|
BAR_EMPTY=#b0b0b0
|
||||||
|
NORMAL_BORDER=#b0b0b0
|
||||||
|
FOCUS_BORDER=#068c70
|
||||||
|
EMACS_THEME=lupan-light
|
||||||
|
else
|
||||||
|
ROOT_BG=#343a1a
|
||||||
|
BAR_BG=#1a343a
|
||||||
|
BAR_FG=#f2f6e1
|
||||||
|
BAR_ACTIVE=#3585ce
|
||||||
|
BAR_URGENT=#9b0640
|
||||||
|
BAR_EMPTY=#808080
|
||||||
|
NORMAL_BORDER=#808080
|
||||||
|
FOCUS_BORDER=#3585ce
|
||||||
|
EMACS_THEME=lupan-dark-blue
|
||||||
|
fi
|
||||||
|
|
||||||
|
switch_colors() {
|
||||||
|
xrdb -merge <<EOF
|
||||||
|
polybar.background: ${BAR_BG}
|
||||||
|
polybar.foreground: ${BAR_FG}
|
||||||
|
polybar.active: ${BAR_ACTIVE}
|
||||||
|
polybar.urgent: ${BAR_URGENT}
|
||||||
|
polybar.empty: ${BAR_EMPTY}
|
||||||
|
EOF
|
||||||
|
polybar-msg cmd restart
|
||||||
|
xsetroot -solid "${ROOT_BG}"
|
||||||
|
bspc config normal_border_color "${NORMAL_BORDER}"
|
||||||
|
bspc config focused_border_color "${FOCUS_BORDER}"
|
||||||
|
bspc config presel_feedback_color "${FOCUS_BORDER}"
|
||||||
|
python ~/.config/alacritty/switch_bg.py "$SCHEME"
|
||||||
|
emacsclient --eval "(my-select-theme '${EMACS_THEME})"
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$CMD" in
|
||||||
|
light-colors|dark-colors)
|
||||||
|
switch_colors
|
||||||
|
;;
|
||||||
|
dmenu|dmenu_run)
|
||||||
|
exec "$CMD" -nb "${BAR_BG}" -nf "${BAR_FG}" -sb "${BAR_ACTIVE}" -sf "${BAR_FG}" -fn "$FONT" "$@"
|
||||||
|
;;
|
||||||
|
esac
|
@ -1,15 +1,16 @@
|
|||||||
[colors]
|
[colors]
|
||||||
background = #1a343a
|
background = ${xrdb:polybar.background:#1a343a}
|
||||||
foreground = #f2f6e1
|
foreground = ${xrdb:polybar.foreground:#f2f6e1}
|
||||||
underline = #1a343a
|
active = ${xrdb:polybar.active:#3585ce}
|
||||||
active = #3585ce
|
urgent = ${xrdb:polybar.urgent:#9b0640}
|
||||||
urgent = #9b0640
|
empty = ${xrdb:polybar.empty:#808080}
|
||||||
empty = #808080
|
|
||||||
|
|
||||||
[bar/panel]
|
[bar/panel]
|
||||||
monitor = ${env:MONITOR:}
|
monitor = ${env:MONITOR:}
|
||||||
modules-left = bspwm xwindow
|
modules-left = bspwm xwindow
|
||||||
modules-right = date
|
modules-right = date
|
||||||
|
wm-restack = bspwm
|
||||||
|
enable-ipc = true
|
||||||
font-0 = Iosevka:pixelsize=23:antialias=true:autohint=true;5
|
font-0 = Iosevka:pixelsize=23:antialias=true:autohint=true;5
|
||||||
height = 40
|
height = 40
|
||||||
background = ${colors.background}
|
background = ${colors.background}
|
||||||
@ -31,7 +32,6 @@ label-occupied-padding = 1
|
|||||||
label-urgent-padding = 1
|
label-urgent-padding = 1
|
||||||
label-empty-padding = 1
|
label-empty-padding = 1
|
||||||
label-focused-background = ${colors.active}
|
label-focused-background = ${colors.active}
|
||||||
label-focused-underline = ${colors.underline}
|
|
||||||
label-urgent-background = ${colors.urgent}
|
label-urgent-background = ${colors.urgent}
|
||||||
label-empty-foreground = ${colors.empty}
|
label-empty-foreground = ${colors.empty}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ super + shift + Return
|
|||||||
|
|
||||||
# program launcher
|
# program launcher
|
||||||
super + p
|
super + p
|
||||||
dmenu_run -nb '#1a343a' -nf '#a0a0a0' -sb '#3585ce' -sf '#e0e0e0' -fn Iosevka:pixelsize=30
|
sh ~/.config/bspwm/commands.sh dmenu_run
|
||||||
|
|
||||||
# make sxhkd reload its configuration files:
|
# make sxhkd reload its configuration files:
|
||||||
super + Escape
|
super + Escape
|
||||||
@ -18,10 +18,13 @@ super + e
|
|||||||
emacsclient -n -c
|
emacsclient -n -c
|
||||||
|
|
||||||
super + ctrl + p
|
super + ctrl + p
|
||||||
bspc node -f $(xtitle -f '%u %s\n' $(bspc query -N -n .window) | dmenu -i -l 20 -nb '#1a343a' -nf '#a0a0a0' -sb '#3585ce' -sf '#e0e0e0' -fn Iosevka:pixelsize=30 | cut -f 1 -d ' ')
|
bspc node -f $(xtitle -f '%u %s\n' $(bspc query -N -n .window) | sh ~/.config/bspwm/commands.sh dmenu | cut -f 1 -d ' ')
|
||||||
|
|
||||||
super + semicolon
|
super + semicolon
|
||||||
echo -e 'slock\nsystemctl suspend\nsystemctl hibernate\n' | dmenu -l 20 -nb '#1a343a' -nf '#a0a0a0' -sb '#3585ce' -sf '#e0e0e0' -fn Iosevka:pixelsize=30 | sh
|
echo -e 'slock\nsystemctl suspend\nsystemctl hibernate\n' | sh ~/.config/bspwm/commands.sh dmenu -l 20 | sh
|
||||||
|
|
||||||
|
super + F6
|
||||||
|
sh ~/.config/bspwm/commands.sh switch-colors
|
||||||
|
|
||||||
#
|
#
|
||||||
# bspwm hotkeys
|
# bspwm hotkeys
|
||||||
|
@ -20,7 +20,11 @@ fi
|
|||||||
# run emacs daemon if not running
|
# run emacs daemon if not running
|
||||||
emacsclient --eval nil -a '' &
|
emacsclient --eval nil -a '' &
|
||||||
|
|
||||||
exec /usr/bin/bspwm
|
if which bspwm > /dev/null; then
|
||||||
|
sxhkd &
|
||||||
|
xsetroot -cursor_name left_ptr
|
||||||
|
exec bspwm
|
||||||
|
fi
|
||||||
exec /usr/bin/i3
|
exec /usr/bin/i3
|
||||||
dwm-clock &
|
dwm-clock &
|
||||||
exec /usr/local/bin/dwm
|
exec /usr/local/bin/dwm
|
||||||
|
Loading…
x
Reference in New Issue
Block a user