I want to turn off the screen after 10 minutes of inactivity, and 1 minute later, **IF** the monitor is still off, then lock the screen.
I know how to turn the screen off with
dbus
, how to lock screen, and how to get the screensaver state (i.e., if the screen is locked). But I do not know how to get the current monitor state ON/OFF.
So I want for KDE to trigger this script after 10 minutes of inactivity:
#!/bin/bash
sleep 1
dbus-send --session --print-reply --dest=org.kde.kglobalaccel /component/org_kde_powerdevil org.kde.kglobalaccel.Component.invokeShortcut string:'Turn Off Screen'
sleep 60
[[ ]] && dbus-send --session --print-reply --dest=org.freedesktop.ScreenSaver /ScreenSaver org.freedesktop.ScreenSaver.Lock
So how to query for monitor state (preferably with dbus
), namely, the `` condition in the above script?
I used to do xset -q | grep -i 'monitor is off'
, but now I get an error: Server does not have the DPMS Extension
.
Asked by Luis A. Florit
(509 rep)
Jul 23, 2024, 03:23 AM
Last activity: Jan 10, 2025, 06:24 PM
Last activity: Jan 10, 2025, 06:24 PM