You are not logged in.

#1 2023-04-11 05:48:18

LeonN
Member
Registered: 2022-12-19
Posts: 92

Nitrogen doesn't restore the wallpapers

Hello, community. I have this script that allow me to choose a wallpaper and set it using Rofi to list the available images in a folder and Nitrogen to set the wallpaper:

#!/usr/bin/env sh

# shellcheck disable=SC2016

export LANG='POSIX'
exec >/dev/null 2>&1

WALLPAPERS_DIR="${HOME}/.wallpapers"

# List all images in the ${HOME}/.wallpapers folder
WALLPAPER="$(for LS in "$WALLPAPERS_DIR"/*.*; do
            [ ! -f "$LS" ] || echo "${LS##*/}"
        done \
        | rofi -theme-str '@import "config-wallpaper.rasi"' \
            -no-show-icons \
            -no-lazy-grab \
            -no-plugins \
            -p "?" \
            -dmenu )"

# Check if one image was selected
[ -n "$WALLPAPER" ] || exit ${?}

# Set the wallpaper
nitrogen --force-setter=xwindows --set-zoom-fill --save "${WALLPAPERS_DIR}/${WALLPAPER}"

# Display notification
dunstify '' "<span size='larger'><u>${WALLPAPER}</u></span>\nSuccessfully applied!" \
         -h string:synchronous:wallpaper-set \
         -a "Wallpaper" \
         -i "$WALLPAPER_ICON" \
         -u low

exit ${?}

It works great on the current session, I can change to any image in the .wallpapers folder, but after a reboot, the wallaper is no longer set. I added

nitrogen --restore &

in my .xprofile, but it still doesn't keep the wallpaper.
I tried looking for clues in the .config/nitrogen/ folder, and the only there is named bg-saved.cfg, which just contains this:

[:0]
file=/home/leo/.wallpapers/19.jpg
mode=5
bgcolor=#000000

I couldn't figure out why it is not restoring the wallpaper when I set it with the script, but it does when I do it by its GUI.

Offline

#2 2023-04-11 12:09:07

Ferdinand
Member
From: Norway
Registered: 2020-01-02
Posts: 338

Re: Nitrogen doesn't restore the wallpapers

If the script works great for the current session, I take it that /home/leo/.wallpapers/19.jpg, as specified in ~/.config/nitrogen/bg-saved.cfg, is the background you want restored after reboot?

Does...

nitrogen --restore

...from the CLI, after boot, load /home/leo/.wallpapers/19.jpg?

It it does, are you sure .xprofile is actually loaded when you start X?

Of course, you can call one from the other, or whatever, but if you're not loading .xprofile then nitrogen --restore & obviously won't be run smile

Edit: Just correcting typos

Last edited by Ferdinand (2023-04-11 12:17:01)

Offline

#3 2023-04-11 19:00:07

LeonN
Member
Registered: 2022-12-19
Posts: 92

Re: Nitrogen doesn't restore the wallpapers

Yes, indeed, 19.jpg is the wallpaper I set with the script. Now, after a reboot, the command nitrogen --restore does nothing. And my .xprofile file is clearly running since I have other stuff there. So. I still don´t why it doesn´t restore the wallpaper.

Last edited by LeonN (2023-04-11 20:32:35)

Offline

Board footer

Powered by FluxBB