From a3123141e95c309d9d40c8b76b5240a1b1d6cf44 Mon Sep 17 00:00:00 2001 From: Price Hiller Date: Fri, 11 Aug 2023 00:25:35 -0500 Subject: [PATCH] fix(hypr): ensure wallpapers get set --- .../.config/hypr/scripts/init-wallpapers.bash | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/dots/.config/hypr/scripts/init-wallpapers.bash b/dots/.config/hypr/scripts/init-wallpapers.bash index ab54a41c..14749b14 100755 --- a/dots/.config/hypr/scripts/init-wallpapers.bash +++ b/dots/.config/hypr/scripts/init-wallpapers.bash @@ -1,12 +1,31 @@ #!/usr/bin/env bash +set -e log() { printf "%s\n" "${*}" systemd-cat -t init-wallpapers -p info echo "${*}" } +get-monitor-wallpaper() { + local mon + mon="$(grep "^${1}:.*" <<<"$(swww query)")" + printf "%s" "${mon##* }" +} + +set-wallpaper() { + local monitor="${1}" + local wallpaper_path="${2}" + + until [[ "$(get-monitor-wallpaper "${monitor}")" == "${wallpaper_path}" ]]; do + log "Setting wallpaper for monitor: '${monitor}' to '${wallpaper_path}'" + swww img -t none "${wallpaper_path}" -o "${monitor}" + log "Set wallpaper for monitor: '${monitor}' to '${wallpaper_path}'" + done +} + set-wallpapers() { ### Set default wallpaper ### + local default_wallpaper="${HOME}/.dot_files/dots/.local/share/wallpapers/Nebula.jpg" # Monitors to not set a default for, to be set later down the script local excluded_monitors=("eDP-1") @@ -16,23 +35,23 @@ set-wallpapers() { local set_mon_wallpaper=true for excluded_mon in "${excluded_monitors[@]}"; do if [[ "${excluded_mon}" == "${monitor}" ]]; then - log "Not setting default wallpaper for '${monitor}' as it is excluded" set_mon_wallpaper=false break fi done if "${set_mon_wallpaper}"; then - log "Set default wallpaper for monitor: '${monitor}'" - swww img -t none "${XDG_DATA_HOME}/wallpapers/Nebula.jpg" -o "${monitor}" + set-wallpaper "${monitor}" "${default_wallpaper}" fi done < <(hyprctl monitors -j | jq -r '.[].name') ### Set any non defaults ### - swww img -t none ~/.local/share/wallpapers/Industrial-Shaded.png -o eDP-1 + set-wallpaper "eDP-1" "${HOME}/.dot_files/dots/.local/share/wallpapers/Industrial-Shaded.png" } main() { - swww kill; swww init && log "Initialized swww daemon" + if swww init >/dev/null 2>&1; then + log "Initialized swww daemon" + fi set-wallpapers }