运行的cronjob为用户更改桌面背景在Ubuntu [英] Run cronjob as user to change desktop background in Ubuntu

查看:172
本文介绍了运行的cronjob为用户更改桌面背景在Ubuntu的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图运行这个剧本这改变了我的桌面背景在目录中随机图片。它的命令行工作,而得到的cronjob运行(增加产量和它被吐出到一个日志文件),但我不能让它改变我的背景。这里是我当前行(设定为每分钟运行进行测试)。

I am trying to run this script which changes my desktops background to a random picture in a directory. It works from the command line, and the cronjob gets run (added output and it gets spit out to a log file), but I can't get it to change my background. Here's my current line (set to run every minute for testing).

01 * * * * username /home/username/.wallpapers/flip.sh

任何想法?

推荐答案

错误:的 https://bugs.launchpad.net/ubuntu/+source/gconf/+bug/285937

我的版本:

#!/bin/bash

# Script to randomly set Background from files in a directory

# Directory Containing Pictures
DIR=/home/lucas/studio/art/images/tapety
LOG=/home/lucas/tapeta.log

# Command to Select a random file from directory
PIC="$(
for p in [jJ][pP][gG] [pP][nN][gG] [sS][vV][gG] ; do
 ls $DIR/*.$p
done | shuf -n1
)"
# Command to set Background Image
if [ -z "$DBUS_SESSION_BUS_ADDRESS" ] ; then
 # this is because of gconftool bug in cron
 TMP=~/.dbus/session-bus
 export $(grep -h DBUS_SESSION_BUS_ADDRESS= $TMP/$(ls -1t $TMP | head -n 1))
 echo $DBUS_SESSION_BUS_ADDRESS >> $LOG
fi

gconftool-2 -t string -s /desktop/gnome/background/picture_filename "$PIC"

和它的作品在Fedora 12

and it's works on Fedora 12

这篇关于运行的cronjob为用户更改桌面背景在Ubuntu的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆