Fedora 24 Bash Script to Change Desktop Background

Bash Script to Change Desktop on Gnome Shell

Previously on this blog I had a script that will change your desktop background and can be used on cron

This is an updated version of that script, mainly the pgrep no longer works as the gdm login is matching as well so we need to be more specific when pulling out the process ID.

Here is the script, copy paste into a bash script, edit the path for images and then add to your crontab and enjoy nice backgrounds of your choosing.

I like to combine this with a transparent top panel for something a bit less bland and depressing than the solid black bar that we have by default. You can install this gnome shell extension to easily set transparency and also other tweaks.`

#!/usr/bin/env bash
PID=$(ps waux | grep [g]nome-session-binary | grep -v gdm | cut -d ' ' -f 5)
export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2-)
gsettings set org.gnome.desktop.background picture-uri '"file://'/home/joseph/Pictures/Wallpapers/$(ls /home/joseph/Pictures/Wallpapers/ | shuf -n 1)'"'

Tags: fedorabashdconfwallpaperdesktopbackground