Raspberry pi 命令';xprintidle';在systemd服务中返回非零退出状态1
我有一个带有Raspbian Buster Lite的Raspberry Pi,我用autologin在信息亭模式下启动。其目的是在连接的7英寸触摸屏(带铬)上显示单个网页。如果系统处于空闲状态,我的python脚本将检测到它并自动调暗屏幕。当用户再次与屏幕交互时,屏幕应再次亮起 这是我的剧本: #!/usr/bin/env python3 import subprocess import time import sys from rpi_backlight import Backlight backlight = Backlight() # read arguments from the run command: # idle time before dim (in seconds) idleTimeBeforeDimMS = int( sys.argv[1] )*1000 # brightness when dimmed (between 0 and 100) brightnessDimmed = int( sys.argv[2] ) brightnessFull = 100 def get(cmd): # just a helper function return subprocess.check_output(cmd).decode("utf-8").strip() isIdle0 = False stateChanged = False timeIntervalToWatchChangesS = 100 / 1000 while True: time.sleep( timeIntervalToWatchChangesS ) currentIdleTimeMS = int( get("xprintidle") ) isIdle = currentIdleTimeMS > idleTimeBeforeDimMS stateChanged = isIdle0 != isIdle if isIdle and stateChanged: # idling backlight.brightness = brightnessDimmed elif not isIdle and stateChanged: # active backlight.brightness = brightnessFull # set current state as initial one for the next loop cycle isIdle0 = isIdle 如果我重新启动并运行sudo systemctl status dim_screen.service,我会得到以下结果: 我相信最重要的调试信息是这一行:Raspberry pi 命令';xprintidle';在systemd服务中返回非零退出状态1,raspberry-pi,systemd,touchscreen,raspbian-buster,Raspberry Pi,Systemd,Touchscreen,Raspbian Buster,我有一个带有Raspbian Buster Lite的Raspberry Pi,我用autologin在信息亭模式下启动。其目的是在连接的7英寸触摸屏(带铬)上显示单个网页。如果系统处于空闲状态,我的python脚本将检测到它并自动调暗屏幕。当用户再次与屏幕交互时,屏幕应再次亮起 这是我的剧本: #!/usr/bin/env python3 import subprocess import time import sys from rpi_backlight import Backlight
命令'xprintidle'返回非零退出状态1。
我觉得这很奇怪?如果我在终端中运行xprintidle
,会发生以下情况:
pi@raspberrypi:~$ xprintidle
11399922
pi@raspberrypi:~$xprintidle
11399922
换句话说,我从xprintidle
得到了一个有效的响应。我相信还有一些我不明白的事情
作为服务启动python脚本(dim\u screen.py
)的正确方法是什么
pi@raspberrypi:~$ xprintidle
11399922