How can I trigger the screensaver’s locking feature using D-BUS from the command line?

How can I trigger the screen saver manually from the command line? I’m using GNOME 3.8.4 on Fedora 19, but the solution should not necessarily be specific to this distro.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

The details on how to do this were found here in this blog post titled: Locking the screen from the command line in Gnome 3.8.

Manually triggering

The dbus-send command can be used to send this message, in this case we’re sending the “Lock” message to the screensaver.

$ dbus-send --type=method_call --dest=org.gnome.ScreenSaver 
    /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock

Timeout

Typically this same message will be sent when you’ve configured for this particular timeout to occur through the desktop settings.

You can check the amount of idle time required before the locking will automatically get triggered, from the GNOME Control Center, Settings -> Power -> Blank Screen.

You can check the value of this delay from the command line like so:

$ gsettings get org.gnome.desktop.session idle-delay
uint32 600

Also you can change it via the command line, or through the GNOME Control Center.

$ gsettings set org.gnome.desktop.session idle-delay 300


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x