Skip to content

mate and gnome

Ok it's not an os but since i use it always it deserves a separate chapter.

dconf

The problem i was trying to solve was to randomly change the desktop with a script. So the hard part there boiled down to : how to change the desktop background from the command line. Now there seem to be a lot of tools claiming to do that but i could only get one to work and that was dconf. It uses a key system that you can explore with the list command, just always put a slash at the end and it will list the entries:

list entries
1
2
3
4
5
dconf list /

net/
org/
apps/

Actually you can use TAB completion to find a certain key, like the one we where searching for :

use tab
1
2
3
4
5
6
7
dconf list /org/mate/desktop/background/

color-shading-type
primary-color
picture-options
picture-filename
secondary-color

You will notice that the TAB will stop here since these are entries , not tree nodes. So you might as well use the read command for this, it TAB's as well:

use tab
1
2
3
dconf read /org/mate/desktop/background/picture-filename 

'/home/kees/Pictures/420211-watch-gears-748x421.jpg'

Now you can use write to change it but it has to be between both quotes.

change desktop image
dconf write /org/mate/desktop/background/picture-filename "'/home/kees/Pictures/fiRkPmU.jpg'"

No other combination works. So now our script will look like this, it is a one-shot change so you can put it in crontab :

crontab
1
2
3
4
5
6
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus

DIR="/home/kees/Pictures"
PIC=$(ls $DIR/*.jpg | shuf -n1)

/usr/bin/dconf write /org/mate/desktop/background/picture-filename "'$PIC'"

The DBUS export is needed for dconf and it is not set in the environment in which crontab executes the script.