Reputation: 3
I'm making a little photo booth thing where you can snap a photo of yourself using the Pi and a screen I have setup. I'm using Python and OpenCV and then using systemctl to have it run on startup. I'm then using wlrctl to move the mouse cursor so it's hidden. Everything works great when I call the .py file in the terminal, but when I run it using systemctl, the mouse cursor doesn't move (everything else still works fine though). I've tried using shell=True and different Environment tags but can't figure it out. I'm quite new to Raspberry Pi and Linux stuff so I'm pretty lost here. Any help would be great!
Here's the part of my script with the subprocess
def move_pointer():
try:
subprocess.run(["/usr/local/bin/wlrctl", "pointer", "move", "1920", "1080"], check=True, text=True)
print("Pointer moved to (1920, 1080).")
except subprocess.CalledProcessError as e:
print(f"Error occurred: {e}")
print(f"stderr: {e.stderr}")
print(f"stdout: {e.stdout}")
move_pointer()
and here's the error I get when i restart the service
Feb 04 00:10:29 sam python[5145]: Error occurred: Command '['/usr/local/bin/wlrctl', 'pointer', 'move', '1920', '1080']' died with <Signals.SIGABRT: 6>.
Feb 04 00:10:29 sam python[5145]: stderr: None
Feb 04 00:10:29 sam python[5145]: stdout: None
And then here's my service file:
[Unit]
Description=PiBooth python script
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/python /home/skngh/Desktop/PiBooth.py
Restart=on-abort
WorkingDirectory=/home/skngh/Desktop/
Environment="XAUTHORITY=/home/skngh/.Xauthority"
Environment="DISPLAY=:0"
Environment="PATH=/usr/bin"
User=skngh
[Install]
WantedBy=multi-user.target
Upvotes: 0
Views: 21