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

查看:13
本文介绍了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 正确更新背景,并且遵循了建议 此处,创建了以下名为 update.sh 的脚本来设置背景:

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天全站免登陆