Chwp -- Desktop wallpaper changer

I have developed a cool python utility that uses Nitrogen to change wallpapers from a directory, never using the same picture twice until all the pictures have been shown, and rotating x number of seconds (configurable) before the next wallpaper change. It’s called “chwp” and it works flawlessly with my Mabox setup. I would like to make it available for others. Download here.


Hello @Shwaybo,
That sounds interesting, I’d love to try it out :slight_smile:
Have you posted this script somewhere? On github or elsewhere?
If it’s short, you can put it here in post.
Use 3 backticks (```) on their own line above and below your code.

1 Like

Thanks for sharing,
I set a wallpaper change every 30 seconds and I’m looking at them now;)
It works nice :smiley:

Some thoughts…

  1. I like the idea.
  2. Not so easy to setup currently (user need to edit 2 files and make “backup directory” by hand).
  3. Perhaps - sometime in my free time - I’ll try to write something like this, but as a Bash script - my Python skill is very low :wink:

Some ideas for tool changes/improvements

  1. Config file location should be: $HOME/.config/chwp/chwp.conf and it should be created at first run.
  2. Might be better to not copy images anywhere but to store image filenames in list/temporary file(?) and take random line from it - then delete line and so on. This way will be possible to operate on read-only directories like /usr/share/wallpapers
  3. Configurable wallpaper setter command to make script more universal for example on LXDE:
    something like:
pcmanfm --set-wallpaper="$file"

Here it is :slight_smile:


# Make config directory if not exist
mkdir -p $CONFIG_DIR

# If config file not exist create one with defaults
if [ ! -f $CONFIG_FILE ]; then
cat <<EOF > ${CONFIG_FILE}
# Directory with wallpapers
# Rotate time in seconds
# Wallpaper setter program: nitrogen or feh

# read config variables from file
source <(grep = $CONFIG_FILE)

# decide which setter and command use to set wallpaper
case "$setter" in
    nitrogen) command="nitrogen --set-zoom-fill --save";;
    feh) command="feh --bg-fill" ;;
    *) echo "Unknown wallpaper setter. Please check your config file $CONFIG_FILE";exit 1;;

while true
    # If list does not exist or is empty
    if [[ ! -f $WALLPAPERS_LIST || $(wc -l <$WALLPAPERS_LIST) -lt 1 ]]; then
    # Prepare list with wallpapers (only PNG and JPG)
    ls -1 "$wallpaper_dir"/*{.jpg,.png} > "$WALLPAPERS_LIST"
    # if wallpapers list have more than 0 lines
    while [ $(wc -l <$WALLPAPERS_LIST) -gt 0 ]
        # get random line
        line=$(shuf -n 1 $WALLPAPERS_LIST)
        #delete it from list
        grep -v "$line" "$WALLPAPERS_LIST" > "$CONFIG_DIR/tmpfile"; mv "$CONFIG_DIR/tmpfile" "$WALLPAPERS_LIST"
        #run command to set wallpaper
        ${command} ${line}
        sleep ${interval}
1 Like

Thanks for the script.
Well, my question is - why is wplist file with a list of images needed in the configuration?

Hi @Ved-un good point.
I was writing this script late at night quickly.
A list with pictures has to be saved somewhere.
There is no deeper sense in it, it just turned out like that :wink:

If I have some free time, I will probably rewrite the script + add pipemenu to make it a nice toy that runs from the left sidepanel. (start, stop, configure interval and so on)

1 Like

I have such a script - is it worse?


 while true; do
  nitrogen --set-zoom-fill --random --save
  sleep 900

Here it is completely and I use it.


if [ "$1" = -d ];
 while true; do
  nitrogen --set-zoom-fill --random --save
  sleep 900
  nitrogen --set-zoom-fill --random --save

@Ved-un your script is fine :slight_smile:

But idea and python program from @Shwaybo is about…

1 Like

Got it.
Then I’ll leave this script for experiments )
although my folder with images is large and repetitions with my script are very rare (imperceptible)