【发布时间】:2012-05-09 14:41:00
【问题描述】:
我编写了一个 bash 脚本来更改壁纸(用于 GNOME3)。
#!/bin/bash
# Wallpaper's directory.
dir="${HOME}/images/wallpapers/"
# Random wallpaper.
wallpaper=`find "${dir}" -type f | shuf -n1`
# Change wallpaper.
# http://bit.ly/HYEU9H
gsettings set org.gnome.desktop.background picture-options "spanned"
gsettings set org.gnome.desktop.background picture-uri "file://${wallpaper}"
在终端模拟器(例如 gnome-terminal)中执行的脚本效果很好。 cron 执行期间,或 ttyX 终端报错:
** (process:26717): WARNING **: Command line `dbus-launch --autolaunch=d64a757758b286540cc0858400000603 --binary-syntax --close-stderr' exited with non-zero exit status 1: Autolaunch error: X11 initialization failed.\n
** (process:26717): WARNING **: Command line `dbus-launch --autolaunch=d64a757758b286540cc0858400000603 --binary-syntax --close-stderr' exited with non-zero exit status 1: Autolaunch error: X11 initialization failed.\n
** (process:26721): WARNING **: Command line `dbus-launch --autolaunch=d64a757758b286540cc0858400000603 --binary-syntax --close-stderr' exited with non-zero exit status 1: Autolaunch error: X11 initialization failed.\n
** (process:26721): WARNING **: Command line `dbus-launch --autolaunch=d64a757758b286540cc0858400000603 --binary-syntax --close-stderr' exited with non-zero exit status 1: Autolaunch error: X11 initialization failed.\n
【问题讨论】:
-
没有一个解决方案对我有用。 :( 我必须在 cron 表达式中的命令之前设置 DISPLAY=:0.0。(ubuntuforums.org/showthread.php?t=1023215)。P.s. 我正在尝试运行一个使用 pynotify 的 python 脚本。
-
@Hussain:我花了一些时间才开始提问。我敢打赌,我下面的答案应该会更好 - 只需阅读整个讨论即可。