You are not logged in.
Pages: 1
Topic closed
Hi,
I want to lock my screen when I come out of sleep, my search came up to use systemd service to do that.
So I created the following service to do that:
[Unit]
Description=Lock Cinnamon X Session on sleep
Before=sleep.target
[Service]
Environment=DISPLAY=:0
ExecStart=/usr/bin/cinnamon-screensaver-command --lock
ExecStartPost=/usr/bin/sleep 1
[Install]
WantedBy=sleep.target
But unfortunately this is not working. The service is enabled, but when I try it I get the following:
Aug 03 13:59:51 TTT-XX cinnamon-screensaver-command[25109]: Can't connect to screensaver!
I am not sure what am I doing wrong. I am suspecting that this will not work with cinnamon-screensaver-command because all examples I have seen uses something like slimlock or xlock, but I would really like to understand what is going on.
Offline
dbus environment?
You could maybe adapt https://gist.githubusercontent.com/Alad … tfile1.txt
Offline
Looking at cinnamon-screensaver-command
$ cat /usr/bin/cinnamon-screensaver-command#!/bin/sh
exec /usr/share/cinnamon-screensaver/cinnamon-screensaver-command.py "$@"
Leads to the python script /usr/share/cinnamon-screensaver/cinnamon-screensaver-command.py
$ cat /usr/share/cinnamon-screensaver/cinnamon-screensaver-command.py
#!/usr/bin/python3
....
from dbusdepot.screensaverClient import ScreenSaverClient
import config
....
class ScreensaverCommand:
"""
This is a standalone executable that provides a simple way
of controlling the screensaver via its dbus interface.
"""
def __init__(self, mainloop):
self.mainloop = mainloop
....
self.client = ScreenSaverClient()
self.client.connect("client-ready", self.on_client_ready)
....
Which derives its dbus support from /usr/share/cinnamon-screensaver/dbusdepot/screensaverClient.py
$ cat /usr/share/cinnamon-screensaver/dbusdepot/screensaverClient.py
....
class ScreenSaverClient(BaseClient):
"""
This is the paired proxy paired to our ScreensaverService interface.
It is only used by cinnamon-screensaver-command to communicate with
the screensaver process.
"""
....
def __init__(self):
super(ScreenSaverClient, self).__init__(Gio.BusType.SESSION,
CScreensaver.ScreenSaverProxy,
c.SS_SERVICE,
c.SS_PATH)
....
So you need to use the session bus of the session started by cinnamon-session which launches cinnamon-screensaver.
Please note "...." denotes sections of output removed for clarity
Offline
Thanks seth and loqs. Sorry for my delayed response, my knowledge in DBUS is limited and needed to look into it before posting about this any further.
The issue is resolved on its own though. I think maybe a restart was needed, which is probably weird?
For my knowledge the changes in systemd should be active once I enable them with --now option.
Offline
I had this problem too. Fixed it up by adding to the .service file...
User=username
Environment=DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
But change 1000 to your own userid, and "username" to your user name.
Offline
Offline
Pages: 1
Topic closed