How to change brightness of wallpapers with time of the day, like the default wallpaper given.

What tutorials suggest is to use a picture slide-show or applications like F.lux.

But I want to automate the brightness only of the image based on time, just like the default wallpaper given in Ubuntu.

  • yep , I found the xml of the default file, which simply changes 3-5 images with varied brightness, is there any way to change the brightness of the same image? or should i go for a custom script? May 9, 2015 at 10:37

1 Answer 1


Wherever I've written USER, change it to your username (e.g. mine is tim).

Create a new folder, perhaps in your pictures folder, and navigate to it:

mkdir /home/$USER/Pictures/Wallpaper
cd /home/$USER/Pictures/Wallpaper

make a new file, make it executable, and edit it:

touch bgchange.sh
chmod +x bgchange.sh
gedit bgchange.sh

Add the following to the file (where is says USER below you need to change this to your user):

#! /bin/bash

gsettings set org.gnome.desktop.background picture-uri 'file:///home/USER/Pictures/Wallpaper/'$(date +%H)'.png'

That will change the image on the hour to an image with the hour name (i.e. at 1pm (13:00) it will change the background to an image called 13.png.

Now to create the images. Simply run this command:

for i in {0..23}; do convert -brightness-contrast $(($i*2))x0 image.png $i.png; done

You will end up with a series of images, each "2" brighter than the previous. The darkest (original) will be 0.png, the brightest 23.png. It will look a little like this:

enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here

You may want to rename these to change the order, but make sure there is an image for every hour (0 to 23).

Finally, the script needs to start at boot:

Run this command, and press enter (2 is selected by default):

crontab -e

and add this line:

0 * * * * /home/USER/Pictures/Wallpaper/bgchange.sh

Then press Ctrl+X, type Y and press enter. It will start each time you boot the computer.

My pronouns are He / Him

  • 2
    Since you're using cron anyway, why not set it to re-run the script hourly, instead of using a loop with sleep? May 9, 2015 at 19:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .