📜  cron 无法更改墙纸 ubuntu - Shell-Bash 代码示例

📅  最后修改于: 2022-03-11 14:50:18.980000             🧑  作者: Mango

代码示例1
#!/bin/bash
# you must set some environment variables
# before cron can change your wallpaper
# please go see the source answer on askubuntu.com for more details

user=$(whoami)

fl=$(find /proc -maxdepth 2 -user $user -name environ -print -quit)
while [ -z $(grep -z DBUS_SESSION_BUS_ADDRESS "$fl" | cut -d= -f2- | tr -d '\000' ) ]
do
  fl=$(find /proc -maxdepth 2 -user $user -name environ -newer "$fl" -print -quit)
done

export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS "$fl" | cut -d= -f2-)

/usr/bin/gsettings set org.gnome.desktop.background picture-uri file:////the/path/to/your/image