diff options
| author | Don Williams <don.e.williams@gmail.com> | 2025-09-20 13:44:10 -0400 |
|---|---|---|
| committer | Don Williams <don.e.williams@gmail.com> | 2025-09-20 13:44:10 -0400 |
| commit | 3da2f5e614c796372c76967afbb41a6ae5d5a41d (patch) | |
| tree | 25672fcf1ffe5c4b4b5e9dc5ea2d83269c0590e4 /config/hypr | |
| parent | 88f1b4d4ebbcdb58daecbbee2c0cdab791366452 (diff) | |
fix(sddm): set Backgrounds/default as primary and update fallbacks; detect themes dir (incl. NixOS) and skip prompt on read-only paths
- Prefer Backgrounds/default for simple_sddm_2; update default.jpg/png if present
- Detect SDDM themes dir under /usr/share and /run/current-system
- Avoid prompting when theme is missing or Backgrounds is not writable (e.g., NixOS)
- Skip runtime changes on NixOS since SDDM isn’t used in that config
Diffstat (limited to 'config/hypr')
| -rwxr-xr-x | config/hypr/UserScripts/WallpaperEffects.sh | 58 | ||||
| -rwxr-xr-x | config/hypr/UserScripts/WallpaperSelect.sh | 22 | ||||
| -rw-r--r-- | config/hypr/scripts/sddm_wallpaper.sh | 23 |
3 files changed, 72 insertions, 31 deletions
diff --git a/config/hypr/UserScripts/WallpaperEffects.sh b/config/hypr/UserScripts/WallpaperEffects.sh index 2ba58d0c..ac8fc0e8 100755 --- a/config/hypr/UserScripts/WallpaperEffects.sh +++ b/config/hypr/UserScripts/WallpaperEffects.sh @@ -108,31 +108,41 @@ main sleep 1 if [[ -n "$choice" ]]; then - sddm_simple="/usr/share/sddm/themes/simple_sddm_2" - if [ -d "$sddm_simple" ]; then - - # Check if yad is running to avoid multiple yad notification - if pidof yad > /dev/null; then - killall yad - fi - - if yad --info --text="Set current wallpaper as SDDM background?\n\nNOTE: This only applies to SIMPLE SDDM v2 Theme" \ - --text-align=left \ - --title="SDDM Background" \ - --timeout=5 \ - --timeout-indicator=right \ - --button="yad-yes:0" \ - --button="yad-no:1" \ - ; then + # Resolve SDDM themes directory (standard and NixOS path) + sddm_themes_dir="" + if [ -d "/usr/share/sddm/themes" ]; then + sddm_themes_dir="/usr/share/sddm/themes" + elif [ -d "/run/current-system/sw/share/sddm/themes" ]; then + sddm_themes_dir="/run/current-system/sw/share/sddm/themes" + fi - # Check if terminal exists - if ! command -v "$terminal" &>/dev/null; then - notify-send -i "$iDIR/ja.png" "Missing $terminal" "Install $terminal to enable setting of wallpaper background" - exit 1 - fi + if [ -n "$sddm_themes_dir" ]; then + sddm_simple="$sddm_themes_dir/simple_sddm_2" + + # Only prompt if theme exists and its Backgrounds directory is writable + if [ -d "$sddm_simple" ] && [ -w "$sddm_simple/Backgrounds" ]; then + # Check if yad is running to avoid multiple yad notification + if pidof yad > /dev/null; then + killall yad + fi - exec $SCRIPTSDIR/sddm_wallpaper.sh --effects - + if yad --info --text="Set current wallpaper as SDDM background?\n\nNOTE: This only applies to SIMPLE SDDM v2 Theme" \ + --text-align=left \ + --title="SDDM Background" \ + --timeout=5 \ + --timeout-indicator=right \ + --button="yad-yes:0" \ + --button="yad-no:1" \ + ; then + + # Check if terminal exists + if ! command -v "$terminal" &>/dev/null; then + notify-send -i "$iDIR/ja.png" "Missing $terminal" "Install $terminal to enable setting of wallpaper background" + exit 1 + fi + + exec "$SCRIPTSDIR/sddm_wallpaper.sh" --effects + fi fi fi -fi
\ No newline at end of file +fi diff --git a/config/hypr/UserScripts/WallpaperSelect.sh b/config/hypr/UserScripts/WallpaperSelect.sh index a08b53ce..466832ba 100755 --- a/config/hypr/UserScripts/WallpaperSelect.sh +++ b/config/hypr/UserScripts/WallpaperSelect.sh @@ -101,9 +101,21 @@ menu() { # Offer SDDM Simple Wallpaper Option (only for non-video wallpapers) set_sddm_wallpaper() { sleep 1 - sddm_simple="/usr/share/sddm/themes/simple_sddm_2" - if [ -d "$sddm_simple" ]; then + # Resolve SDDM themes directory (standard and NixOS path) + local sddm_themes_dir="" + if [ -d "/usr/share/sddm/themes" ]; then + sddm_themes_dir="/usr/share/sddm/themes" + elif [ -d "/run/current-system/sw/share/sddm/themes" ]; then + sddm_themes_dir="/run/current-system/sw/share/sddm/themes" + fi + + [ -z "$sddm_themes_dir" ] && return 0 + + local sddm_simple="$sddm_themes_dir/simple_sddm_2" + + # Only prompt if theme exists and its Backgrounds directory is writable + if [ -d "$sddm_simple" ] && [ -w "$sddm_simple/Backgrounds" ]; then # Check if yad is running to avoid multiple notifications if pidof yad >/dev/null; then @@ -123,9 +135,9 @@ set_sddm_wallpaper() { notify-send -i "$iDIR/error.png" "Missing $terminal" "Install $terminal to enable setting of wallpaper background" exit 1 fi - - exec $SCRIPTSDIR/sddm_wallpaper.sh --normal - + + exec "$SCRIPTSDIR/sddm_wallpaper.sh" --normal + fi fi } diff --git a/config/hypr/scripts/sddm_wallpaper.sh b/config/hypr/scripts/sddm_wallpaper.sh index a781156e..9487188c 100644 --- a/config/hypr/scripts/sddm_wallpaper.sh +++ b/config/hypr/scripts/sddm_wallpaper.sh @@ -10,7 +10,12 @@ wallDIR="$HOME/Pictures/wallpapers" SCRIPTSDIR="$HOME/.config/hypr/scripts" wallpaper_current="$HOME/.config/hypr/wallpaper_effects/.wallpaper_current" wallpaper_modified="$HOME/.config/hypr/wallpaper_effects/.wallpaper_modified" -sddm_simple="/usr/share/sddm/themes/simple_sddm_2" +# Resolve SDDM themes directory (standard paths and NixOS path) +sddm_themes_dir="/usr/share/sddm/themes" +if [ ! -d "$sddm_themes_dir" ] && [ -d "/run/current-system/sw/share/sddm/themes" ]; then + sddm_themes_dir="/run/current-system/sw/share/sddm/themes" +fi +sddm_simple="$sddm_themes_dir/simple_sddm_2" # rofi-wallust-sddm colors path rofi_wallust="$HOME/.config/rofi/wallust/colors-rofi.rasi" @@ -46,6 +51,12 @@ else wallpaper_path="$wallpaper_modified" fi +# Abort on NixOS where this repo doesn't manage SDDM and themes are typically read-only +if hostnamectl 2>/dev/null | grep -q 'Operating System: NixOS'; then + notify-send -i "$iDIR/error.png" "SDDM" "NixOS detected: skipping SDDM background change." + exit 0 +fi + # Launch terminal and apply changes $terminal -e bash -c " echo 'Enter your password to update SDDM wallpapers and colors'; @@ -70,7 +81,15 @@ sudo sed -i \"s/UserIconColor=\\\"#.*\\\"/UserIconColor=\\\"$color7\\\"/\" \"$sd sudo sed -i \"s/PasswordIconColor=\\\"#.*\\\"/PasswordIconColor=\\\"$color7\\\"/\" \"$sddm_theme_conf\" # Copy wallpaper to SDDM theme -sudo cp \"$wallpaper_path\" \"$sddm_simple/Backgrounds/default\" +# Primary: set Backgrounds/default (no extension) for simple_sddm_2 +sudo cp -f \"$wallpaper_path\" \"$sddm_simple/Backgrounds/default\" || true +# Fallbacks: if theme ships default.jpg or default.png, update those too +if [ -e \"$sddm_simple/Backgrounds/default.jpg\" ]; then + sudo cp -f \"$wallpaper_path\" \"$sddm_simple/Backgrounds/default.jpg\" +fi +if [ -e \"$sddm_simple/Backgrounds/default.png\" ]; then + sudo cp -f \"$wallpaper_path\" \"$sddm_simple/Backgrounds/default.png\" +fi notify-send -i \"$iDIR/ja.png\" \"SDDM\" \"Background SET\" "
\ No newline at end of file |
