Monitoring SDDM to Auto-Shutdown PC if Never Logged In

Hey everyone,

I’m trying to create a script that monitors my PC when I turn it on via Wake-on-LAN (WoL) and shuts it down if I never log in or if I lock the screen for too long. I’ve managed to check for screen locking by detecting the kscreenlocker_g process, but I’m struggling to determine if I never leave the SDDM screen after booting.

The tricky part is that SDDM runs regardless of whether I’m logged in or not, so I can’t just check if it’s running. My PC also has Wolf (Games on Whales) installed, and I want the script to ensure that if I haven’t logged in, or the screen is locked, and no Wolf container is running, the PC should shut down after 30 minutes. This works fine for a locked screen, but I can’t find a reliable way to detect if I never left SDDM at all.

Does anyone know a good method to check if a session was never started from SDDM? Any ideas would be greatly appreciated!

Hi! I’d think pretty much anything related to Plasma itself wouldn’t have been started if no users had logged into a Plasma session since the device booted - ex. the plasmashell process, or the systemd user unit plasma-plasmashell.service. Maybe you could check for those?