1

I'm trying to change the desktop wallpaper via cron/bash. I've read a lot of questions and answers on this site an apparently I have to do something like

#!/bin/bash

MY_FILE_PATH=/home/$USER/file.jpg

PID=$(pgrep gnome-session)

export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2-)

sleep 5

gsettings set org.gnome.desktop.background picture-uri file://$MY_FILE_PATH

But if run ./my_script.sh I get

grep: /proc/X1: Is a directory
grep: X2/environ: No such file or directory

X1 and X2 are two different numbers and of course cron doesn't work

EDIT

If I manually set PID to one of the two numbers I get (on the line where export is made)

for X1 (829):

permission denied

for X2 (1394):

warning: command substitution: ignored null byte in input
Zanna
  • 72,312

0 Answers0