This commit is contained in:
2026-01-24 23:16:59 +01:00
parent 4f384a2c79
commit b9ed4072f2
4 changed files with 56 additions and 49 deletions
+2 -2
View File
@@ -19,8 +19,8 @@ environment {
WLR_NO_HARDWARE_CURSORS "1" WLR_NO_HARDWARE_CURSORS "1"
// Nvidia Prime // Nvidia Prime
// __NV_PRIME_RENDER_OFFLOAD "1"; __NV_PRIME_RENDER_OFFLOAD "1";
// __VK_LAYER_NV_optimus "NVIDIA_only" __VK_LAYER_NV_optimus "NVIDIA_only"
// Fix Swing // Fix Swing
_JAVA_AWT_WM_NONREPARENTING "1" _JAVA_AWT_WM_NONREPARENTING "1"
+43 -37
View File
@@ -11,12 +11,13 @@
# - change-colortheme (from scripts/change-colortheme) # - change-colortheme (from scripts/change-colortheme)
# - flock (usually part of util-linux) # - flock (usually part of util-linux)
set -euo pipefail
trap 'echo $LINENO: $BASH_COMMAND' ERR
# Lock # Lock
exec {LOCK_FD}>/tmp/"$(basename "$0")".lock || { exec {LOCK_FD}>/tmp/"$(basename "$0")".lock
echo "Failed to open lock file"
exit 1
}
flock -n "$LOCK_FD" || { flock -n "$LOCK_FD" || {
echo "Another instance is running. Exiting." echo "Another instance is running. Exiting."
@@ -26,7 +27,7 @@ flock -n "$LOCK_FD" || {
# Open a file selection dialog if no argument is provided # Open a file selection dialog if no argument is provided
if [ -z "$1" ]; then if [ -z "${1-}" ]; then
image=$(zenity --file-selection --title="Open File" --file-filter="*.jpg *.jpeg *.png *.webp *.bmp *.jfif *.tiff *.avif *.heic *.heif") image=$(zenity --file-selection --title="Open File" --file-filter="*.jpg *.jpeg *.png *.webp *.bmp *.jfif *.tiff *.avif *.heic *.heif")
else else
image="$1" image="$1"
@@ -37,8 +38,8 @@ fi
# Obtain screen resolution # Obtain screen resolution
screen_width=$2 screen_width=${2-}
screen_height=$3 screen_height=${3-}
[ -z "$screen_width" ] && { [ -z "$screen_width" ] && {
if [ "$XDG_CURRENT_DESKTOP" = "Hyprland" ]; then if [ "$XDG_CURRENT_DESKTOP" = "Hyprland" ]; then
@@ -56,8 +57,9 @@ screen_height=$3
fi fi
} }
[ -z "$screen_width" ] && screen_width=2560 ## Default to 2k
[ -z "$screen_height" ] && screen_height=1440 screen_width=${screen_width:-2560}
screen_height=${screen_height:-1440}
# $HOME/.config/wallpaper-chooser/config.json: # $HOME/.config/wallpaper-chooser/config.json:
# ```json # ```json
@@ -71,37 +73,43 @@ touch "$image" 2>/dev/null || true # ignore errors
# Copy image to local wallpaper directory # Copy image to local wallpaper directory
## Format of current and cached wallpaper
wallpaper_ext="png" wallpaper_ext="png"
## Generate a random name for the current wallpaper
set +o pipefail # SIGPIPE is expected here
random_name=$(tr -dc 'a-zA-Z0-9' </dev/urandom | head -c 16) random_name=$(tr -dc 'a-zA-Z0-9' </dev/urandom | head -c 16)
set -o pipefail
## Directory to store current wallpaper
current_dir="$HOME/.local/share/wallpaper/current" current_dir="$HOME/.local/share/wallpaper/current"
## Path to current wallpaper image
wallpaper_image="$current_dir/wallpaper-${random_name}.${wallpaper_ext}" wallpaper_image="$current_dir/wallpaper-${random_name}.${wallpaper_ext}"
mkdir -p "$current_dir" || { mkdir -p "$current_dir"
echo "Could not create directory $current_dir"
exit 1
}
temp_img=$(mktemp --suffix=."$wallpaper_ext") || exit 1 ## Batch copy using a temporary file to avoid incomplete file being used
temp_img=$(mktemp --suffix=."$wallpaper_ext")
trap 'rm -f "$temp_img"' EXIT trap 'rm -f "$temp_img"' EXIT
magick "$image" -resize "${screen_width}x${screen_height}^" -gravity center -extent "${screen_width}x${screen_height}" "$temp_img" || { magick "$image" -resize "${screen_width}x${screen_height}^" -gravity center -extent "${screen_width}x${screen_height}" "$temp_img"
echo "Could not resize and crop image" cp "$temp_img" "$wallpaper_image"
exit 1
} ## Generate hash for caching,
cp "$temp_img" "$wallpaper_image" || exit 1 ## based on content of the source image and resolution of the resized image
hash="$(md5sum "$image" | awk '{print $1}')-${screen_width}x${screen_height}" hash="$(md5sum "$image" | awk '{print $1}')-${screen_width}x${screen_height}"
# Clean up old wallpapers # Clean up old wallpapers in the same directory of current wallpaper.
# Only keep the newly added one so the wallpaper-daemon can pick it up directly
find "$current_dir" -type f -name "wallpaper-*" ! -name "$(basename "$wallpaper_image")" -delete find "$current_dir" -type f -name "wallpaper-*" ! -name "$(basename "$wallpaper_image")" -delete
# Generate blurred wallpaper # Generate blurred wallpaper
## Similarly, store blurred version of current wallpaper in separate directory
blur_dir="$HOME/.local/share/wallpaper/blurred" blur_dir="$HOME/.local/share/wallpaper/blurred"
## Directory to cache blurred wallpapers, so that we don't need to regenerate
## them every time when switching wallpapers. This makes it possible to have
## an auto-played slideshow with blurred wallpapers without noticeable delay.
blur_cache_dir="$HOME/.local/share/wallpaper/blurred-cache" blur_cache_dir="$HOME/.local/share/wallpaper/blurred-cache"
mkdir -p "$blur_dir" "$blur_cache_dir" || { mkdir -p "$blur_dir" "$blur_cache_dir"
echo "Could not create cache directory"
exit 1
}
blurred_image="$blur_dir/blurred-${random_name}.${wallpaper_ext}" blurred_image="$blur_dir/blurred-${random_name}.${wallpaper_ext}"
blurred_cache_image="$blur_cache_dir/${hash}.${wallpaper_ext}" blurred_cache_image="$blur_cache_dir/${hash}.${wallpaper_ext}"
@@ -109,6 +117,14 @@ blurred_cache_image="$blur_cache_dir/${hash}.${wallpaper_ext}"
( (
# notify-send -a "change-wallpaper" "Generating Blurred Wallpaper" "This may take a few seconds..." # notify-send -a "change-wallpaper" "Generating Blurred Wallpaper" "This may take a few seconds..."
function apply_blured {
find "$blur_dir" -type f -name "blurred-*" ! -name "$(basename "$blurred_image")" -delete
if [ "$XDG_CURRENT_DESKTOP" = "niri" ]; then
swww img -n backdrop "$blurred_image" --transition-type fade --transition-duration 2 >/dev/null 2>/dev/null
fi
notify-send -a "change-wallpaper" "Blurred Wallpaper Applied" "$blurred_image" -i "$blurred_image"
}
### Check if cached blurred image exists ### Check if cached blurred image exists
if [ -f "$blurred_cache_image" ]; then if [ -f "$blurred_cache_image" ]; then
# sleep 1 # Some ugly workaround # sleep 1 # Some ugly workaround
@@ -116,11 +132,7 @@ blurred_cache_image="$blur_cache_dir/${hash}.${wallpaper_ext}"
echo "Could not copy cached blurred image" echo "Could not copy cached blurred image"
# exit 1 # Non-critical error # exit 1 # Non-critical error
else else
find "$blur_dir" -type f -name "blurred-*" ! -name "$(basename "$blurred_image")" -delete apply_blured
if [ "$XDG_CURRENT_DESKTOP" = "niri" ]; then
swww img -n backdrop "$blurred_image" --transition-type fade --transition-duration 2 >/dev/null 2>/dev/null
fi
notify-send -a "change-wallpaper" "Blurred Wallpaper From Cache" "$blurred_image" -i "$blurred_image"
exit 0 exit 0
fi fi
fi fi
@@ -133,7 +145,7 @@ blurred_cache_image="$blur_cache_dir/${hash}.${wallpaper_ext}"
printf "%.2f", s printf "%.2f", s
}') }')
### use a temporary file to avoid incomplete file being used ### Batch processing using a temporary file to avoid incomplete file being used
temp_blurred=$(mktemp --suffix=."$wallpaper_ext") || exit 1 temp_blurred=$(mktemp --suffix=."$wallpaper_ext") || exit 1
trap 'rm -f "${temp_blurred}"' EXIT trap 'rm -f "${temp_blurred}"' EXIT
magick "$wallpaper_image" -blur 0x"$sigma" "$temp_blurred" || { magick "$wallpaper_image" -blur 0x"$sigma" "$temp_blurred" || {
@@ -146,18 +158,12 @@ blurred_cache_image="$blur_cache_dir/${hash}.${wallpaper_ext}"
exit 1 exit 1
} }
find "$blur_dir" -type f -name "blurred-*" ! -name "$(basename "$blurred_image")" -delete
cp -f "$blurred_image" "$blurred_cache_image" || { cp -f "$blurred_image" "$blurred_cache_image" || {
echo "Could not cache blurred image" echo "Could not cache blurred image"
# exit 1 # Non-critical error # exit 1 # Non-critical error
} }
if [ "$XDG_CURRENT_DESKTOP" = "niri" ]; then apply_blured
swww img -n backdrop "$blurred_image" --transition-type fade --transition-duration 2 >/dev/null 2>/dev/null
fi
notify-send -a "change-wallpaper" "Blurred Wallpaper Generated" "$blurred_image" -i "$blurred_image"
) & ) &
# Apply wallpaper # Apply wallpaper
+10 -9
View File
@@ -73,9 +73,10 @@
| 简写 | 全称 | 中文名称 | 说明 | | 简写 | 全称 | 中文名称 | 说明 |
| --------------- | --------------------------------------------------------------- | ------------------------------ | ---------------------------------------------------------------------------------------------------- | | --------------- | --------------------------------------------------------------- | ------------------------------ | ---------------------------------------------------------------------------------------------------- |
| rDNS | Reverse DNS | 反向域名解析 | 将 IP 地址映射回域名的特殊 DNS 记录. 多个 ip 可以同时映射到同一个域名, 但一个 ip 只能映射到一个域名. | | rDNS | Reverse DNS | 反向域名解析 | 将 IP 地址映射回域名的特殊 DNS 记录. 多个 ip 可以同时映射到同一个域名, 但一个 ip 只能映射到一个域名. |
| PTR | Pointer Record | 指针记录 | rDNS 使用的 DNS 记录类型. |
| SPF | Sender Policy Framework | 发件人策略框架 | 用于防止伪造发件人的技术. | | SPF | Sender Policy Framework | 发件人策略框架 | 用于防止伪造发件人的技术. |
| DKIM | DomainKeys Identified Mail | 域名密钥识别邮件 | 用于验证邮件的完整性和真实性的技术. | | DKIM | DomainKeys Identified Mail | 域名密钥识别邮件 | 用于验证邮件的完整性和真实性的技术. |
| DMARC | Domain-based Message Authentication, Reporting, and Conformance | 基于域的消息认证, 报告和一致性 | 用于指定邮件在目标服务的处理策略. | | DMARC | Domain-based Message Authentication, Reporting, and Conformance | 基于域的消息认证, 报告和一致性 | 用于指定邮件在目标服务的处理策略. |
| DMARC Alignment | DMARC Alignment | DMARC 对齐 | 用于确保发件人域名与 SPF 和 DKIM 认证域名一致的策略. | | DMARC Alignment | DMARC Alignment | DMARC 对齐 | 用于确保发件人域名与 SPF 和 DKIM 认证域名一致的策略. |
| MTA-STS | Mail Transfer Agent Strict Transport Security | 邮件传输代理严格传输安全 | 用于防止中间人攻击的技术. | | MTA-STS | Mail Transfer Agent Strict Transport Security | 邮件传输代理严格传输安全 | 用于防止中间人攻击的技术. |
| TLS-RPT | Transport Layer Security Reporting | 传输层安全报告 | 一方向另一方反馈 TLS 相关报告的方式. | | TLS-RPT | Transport Layer Security Reporting | 传输层安全报告 | 一方向另一方反馈 TLS 相关报告的方式. |
@@ -84,13 +85,13 @@
- 邮件数据 - 邮件数据
| 名称 | 中文名称 | 说明 | | 名称 | 中文名称 | 说明 |
| ------------------ | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | -------------- | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Envelope From | 信封发件人 | 邮件传输过程中使用的发件人地址. 通常在接受到的邮件头部中以 `Return-Path` 字段显示. | | Envelope From | 信封发件人 | 邮件传输过程中使用的发件人地址. 通常在接受到的邮件头部中以 `Return-Path` 字段显示. |
| Header From / From | 邮件头部发件人 | 邮件头部中显示的发件人地址, 也是在邮件客户端中能清晰看到的最醒目的发件人地址. | | (Header) From | 邮件头部发件人 | 邮件中显示的发件人地址, 也是在邮件客户端中能清晰看到的最醒目的发件人地址. |
| Return-Path | 退信路径 | 邮件头部中的一个字段, 用于指定邮件的回执地址, 通常由接受方 MTA 根据 Envelope sender 生成. | | Return-Path | 退信路径 | 邮件头部中的一个字段, 用于指定邮件的回执地址, 通常由接受方 MTA 根据 Envelope sender 生成. |
| DKIM-Signature | DKIM 签名 | 邮件头部中的一个字段, 包含用于验证邮件完整性和真实性的签名信息. | | DKIM-Signature | DKIM 签名 | 邮件头部中的一个字段, 包含用于验证邮件完整性和真实性的签名信息. |
| Content-Type | 内容类型 | 邮件头部中的一个字段, 用于指定邮件内容的格式和编码方式. 文本为主的邮件通常使用 `text/plain; charset="UTF-8"``text/html; charset="UTF-8"`, 二者在收件方的垃圾邮件过滤策略中可能会有不同的检测标准和权重. | | Content-Type | 内容类型 | 邮件头部中的一个字段, 用于指定邮件内容的格式和编码方式. 文本为主的邮件通常使用 `text/plain; charset="UTF-8"``text/html; charset="UTF-8"`, 二者在收件方的垃圾邮件过滤策略中可能会有不同的检测标准和权重. |
- 反垃圾与声誉 - 反垃圾与声誉
@@ -311,9 +312,9 @@ services:
ports: ports:
- '25:25' # SMTP - '25:25' # SMTP
- '143:143' # IMAP - '143:143' # IMAP
- '993:993' # IMAPS
- '587:587' # STARTTLS - '587:587' # STARTTLS
- '465:465' # SMTPS - '465:465' # SMTPS
- '993:993' # IMAPS
- '127.0.0.1:11334:11334' # Raspamd Web UI - '127.0.0.1:11334:11334' # Raspamd Web UI
environment: environment:
- DMS_DEBUG=0 - DMS_DEBUG=0