From 451f28a022f2e6849c688f80bf0fd2ef82b69820 Mon Sep 17 00:00:00 2001 From: zhenyan121 <3367366583@qq.com> Date: Fri, 3 Apr 2026 17:01:01 +0800 Subject: [PATCH] feat: add overview background --- .config/niri/config.kdl | 6 +++ .config/waypaper/config.ini | 13 ++++++- .config/waypaper/scripts/set_wallpaper.sh | 46 +++++++++++++++++++++++ 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100755 .config/waypaper/scripts/set_wallpaper.sh diff --git a/.config/niri/config.kdl b/.config/niri/config.kdl index 89ef2dc..77c9f7b 100644 --- a/.config/niri/config.kdl +++ b/.config/niri/config.kdl @@ -294,6 +294,7 @@ spawn-at-startup "waybar" spawn-at-startup "/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1" spawn-at-startup "mako" spawn-at-startup "awww-daemon" +spawn-at-startup "awww-daemon" "-n" "overview" spawn-at-startup "nm-applet" spawn-sh-at-startup "xrdb -merge /home/zhenyan121/.Xresources" spawn-sh-at-startup "clipse --listen" @@ -385,6 +386,11 @@ window-rule { draw-border-with-background false } +layer-rule{ + match namespace="awww-daemonoverview" + place-within-backdrop true +} + binds { // Keys consist of modifiers separated by + signs, followed by an XKB key name // in the end. To find an XKB name for a particular key, you may use a program diff --git a/.config/waypaper/config.ini b/.config/waypaper/config.ini index 6358765..c3ef9a6 100644 --- a/.config/waypaper/config.ini +++ b/.config/waypaper/config.ini @@ -14,7 +14,7 @@ show_hidden = False show_gifs_only = False zen_mode = True number_of_columns = 3 -post_command = matugen image $wallpaper --source-color-index 0 +post_command = $HOME/.config/waypaper/scripts/set_wallpaper.sh $wallpaper swww_transition_type = any swww_transition_step = 63 swww_transition_angle = 0 @@ -25,4 +25,15 @@ mpvpaper_options = use_xdg_state = False stylesheet = ~/.config/waypaper/style.css keybindings = ~/.config/waypaper/keybindings.ini +wallpaperengine_folder = ~/.steam/root/steamapps/workshop/content/431960 +linux_wallpaperengine_clamp = none +linux_wallpaperengine_volume = 15 +linux_wallpaperengine_silent = False +linux_wallpaperengine_noautomute = False +linux_wallpaperengine_no_audio_processing = False +linux_wallpaperengine_fps = 30 +linux_wallpaperengine_disable_particles = True +linux_wallpaperengine_disable_mouse = False +linux_wallpaperengine_disable_parallax = False +linux_wallpaperengine_no_fullscreen_pause = False diff --git a/.config/waypaper/scripts/set_wallpaper.sh b/.config/waypaper/scripts/set_wallpaper.sh new file mode 100755 index 0000000..39ea17f --- /dev/null +++ b/.config/waypaper/scripts/set_wallpaper.sh @@ -0,0 +1,46 @@ +#!/bin/sh + +set -e + +# 缓存目录 +CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/wallpaper_overview" +mkdir -p "$CACHE_DIR" + +# 检查参数 +if [ -z "$1" ]; then + echo "用法: $0 <壁纸文件路径>" + exit 1 +fi + +WALLPAPER="$1" + +# 1. 生成颜色文件(每次都执行) +matugen image "$WALLPAPER" --source-color-index 0 + +# 2. 基于原壁纸路径生成唯一的缓存文件名(md5 哈希) +HASH=$(echo -n "$WALLPAPER" | md5sum | cut -d' ' -f1) +CACHE_FILE="$CACHE_DIR/${HASH}.png" + +# 3. 检查缓存是否存在 +if [ -f "$CACHE_FILE" ]; then + echo "使用已有缓存图片: $CACHE_FILE" + # 更新文件的修改时间,表示“最近使用过” + touch "$CACHE_FILE" +else + echo "未找到缓存,正在生成模糊暗色壁纸..." + magick "$WALLPAPER" -blur 0x8 -fill black -colorize 30% "$CACHE_FILE" +fi + +# 4. 设置 overview 壁纸,关闭动画 +awww img "$CACHE_FILE" -n overview --transition-type none + +# 5. 缓存清理:只保留最新的 10 张(按修改时间,最近使用的会被保留) +cd "$CACHE_DIR" || exit 1 +# 列出所有 .png 文件,按修改时间排序(最新的在前) +# 保留前 10 个,删除第 11 个及之后的 +ls -t *.png 2>/dev/null | tail -n +11 | while read -r oldfile; do + rm -f "$oldfile" + echo "已删除旧缓存: $oldfile" +done + +echo "完成。当前缓存目录有 $(ls -1 *.png 2>/dev/null | wc -l) 张图片(最多保留 10 张)"