You are not logged in.
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=#000000I 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
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?
It should if you're using one of the DM's listed here: https://wiki.archlinux.org/title/.xprofile
Otherwise, you may actually be loading .xinitrc: https://wiki.archlinux.org/title/.xinitrc
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 ![]()
Edit: Just correcting typos
Last edited by Ferdinand (2023-04-11 12:17:01)
Offline
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