From 8b4dacfc2b0c0e3f1a506ace527796713bd37473 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20M=C3=BChl?= Date: Tue, 30 Sep 2025 10:39:22 +0200 Subject: [PATCH] Rewrite generate-wallpaper to be more resilient --- .../christopher@cobalt/config/wayland.nix | 22 ++++++- .../scripts/generate-wallpaper/default.nix | 58 +++++++++++++++++-- .../generate-wallpaper/generate-wallpaper | 20 ------- 3 files changed, 72 insertions(+), 28 deletions(-) delete mode 100755 packages/scripts/generate-wallpaper/generate-wallpaper diff --git a/homes/x86_64-linux/christopher@cobalt/config/wayland.nix b/homes/x86_64-linux/christopher@cobalt/config/wayland.nix index 69f0f1f..a990944 100644 --- a/homes/x86_64-linux/christopher@cobalt/config/wayland.nix +++ b/homes/x86_64-linux/christopher@cobalt/config/wayland.nix @@ -10,6 +10,7 @@ in { cliphist # Wayland clipboard hyprpicker # Color picker hyprpaper # Wallpaper utility + hyprlandPlugins.borders-plus-plus ]; services.hyprpaper = { @@ -46,13 +47,14 @@ in { # See https://wiki.hyprland.org/Configuring/Keywords/ for more exec-once = ibus-daemon -drxR - exec-once = hyprpaper & # Wallpaper util + # exec-once = hyprpaper & # Wallpaper util exec-once = swaync & # Notification center exec-once = udiskie # Automatic mounting of USBs - exec-once = sleep 2; ${pkgs._elements.generate-wallpaper}/bin/generate-wallpaper # exec-once = eval $(gnome-keyring-daemon --start --components=pkcs11,secrets,ssh) & + exec-once = ${pkgs._elements.generate-wallpaper}/bin/generate-wallpaper exec-once = eww daemon exec-once = eww open spraggins + exec-once = sleep 10; eww open spraggins # Open again after a while because the wallpaper will display on top once that is done exec-once = wl-paste --type text --watch cliphist store exec-once = wl-paste --type image --watch cliphist store @@ -109,7 +111,7 @@ in { decoration { # See https://wiki.hyprland.org/Configuring/Variables/ for more - rounding = 2 + rounding = 5 blur { enabled = true xray = true @@ -145,6 +147,20 @@ in { split-monitor-workspaces { count = 10 } + + borders-plus-plus { + add_borders = 3 + + col.border_1 = rgb(000000) + col.border_2 = rgba(5e81acaa) + col.border_3 = rgb(000000) + + border_size_1 = 1 + border_size_2 = 3 + border_size_3 = 1 + + natural_rounding = yes + } } dwindle { diff --git a/packages/scripts/generate-wallpaper/default.nix b/packages/scripts/generate-wallpaper/default.nix index c01cbee..15abdfe 100644 --- a/packages/scripts/generate-wallpaper/default.nix +++ b/packages/scripts/generate-wallpaper/default.nix @@ -1,5 +1,53 @@ -{pkgs, ...}: -pkgs.writeShellApplication { - name = "generate-wallpaper"; - text = builtins.readFile ./generate-wallpaper; -} +{ + pkgs, + stdenv, + ... +}: +with pkgs; let + themes = stdenv.mkDerivation { + name = "catppuccin-base16-json"; + + src = fetchFromGitHub { + owner = "catppuccin"; + repo = "base16"; + rev = "99aa911b29c9c7972f7e1d868b6242507efd508c"; + hash = "sha256-HHodDRrlcBVWGE3MN0i6UvUn30zY/JFEbgeUpnZG5C0="; + }; + + buildInputs = [yq]; + + # Take all yaml files and convert them to json. + installPhase = '' + mkdir -p $out + ls $src/base16 | sed 's/\.yaml$//' | xargs -I {} sh -c "yq '.' $src/base16/{}.yaml > $out/{}.json" + ''; + }; +in + writeShellApplication { + name = "generate-wallpaper"; + + runtimeInputs = [ + imagemagick + nodejs_24 + jq + ]; + + text = '' + # TODO: Do we want this configurable via an argument? + THEME="macchiato" + + THEME_JSON_PATH="${themes}/$THEME.json" + SCHEME_NAME=$(jq -r '.scheme' "$THEME_JSON_PATH") + SCHEME_NAME_LWR=$(echo "$SCHEME_NAME" | tr '[:upper:]' '[:lower:]' | tr ' ' '-') + + WALLPAPER_ROOT="/tmp/wallpaper" + WALLPAPER_FILE="$WALLPAPER_ROOT/$SCHEME_NAME/Circuits wallpaper/themer-$SCHEME_NAME_LWR-dark" + WALLPAPER_DIR=$(dirname "$WALLPAPER_FILE") + + npx themer -t wallpaper-circuits -o "$WALLPAPER_ROOT" --color-set "$THEME_JSON_PATH" -s 3840x1080 -s 1080x1920 + find "$WALLPAPER_DIR" -type f -iname '*.svg' | sed 'p;s/\.svg/\.png/' | sed 's/.*/"&"/' | xargs -n2 magick + + hyprctl hyprpaper reload DP-2,"$WALLPAPER_FILE-3840x1080.png" + hyprctl hyprpaper reload DP-4,"$WALLPAPER_FILE-1080x1920.png" + ''; + } diff --git a/packages/scripts/generate-wallpaper/generate-wallpaper b/packages/scripts/generate-wallpaper/generate-wallpaper deleted file mode 100755 index be4ce62..0000000 --- a/packages/scripts/generate-wallpaper/generate-wallpaper +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash - -THEME_FILE_YAML="/tmp/base16.yml" -THEME_FILE_JSON="/tmp/base16.json" - -wget https://raw.githubusercontent.com/catppuccin/base16/refs/heads/main/base16/macchiato.yaml -O "$THEME_FILE_YAML" -yq '.' "$THEME_FILE_YAML" > "$THEME_FILE_JSON" - -THEME_NAME=$(jq -r '.scheme' "$THEME_FILE_JSON") -THEME_NAME_LWR=$(echo "$THEME_NAME" | tr '[:upper:]' '[:lower:]' | tr ' ' '-') - -WALLPAPER_BASE="/tmp/wallpaper" -WALLPAPER_PATH="$WALLPAPER_BASE/$THEME_NAME/Circuits wallpaper/themer-$THEME_NAME_LWR-dark" -WALLPAPER_DIR=$(dirname "$WALLPAPER_PATH") - -npx themer -t wallpaper-circuits -o "$WALLPAPER_BASE" --color-set "$THEME_FILE_JSON" -s 3840x1080 -s 1080x1920 -find "$WALLPAPER_DIR" -type f -iname '*.svg' | sed 'p;s/\.svg/\.png/' | sed 's/.*/"&"/' | xargs -n2 magick - -hyprctl hyprpaper reload DP-2,"$WALLPAPER_PATH-3840x1080.png" -hyprctl hyprpaper reload DP-4,"$WALLPAPER_PATH-1080x1920.png"