Pcmanfm设置壁纸在Cron中的Raspbian拉伸失败 [英] Pcmanfm set wallpaper fails on Raspbian stretch in cron

查看:128
本文介绍了Pcmanfm设置壁纸在Cron中的Raspbian拉伸失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用桌面运行近乎新鲜的Raspbian Stretch 4.9图像,并且有一个程序每隔几分钟就会为计算机背景创建一个新图像.

I am running a nearly fresh image of Raspbian Stretch 4.9 with a desktop and have a program which creates a new image for the computer background every few minutes.

我正在尝试创建一个cron作业,以使用pcmanfm正确更新背景,并遵循了建议

I am trying to create a cron job to properly update the background using pcmanfm and, having followed the suggestions here, have created the following script called update.sh to set the background:

!#/bin/bash
export DISPLAY=:0
export XAUTHORITY=/home/pi/.Xauthority
pcmanfm -w '/home/pi/folder/image.png'

该脚本是可执行的,并且从终端运行时可以正常运行.我创建了一个crontab使其自动运行,例如:

The script is executable and when it is run from the terminal it functions as intended. I have created a crontab to have this run automatically as such:

* * * * * /home/pi/folder/update.sh > /home/pi/folder/log.txt 2>&1

当cron作业每分钟触发一次时,会出现一个弹出窗口,并显示错误消息桌面管理器未激活".单击确定"按钮将其关闭,日志文件将显示为:

When the cron job triggers every minute, a pop-up window appears with an error saying "Desktop manager is not active." with a button "OK" to dismiss it, and the log file reads:

** Message: x-terminal-emulator has very limited support, consider choose another terminal

我已经在crontab中直接尝试了该命令

I have tried the command directly in the crontab

* * * * * DISPLAY=:0 && pcmanfm -w '/home/pi/folder/image.png' > /home/pi/folder/log.txt 2>&1

这次错误有所不同

Cannot open display:

虽然从环顾四周看来,cron作业似乎很挑剔,但我不确定这是什么意义.我不确定这是路径问题还是环境问题,因为我不了解这些事情的许多细节,但是我不认为这应该是问题,因为我使用的是图像和脚本的完整路径.它不应该是权限错误,因为我在用户crontab和系统crontab上都尝试了此操作,但都失败了. (此外,默认情况下,默认的pi用户仍然具有root权限.)我不确定其他要搜索或尝试的内容,因此我在寻求帮助是否有人将我指向正确的方向或之前曾遇到此问题.

I am not entirely sure what sense to make of this, though from looking around it seems cron jobs can be finnicky. I am not sure if it is a Path or environment problem because I do not know many details about these things, but I don't think it should be a problem as I am using the full path to the image and the scripts. It shouldn't be a permissions error, because I have tried this on both a user crontab and a system crontab, and both fail. (Besides, the default pi user has root permissions by default anyways.) I am not sure what else to search for or try so I am asking for help if someone could point me in the right direction or has encountered this problem before.

推荐答案

除了运行Lubuntu 17.04之外,我遇到了完全相同的问题.它在最近更新后不久才出现,但无法确定何时.经过大量研究,我怀疑XDG环境变量之一也必须导出.经过一些试验和错误,我发现导出XDG_RUNTIME_DIR为我解决了这个问题.您可能需要尝试一下.

I had exactly the same issue, except I am running Lubuntu 17.04. It appeared lately after a recent update, though cannot pinpoint when. After lot's of research I became suspicious that one of the XDG enviromental variables must be exported too. Following some trial and error, I found that exporting XDG_RUNTIME_DIR solved the problem for me. You may want to give it a try.

要计算值,请运行:echo $XDG_RUNTIME_DIR

对我来说,从cron运行的工作墙纸更换器看起来像:

The working wallpaper changer running from cron for me now looks like:

#!/bin/bash
...
export DISPLAY=:0
export XAUTHORITY=/home/krisz/.Xauthority
export XDG_RUNTIME_DIR=/run/user/1000
pcmanfm --set-wallpaper=${dir}/${file} --wallpaper-mode=crop
...

这篇关于Pcmanfm设置壁纸在Cron中的Raspbian拉伸失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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