How to make Kiosk session's screen go blank?

Hi,

I’ve been trying to get the kiosk session to respect “org.gnome.desktop.session idle-delay” but to no avail. I’ve set it to 60 seconds but it doesn’t work, the screen is always on.

Through my research, I’ve tried running gsd-power as a systemd unit and also included “org.gnome.SettingsDaemon.Power” as a required component over at “/usr/share/gnome-session/sessions/gnome-kiosk-script.session” but still nothing.

I’m setting up an embedded device, backed by a battery, and having the screen go blank would help a lot.

Thanks.

1 Like

I’m also interested in this issue. @Vidar Did you find a suitable solution?

(YMMV)Try to use busctl to power down screen and then monitor should go to standy mode:

busctl --user set-property org.gnome.Mutter.DisplayConfig /org/gnome/Mutter/DisplayConfig org.gnome.Mutter.DisplayConfig PowerSaveMode i 1

Thanks for the hint. I have tried the command and the screen enter PowerSaving Mode like expected, but fails to Power back on when a key on the keyboard is pressed or there is mouse movement. Any ideas how to achieve this?

To activate monitor again use following command, 0 at the end to turn off power saving for monitor:

busctl --user set-property org.gnome.Mutter.DisplayConfig /org/gnome/Mutter/DisplayConfig org.gnome.Mutter.DisplayConfig PowerSaveMode i 0

Not sure if this is the proper way, but maybe you could try to write a bash script to be executed by timer from systemd like this:

  1. Write bash script to detect mouse activation from /dev/input/mouse*
  2. Write systemd timer/script to wait for this bash script mouse detection
  3. Execute systemd bash script by timer after detecting mouse click to execute script above

If you manage to do it … it would be helpfull to post back example.
Good luck

Autostart

I used the solution from: Can't automatically suspend or logout after a certain time of inactivity (#10) · Issues · GNOME / GNOME Kiosk · GitLab to start the daemon (screensaver.py)

#/etc/xdg/autostart/idle_monitor.desktop
[Desktop Entry]
Type=Application
Name=Idle Monitor
Comment=Monitor idle state in kiosk session
Exec=/home/kiosk/.local/bin/screensaver.py
X-GNOME-Autostart-enabled=true
NoDisplay=true

Presence detection

I think the default time for idle is 5 min. I places this script as /home/kiosk/.local/bin/screensaver.py with kiosk as the kiosk-user.

#!/usr/bin/env python3
from pydbus import SessionBus
from gi.repository import GLib
import subprocess
import logging

logging.basicConfig( level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", filename="/tmp/screen.log" )

# GNOME Presence Status Codes
STATUS = {
    0: "active",
    1: "idle",
    2: "idle-dim",
    3: "away"
}

def set_monitor(powerSaveMode: bool):
    if powerSaveMode:
        logging.info("Enable PowerSave-Mode")
        subprocess.run(["busctl", "--user", "set-property", "org.gnome.Mutter.DisplayConfig", "/org/gnome/Mutter/DisplayConfig", "org.gnome.Mutter.DisplayConfig", "PowerSaveMode", "i", "1"])

    else:
        logging.info("Disable PowerSave-Mode")
        subprocess.run(["busctl", "--user", "set-property", "org.gnome.Mutter.DisplayConfig", "/org/gnome/Mutter/DisplayConfig", "org.gnome.Mutter.DisplayConfig", "PowerSaveMode", "i", "0"])

def on_status_changed(new_status):
    state = STATUS.get(new_status, "unknown")
    logging.info(f"Presence changed: {state}")

    if state in ("idle", "idle-dim", "away"):
        set_monitor(True)
    else:
        set_monitor(False)
def main():
    bus = SessionBus()
    presence = bus.get("org.gnome.SessionManager",
                       "/org/gnome/SessionManager/Presence")

    presence.onStatusChanged = on_status_changed

    logging.info("Monitor watcher started…")
    loop = GLib.MainLoop()
    loop.run()

if __name__ == "__main__":
    main()

Maybe there is a more robust way for example with systemd restart etc. but for now it’s working good enough. Thanks for the hints :slight_smile:

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.