[foot] fix: (simple) theme switching
This commit is contained in:
parent
0a7a5181ff
commit
6ef7e0aef8
6 changed files with 184 additions and 9 deletions
|
@ -21,6 +21,7 @@ in {
|
||||||
source = ../../../stow/dunst/.config/dunst;
|
source = ../../../stow/dunst/.config/dunst;
|
||||||
};
|
};
|
||||||
".config/foot" = {
|
".config/foot" = {
|
||||||
|
recursive = true;
|
||||||
source = ../../../stow/foot/.config/foot;
|
source = ../../../stow/foot/.config/foot;
|
||||||
};
|
};
|
||||||
".config/fuzzel" = {
|
".config/fuzzel" = {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Toggle light- or dark-mode for your applications
|
# Toggle light- or dark-mode for your applications
|
||||||
# Usage: toggle [-m light|dark]
|
# Usage: toggle [-m light|dark] [-g]
|
||||||
|
|
||||||
#################
|
#################
|
||||||
### Variables ###
|
### Variables ###
|
||||||
|
@ -10,7 +10,9 @@ THEME_LIGHT='tdpeuter-light'
|
||||||
THEME_DARK='tdpeuter-dark'
|
THEME_DARK='tdpeuter-dark'
|
||||||
THEME_DEFAULT="${THEME_LIGHT}"
|
THEME_DEFAULT="${THEME_LIGHT}"
|
||||||
|
|
||||||
STATE_FILE="${HOME}/.local/state/sisyphus/theme"
|
STATE_DIR="${HOME}/.local/state/sisyphus"
|
||||||
|
STATE_FILE="${STATE_DIR}/theme"
|
||||||
|
BG_DIR="${HOME}/Nextcloud/Afbeeldingen/wallpapers"
|
||||||
|
|
||||||
declare -A theme_next
|
declare -A theme_next
|
||||||
theme_next[${THEME_LIGHT}]="${THEME_DARK}"
|
theme_next[${THEME_LIGHT}]="${THEME_DARK}"
|
||||||
|
@ -20,8 +22,12 @@ declare -A gsettings_alt
|
||||||
gsettings_alt[${THEME_LIGHT}]='default'
|
gsettings_alt[${THEME_LIGHT}]='default'
|
||||||
gsettings_alt[${THEME_DARK}]='prefer-dark'
|
gsettings_alt[${THEME_DARK}]='prefer-dark'
|
||||||
|
|
||||||
|
declare -A gtk_theme
|
||||||
|
gtk_theme[${THEME_LIGHT}]='Adwaita'
|
||||||
|
gtk_theme[${THEME_DARK}]='Adwaita-dark'
|
||||||
|
|
||||||
declare -A wallpaper
|
declare -A wallpaper
|
||||||
wallpaper[${THEME_LIGHT}]="bg"
|
wallpaper[${THEME_LIGHT}]="bg-light"
|
||||||
wallpaper[${THEME_DARK}]="bg-dark"
|
wallpaper[${THEME_DARK}]="bg-dark"
|
||||||
|
|
||||||
#############
|
#############
|
||||||
|
@ -29,7 +35,7 @@ wallpaper[${THEME_DARK}]="bg-dark"
|
||||||
#############
|
#############
|
||||||
|
|
||||||
# Parse options
|
# Parse options
|
||||||
while getopts ":m:" option; do
|
while getopts ":m:g" option; do
|
||||||
case "${option}" in
|
case "${option}" in
|
||||||
m)
|
m)
|
||||||
if [ "${OPTARG}" == 'light' ]; then
|
if [ "${OPTARG}" == 'light' ]; then
|
||||||
|
@ -41,6 +47,17 @@ while getopts ":m:" option; do
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
g)
|
||||||
|
previous_theme="$(cat ${STATE_FILE})"
|
||||||
|
if [ "${previous_theme}" == "${THEME_LIGHT}" ]; then
|
||||||
|
class="activated"
|
||||||
|
percentage=1
|
||||||
|
else
|
||||||
|
percentage=0
|
||||||
|
fi
|
||||||
|
printf '{ "class": "%s", "percentage": %d }' "${class}" "${percentage}"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
>&2 printf "Error: Invalid option: '%s'.\n" "${option}"
|
>&2 printf "Error: Invalid option: '%s'.\n" "${option}"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -65,9 +82,33 @@ echo "${theme:=${THEME_DEFAULT}}" > "${STATE_FILE}"
|
||||||
### Set all themes ###
|
### Set all themes ###
|
||||||
######################
|
######################
|
||||||
|
|
||||||
# GNOME
|
# Update terminal colors by sending it OSC sequences.
|
||||||
|
# Alternatively, you could use theme.sh (https://github.com/lemnos/theme.sh)
|
||||||
|
# Function below loosely based on theme.sh and https://codeberg.org/dnkl/foot/issues/708
|
||||||
|
function update_terminal_colors() {
|
||||||
|
for pid in $(pgrep zsh); do
|
||||||
|
if [ "${theme}" == "${THEME_LIGHT}" ]; then
|
||||||
|
printf "\033]10;#000000\007" >> /proc/${pid}/fd/0
|
||||||
|
printf "\033]11;#ffffff\007" >> /proc/${pid}/fd/0
|
||||||
|
elif [ "${theme}" == "${THEME_DARK}" ]; then
|
||||||
|
printf "\033]10;#ffffff\007" >> /proc/${pid}/fd/0
|
||||||
|
printf "\033]11;#000000\007" >> /proc/${pid}/fd/0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Foot
|
||||||
|
if [ "$(command -v foot)" ] ; then
|
||||||
|
# Make color theme switch 'permanent'.
|
||||||
|
echo "include=~/.config/foot/themes/${theme}.ini" > ~/.config/foot/theme.ini &
|
||||||
|
# We will have to change the terminal colors ourselves.
|
||||||
|
update_terminal_colors &
|
||||||
|
fi
|
||||||
|
|
||||||
|
# GNOME (GTK)
|
||||||
if [ "$(command -v gsettings)" ]; then
|
if [ "$(command -v gsettings)" ]; then
|
||||||
gsettings set org.gnome.desktop.interface color-scheme "${gsettings_alt[${theme}]}" &
|
gsettings set org.gnome.desktop.interface color-scheme "${gsettings_alt[${theme}]}" &
|
||||||
|
gsettings set org.gnome.desktop.interface gtk-theme "${gtk_theme[${theme}]}" &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Kitty
|
# Kitty
|
||||||
|
@ -77,7 +118,8 @@ fi
|
||||||
|
|
||||||
# Sway
|
# Sway
|
||||||
if [ "$(command -v swaybg)" ]; then
|
if [ "$(command -v swaybg)" ]; then
|
||||||
pkill swaybg && swaybg --mode fill --image ~/Nextcloud/Afbeeldingen/wallpapers/${wallpaper[${theme}]} && swaymsg reload &
|
bg_path="${BG_DIR}/${wallpaper[${theme}]}"
|
||||||
|
/run/current-system/sw/bin/cp "${bg_path}" "${STATE_DIR}/bg" && swaymsg reload &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Vifm
|
# Vifm
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
# -*- conf -*-
|
# -*- conf -*-
|
||||||
|
# ~/.config/foot/foot.ini
|
||||||
|
|
||||||
|
# Include the correct color scheme
|
||||||
|
include=~/.config/foot/theme.ini
|
||||||
|
|
||||||
# shell=$SHELL (if set, otherwise user's default shell from /etc/passwd)
|
# shell=$SHELL (if set, otherwise user's default shell from /etc/passwd)
|
||||||
term=xterm-256color
|
term=xterm-256color
|
||||||
|
@ -20,7 +24,7 @@ font=letter extended:size=10
|
||||||
# underline-offset=<font metrics>
|
# underline-offset=<font metrics>
|
||||||
# underline-thickness=<font underline thickness>
|
# underline-thickness=<font underline thickness>
|
||||||
# box-drawings-uses-font-glyphs=no
|
# box-drawings-uses-font-glyphs=no
|
||||||
# dpi-aware=no
|
dpi-aware=yes
|
||||||
|
|
||||||
# initial-window-size-pixels=700x500 # Or,
|
# initial-window-size-pixels=700x500 # Or,
|
||||||
# initial-window-size-chars=<COLSxROWS>
|
# initial-window-size-chars=<COLSxROWS>
|
||||||
|
@ -75,7 +79,7 @@ visual=yes
|
||||||
# long-press-delay=400
|
# long-press-delay=400
|
||||||
|
|
||||||
[colors]
|
[colors]
|
||||||
alpha=0.9
|
alpha=0.8
|
||||||
# background=242424
|
# background=242424
|
||||||
# foreground=ffffff
|
# foreground=ffffff
|
||||||
flash=b00020
|
flash=b00020
|
||||||
|
|
64
stow/foot/.config/foot/themes/tdpeuter-dark.ini
Normal file
64
stow/foot/.config/foot/themes/tdpeuter-dark.ini
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
[colors]
|
||||||
|
# alpha=0.8
|
||||||
|
background=171717
|
||||||
|
foreground=dcdfe4
|
||||||
|
# flash=b00020
|
||||||
|
# flash-alpha=0.5
|
||||||
|
|
||||||
|
## Normal/regular colors (color palette 0-7)
|
||||||
|
regular0=242424 # black
|
||||||
|
# regular0=21222c
|
||||||
|
# regular1=f62b5a # red
|
||||||
|
regular1=c86564
|
||||||
|
regular2=47b413 # green
|
||||||
|
# regular2=b2bc68
|
||||||
|
regular3=e3c401 # yellow
|
||||||
|
# regular3=f7e03f
|
||||||
|
# regular4=24acd4 # blue
|
||||||
|
regular4=80a2be
|
||||||
|
regular5=f2affd # magenta
|
||||||
|
# color5 #b294bb
|
||||||
|
# regular6=13c299 # cyan
|
||||||
|
regular6=8abeb7
|
||||||
|
regular7=e6e6e6 # white
|
||||||
|
# regular7=ffffff
|
||||||
|
|
||||||
|
## Bright colors (color palette 8-15)
|
||||||
|
# bright0=616161 # bright black
|
||||||
|
# bright0=6272a4
|
||||||
|
# bright1=ff4d51 # bright red
|
||||||
|
# color9 #C86564
|
||||||
|
# bright2=35d450 # bright green
|
||||||
|
# color10 #B2BC68
|
||||||
|
# bright3=e9e836 # bright yellow
|
||||||
|
# color11 #f7e03f
|
||||||
|
# bright4=5dc5f8 # bright blue
|
||||||
|
# color12 #80A2BE
|
||||||
|
# bright5=feabf2 # bright magenta
|
||||||
|
# bright5=b294bb
|
||||||
|
# bright6=24dfc4 # bright cyan
|
||||||
|
# bright6=8abeb7
|
||||||
|
bright7=ffffff # bright white
|
||||||
|
|
||||||
|
## dimmed colors (see foot.ini(5) man page)
|
||||||
|
# dim0=<not set>
|
||||||
|
# ...
|
||||||
|
# dim7=<not-set>
|
||||||
|
|
||||||
|
## The remaining 256-color palette
|
||||||
|
# 16 = <256-color palette #16>
|
||||||
|
# ...
|
||||||
|
# 255 = <256-color palette #255>
|
||||||
|
|
||||||
|
## Misc colors
|
||||||
|
# selection-foreground=<inverse foreground/background>
|
||||||
|
# selection-foreground=000000
|
||||||
|
# selection-background=<inverse foreground/background>
|
||||||
|
# selection-background=fffacd
|
||||||
|
# jump-labels=<regular0> <regular3> # black-on-yellow
|
||||||
|
# scrollback-indicator=<regular0> <bright4> # black-on-bright-blue
|
||||||
|
# search-box-no-match=<regular0> <regular1> # black-on-red
|
||||||
|
# search-box-match=<regular0> <regular3> # black-on-yellow
|
||||||
|
# urls=<regular3>
|
||||||
|
urls=0087bd
|
||||||
|
|
64
stow/foot/.config/foot/themes/tdpeuter-light.ini
Normal file
64
stow/foot/.config/foot/themes/tdpeuter-light.ini
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
[colors]
|
||||||
|
# alpha=0.8
|
||||||
|
background=fafafa
|
||||||
|
foreground=000000
|
||||||
|
# flash=b00020
|
||||||
|
# flash-alpha=0.5
|
||||||
|
|
||||||
|
## Normal/regular colors (color palette 0-7)
|
||||||
|
# regular0=242424 # black
|
||||||
|
# color0 #383A42
|
||||||
|
# regular1=f62b5a # red
|
||||||
|
# color1 #E45649
|
||||||
|
# regular2=47b413 # green
|
||||||
|
# color2 #40A14F
|
||||||
|
# regular3=e3c401 # yellow
|
||||||
|
# color3 #C18401
|
||||||
|
# regular4=24acd4 # blue
|
||||||
|
regular4=0184bc
|
||||||
|
# regular5=f2affd # magenta
|
||||||
|
# color5 #A626A4
|
||||||
|
# regular6=13c299 # cyan
|
||||||
|
# color6 #0997B3
|
||||||
|
# regular7=e6e6e6 # white
|
||||||
|
# color7 #FAFAFA
|
||||||
|
|
||||||
|
## Bright colors (color palette 8-15)
|
||||||
|
# bright0=616161 # bright black
|
||||||
|
# color8 #6272a4
|
||||||
|
# bright1=ff4d51 # bright red
|
||||||
|
# color9 #E45649
|
||||||
|
# bright2=35d450 # bright green
|
||||||
|
# color10 #40A14F
|
||||||
|
# bright3=e9e836 # bright yellow
|
||||||
|
# color11 #C18401
|
||||||
|
# bright4=5dc5f8 # bright blue
|
||||||
|
# color12 #0184BC
|
||||||
|
# bright5=feabf2 # bright magenta
|
||||||
|
# color13 #A626A4
|
||||||
|
# bright6=24dfc4 # bright cyan
|
||||||
|
# color14 #0997B3
|
||||||
|
# bright7=ffffff # bright white
|
||||||
|
# color15 #FAFAFA
|
||||||
|
|
||||||
|
## dimmed colors (see foot.ini(5) man page)
|
||||||
|
# dim0=<not set>
|
||||||
|
# ...
|
||||||
|
# dim7=<not-set>
|
||||||
|
|
||||||
|
## The remaining 256-color palette
|
||||||
|
# 16 = <256-color palette #16>
|
||||||
|
# ...
|
||||||
|
# 255 = <256-color palette #255>
|
||||||
|
|
||||||
|
## Misc colors
|
||||||
|
# selection-foreground=<inverse foreground/background>
|
||||||
|
selection-foreground=383a42
|
||||||
|
# selection-background=<inverse foreground/background>
|
||||||
|
selection-background=bfceff
|
||||||
|
# jump-labels=<regular0> <regular3> # black-on-yellow
|
||||||
|
# scrollback-indicator=<regular0> <bright4> # black-on-bright-blue
|
||||||
|
# search-box-no-match=<regular0> <regular1> # black-on-red
|
||||||
|
# search-box-match=<regular0> <regular3> # black-on-yellow
|
||||||
|
urls=f0f0f0
|
||||||
|
|
|
@ -11,7 +11,7 @@ input type:touchpad {
|
||||||
}
|
}
|
||||||
|
|
||||||
output * {
|
output * {
|
||||||
bg "~/Nextcloud/Afbeeldingen/wallpapers/bg" fill
|
bg "${HOME}/.local/state/sisyphus/bg" fill
|
||||||
}
|
}
|
||||||
|
|
||||||
# Vertical display
|
# Vertical display
|
||||||
|
|
Loading…
Reference in a new issue