aboutsummaryrefslogtreecommitdiffstats
path: root/config/hypr/scripts/WallustSwww.sh
diff options
context:
space:
mode:
Diffstat (limited to 'config/hypr/scripts/WallustSwww.sh')
-rwxr-xr-xconfig/hypr/scripts/WallustSwww.sh158
1 files changed, 141 insertions, 17 deletions
diff --git a/config/hypr/scripts/WallustSwww.sh b/config/hypr/scripts/WallustSwww.sh
index 9df3ed61..3472d519 100755
--- a/config/hypr/scripts/WallustSwww.sh
+++ b/config/hypr/scripts/WallustSwww.sh
@@ -9,6 +9,73 @@
# Usage: WallustSwww.sh [absolute_path_to_wallpaper]
set -euo pipefail
+# Wallust v3/v4 compatibility
+wallust_args=()
+wallust_kitty_args=()
+# shellcheck source=/dev/null
+if [ -f "$HOME/.config/hypr/scripts/WallustConfig.sh" ]; then
+ . "$HOME/.config/hypr/scripts/WallustConfig.sh"
+fi
+have_notify() { command -v notify-send >/dev/null 2>&1; }
+wallust_log="${XDG_CACHE_HOME:-$HOME/.cache}/wallust/wallust-swww.log"
+mkdir -p "$(dirname "$wallust_log")"
+capture_current_layout() {
+ if command -v jq >/dev/null 2>&1; then
+ hyprctl -j getoption general:layout 2>/dev/null | jq -r '.str // empty'
+ else
+ hyprctl getoption general:layout 2>/dev/null | awk 'NR==1 {print $2}'
+ fi
+}
+restore_layout_after_reload() {
+ local layout="$1"
+ [ -n "$layout" ] || return 0
+
+ if [ -x "$HOME/.config/hypr/scripts/ChangeLayout.sh" ]; then
+ if "$HOME/.config/hypr/scripts/ChangeLayout.sh" --no-notify "$layout" >/dev/null 2>&1; then
+ return 0
+ fi
+ fi
+
+ hyprctl keyword general:layout "$layout" >/dev/null 2>&1 || true
+}
+reload_hypr_preserve_layout() {
+ command -v hyprctl >/dev/null 2>&1 || return 0
+
+ local active_layout
+ active_layout="$(capture_current_layout || true)"
+
+ hyprctl reload config-only >/dev/null 2>&1 || true
+ sleep 0.1
+ restore_layout_after_reload "$active_layout"
+}
+ensure_wallust_waybar_style() {
+ local waybar_style="$HOME/.config/waybar/style.css"
+ local colors_file="$HOME/.config/waybar/wallust/colors-waybar.css"
+ local styles_dir="$HOME/.config/waybar/style"
+ [ -f "$colors_file" ] || return 0
+ if [ -f "$waybar_style" ] && grep -q 'colors-waybar.css' "$waybar_style"; then
+ return 0
+ fi
+ local candidates=(
+ "Wallust-Chroma-Fusion.css"
+ "Wallust-ML4W-modern.css"
+ "Wallust-Colored.css"
+ "Wallust-Box-type.css"
+ "Wallust-Simple.css"
+ )
+ for candidate in "${candidates[@]}"; do
+ if [ -f "$styles_dir/$candidate" ]; then
+ ln -sf "$styles_dir/$candidate" "$waybar_style"
+ break
+ fi
+ done
+}
+reload_running_cava_colors() {
+ # CAVA supports SIGUSR2 to reload colors without full audio reinitialization.
+ if pgrep -x cava >/dev/null 2>&1; then
+ pkill -USR2 -x cava >/dev/null 2>&1 || true
+ fi
+}
# Inputs and paths
passed_path="${1:-}"
@@ -124,13 +191,23 @@ wait_for_templates() {
# Run wallust (silent) to regenerate templates defined in ~/.config/wallust/wallust.toml
# -s is used in this repo to keep things quiet and avoid extra prompts
start_ts=$(date +%s)
-wallust run -s "$wallpaper_path" || true
+if ! wallust "${wallust_args[@]}" run -s "$wallpaper_path" >"$wallust_log" 2>&1; then
+ have_notify && notify-send -u critical -a WallustSwww \
+ "Wallust failed" "See: $wallust_log"
+ exit 1
+fi
wallust_targets=(
"$HOME/.config/waybar/wallust/colors-waybar.css"
"$HOME/.config/rofi/wallust/colors-rofi.rasi"
"$HOME/.config/hypr/wallust/wallust-hyprland.conf"
)
-wait_for_templates "$start_ts" "${wallust_targets[@]}" || true
+if ! wait_for_templates "$start_ts" "${wallust_targets[@]}"; then
+ have_notify && notify-send -u critical -a WallustSwww \
+ "Wallust templates not updated" "See: $wallust_log"
+ exit 1
+fi
+ensure_wallust_waybar_style
+reload_running_cava_colors
# Normalize Rofi selection colors to a brighter accent and readable foreground
rofi_colors="$HOME/.config/rofi/wallust/colors-rofi.rasi"
@@ -153,28 +230,78 @@ fi
# Run kitty-only wallust config to keep terminal palette separate
run_wallust_with_config() {
local cfg="$1"
- if wallust run --help 2>&1 | grep -q -E '(^|[[:space:]])-c([,[:space:]]|$)|--config'; then
- wallust run -s -c "$cfg" "$wallpaper_path" || true
- else
- WALLUST_CONFIG="$cfg" wallust run -s "$wallpaper_path" || true
+ # Wallust v4: prefer config-file flag via WallustConfig.sh
+ if [ "${#wallust_kitty_args[@]}" -gt 0 ]; then
+ wallust "${wallust_kitty_args[@]}" run -s "$wallpaper_path" || true
+ return
fi
+ # Wallust v3+: prefer config-file flag when available.
+ # NOTE: Do not use -c here; on wallust 3.x it means colorspace, not config file.
+ if wallust run --help 2>&1 | grep -q -E -- '(^|[[:space:]])-C([,[:space:]]|$)|--config-file'; then
+ wallust run -s -C "$cfg" "$wallpaper_path" || true
+ return
+ fi
+ # Legacy fallback for builds that still honor env-based config override.
+ WALLUST_CONFIG="$cfg" wallust run -s "$wallpaper_path" || true
+}
+wallust_hypr_colors="$HOME/.config/hypr/wallust/wallust-hyprland.conf"
+extract_wallust_hex() {
+ local key="$1"
+ awk -v key="$key" '
+ $1 == "$" key && $2 == "=" {
+ if (match($3, /^rgb\(([0-9A-Fa-f]{6})\)$/, m)) {
+ print toupper(m[1])
+ exit
+ }
+ }
+ ' "$wallust_hypr_colors"
+}
+
+apply_hypr_border_fallback() {
+ [ -s "$wallust_hypr_colors" ] || return 0
+ local color12 color10 color15 color0
+ color12="$(extract_wallust_hex color12)"
+ color10="$(extract_wallust_hex color10)"
+ color15="$(extract_wallust_hex color15)"
+ color0="$(extract_wallust_hex color0)"
+
+ [ -n "$color12" ] && hyprctl keyword general:col.active_border "rgb($color12)" >/dev/null 2>&1 || true
+ [ -n "$color10" ] && hyprctl keyword general:col.inactive_border "rgb($color10)" >/dev/null 2>&1 || true
+ [ -n "$color12" ] && hyprctl keyword decoration:shadow:color "rgb($color12)" >/dev/null 2>&1 || true
+ [ -n "$color10" ] && hyprctl keyword decoration:shadow:color_inactive "rgb($color10)" >/dev/null 2>&1 || true
+ [ -n "$color15" ] && hyprctl keyword group:col.border_active "rgb($color15)" >/dev/null 2>&1 || true
+ [ -n "$color0" ] && hyprctl keyword group:groupbar:col.active "rgb($color0)" >/dev/null 2>&1 || true
+}
+
+apply_hypr_gap_fallback() {
+ local decorations_lua="$HOME/.config/hypr/UserConfigs/user_decorations.lua"
+ [ -s "$decorations_lua" ] || return 0
+ local gaps_in gaps_out border_size
+ gaps_in="$(sed -n 's/^[[:space:]]*gaps_in[[:space:]]*=[[:space:]]*\([0-9]\+\).*/\1/p' "$decorations_lua" | head -n1)"
+ gaps_out="$(sed -n 's/^[[:space:]]*gaps_out[[:space:]]*=[[:space:]]*\([0-9]\+\).*/\1/p' "$decorations_lua" | head -n1)"
+ border_size="$(sed -n 's/^[[:space:]]*border_size[[:space:]]*=[[:space:]]*\([0-9]\+\).*/\1/p' "$decorations_lua" | head -n1)"
+
+ [ -n "$gaps_in" ] && hyprctl keyword general:gaps_in "$gaps_in" >/dev/null 2>&1 || true
+ [ -n "$gaps_out" ] && hyprctl keyword general:gaps_out "$gaps_out" >/dev/null 2>&1 || true
+ [ -n "$border_size" ] && hyprctl keyword general:border_size "$border_size" >/dev/null 2>&1 || true
}
+# Apply Hyprland updates immediately to avoid delayed border/gap changes.
+reload_hypr_preserve_layout
+
kitty_cfg="$HOME/.config/wallust/wallust-kitty.toml"
+if [ "${#wallust_kitty_args[@]}" -gt 0 ]; then
+ kitty_cfg="$HOME/.config/wallust/wallust-kitty-v4.toml"
+fi
(
if [ -f "$kitty_cfg" ]; then
- kitty_ts=$(date +%s)
run_wallust_with_config "$kitty_cfg"
- wait_for_templates "$kitty_ts" "$HOME/.config/kitty/kitty-themes/01-Wallust.conf" || true
fi
- # Reload kitty colors when wallpaper-based theme is active
+ # Reload kitty colors when wallpaper-based theme is active.
+ # Use SIGUSR1 directly to avoid extra latency from kitty remote-control calls.
kitty_wallust_theme="$HOME/.config/kitty/kitty-themes/01-Wallust.conf"
if [ -s "$kitty_wallust_theme" ]; then
- if command -v kitty >/dev/null 2>&1; then
- kitty @ load-config >/dev/null 2>&1 || true
- kitty @ set-colors --all --configured "$kitty_wallust_theme" >/dev/null 2>&1 || true
- fi
if pidof kitty >/dev/null 2>&1; then
for pid in $(pidof kitty); do
kill -SIGUSR1 "$pid" 2>/dev/null || true
@@ -195,8 +322,5 @@ kitty_cfg="$HOME/.config/wallust/wallust-kitty.toml"
if pidof ghostty >/dev/null; then
for pid in $(pidof ghostty); do kill -SIGUSR2 "$pid" 2>/dev/null || true; done
fi
- # Reload Hyprland so new border colors from wallust-hyprland.conf take effect
- if command -v hyprctl >/dev/null 2>&1; then
- hyprctl reload >/dev/null 2>&1 || true
- fi
+ # Hyprland reload/keyword updates are applied above to avoid delayed color/gap updates.
) >/dev/null 2>&1 &
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage