diff options
Diffstat (limited to 'niri')
| -rwxr-xr-x | niri/.config/niri/apply-colors.sh | 40 | ||||
| -rw-r--r-- | niri/.config/niri/config.kdl | 3 | ||||
| -rwxr-xr-x | niri/.config/niri/theme-switcher.sh | 10 |
3 files changed, 47 insertions, 6 deletions
diff --git a/niri/.config/niri/apply-colors.sh b/niri/.config/niri/apply-colors.sh new file mode 100755 index 0000000..5383ed7 --- /dev/null +++ b/niri/.config/niri/apply-colors.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Apply a wallpaper and generate colors with wallust (16-color palette) + matugen (Material You / M3). +# Usage: apply-colors.sh <image> [light|dark] +# Called by theme-switcher.sh and the waybar random-wallpaper click. + +set -euo pipefail + +IMG="${1:-}" +MODE="${2:-auto}" + +if [ -z "$IMG" ] || [ ! -f "$IMG" ]; then + echo "usage: $0 <image> [light|dark]" >&2 + exit 1 +fi + +# wallust: classic 16-color palette (foot, btop, ...) +case "$MODE" in + light) wallust run --palette light "$IMG" ;; + dark) wallust run --palette dark "$IMG" ;; + *) wallust run "$IMG" ;; +esac + +# foot needs bare RRGGBB, not #RRGGBB — strip the leading '#' +sed -i 's/#\([0-9a-fA-F]\)/\1/g' ~/.cache/wallust/foot-theme.ini 2>/dev/null || true + +# matugen: Material You / M3 colors (niri focus ring, ...) +# --prefer is required for non-interactive runs (multiple source colors). +case "$MODE" in + light) matugen image "$IMG" -m "light" --prefer saturation ;; + dark) matugen image "$IMG" -m "dark" --prefer saturation ;; + *) matugen image "$IMG" --prefer saturation ;; +esac + +# set the wallpaper +awww img "$IMG" + +# reload consumers +killall -SIGUSR2 waybar 2>/dev/null || true +killall -USR1 foot 2>/dev/null || true +niri msg action reload-config 2>/dev/null || true diff --git a/niri/.config/niri/config.kdl b/niri/.config/niri/config.kdl index 6f573ca..a5640d8 100644 --- a/niri/.config/niri/config.kdl +++ b/niri/.config/niri/config.kdl @@ -1,3 +1,6 @@ +// Material You / Material Design 3 colors, generated by matugen (see theme-switcher.sh / apply-colors.sh) +include optional=true "/home/seraphim/.cache/matugen/theme.kdl" + spawn-at-startup "xrdb" "-merge" "/home/seraphim/.Xresources" spawn-at-startup "vicinae" "server" spawn-at-startup "gentoo-pipewire-launcher" diff --git a/niri/.config/niri/theme-switcher.sh b/niri/.config/niri/theme-switcher.sh index 0ab25af..665aab8 100755 --- a/niri/.config/niri/theme-switcher.sh +++ b/niri/.config/niri/theme-switcher.sh @@ -9,6 +9,7 @@ LIGHT_BLUR_WALLPAPER="$HOME/Pictures/wallpapers/day-blur.jpg" DARK_BLUR_WALLPAPER="$HOME/Pictures/wallpapers/night-blur.jpg" STATE_FILE="/tmp/current_theme_state" +SCRIPT_DIR="$(cd "$(dirname "$(realpath "$0")")" && pwd)" while true; do HOUR=$(date +%H) @@ -24,23 +25,20 @@ while true; do if [ "$CURRENT_STATE" != "$TARGET_STATE" ]; then if [ "$TARGET_STATE" = "light" ]; then - wal -n -l -i "$LIGHT_WALLPAPER" - awww img "$LIGHT_WALLPAPER" + sh "$SCRIPT_DIR/apply-colors.sh" "$LIGHT_WALLPAPER" light awww -n backdrop img "$LIGHT_BLUR_WALLPAPER" # Сообщаем системе, что включилась светлая тема darkman set light else - wal -n -i "$DARK_WALLPAPER" - awww img "$DARK_WALLPAPER" + sh "$SCRIPT_DIR/apply-colors.sh" "$DARK_WALLPAPER" dark awww -n backdrop img "$DARK_BLUR_WALLPAPER" # Сообщаем системе, что включилась тёмная тема darkman set dark fi - killall -SIGUSR2 waybar - killall -USR1 foot + ln -sf "theme-${TARGET_STATE}.css" "$HOME/dotfiles-gentoo/waybar/.config/waybar/theme.css" echo "$TARGET_STATE" >"$STATE_FILE" fi |
