How I can trigger sleep.target in systemd --user session?

My naive approach was first:

[email protected]

   [Unit]
   Description=sleep.target of a systemd user session
   Before=sleep.target
   StopWhenUnneeded=yes

   [Service]
   Type=oneshot
   User=%I
   RemainAfterExit=yes
   ExecStart=/usr/bin/systemctl --user start sleep.target
   ExecStop=/usr/bin/systemctl --user stop sleep.target

   [Install]
   WantedBy=sleep.target

sleep.target

   [|Unit]
   Description=Sleep Timer Target
   StopWhenUnneeded=yes

|
|Unfortunately I got the following error:

||    $ systemctl status user-sleep@joerg
    [email protected] - sleep.target of a systemd user session
       Loaded: loaded (/etc/systemd/system/[email protected]; enabled)
       Active: failed (Result: exit-code) since Mo 2013-06-10 12:30:41 CEST; 
43min ago
      Process: 10503 ExecStart=/usr/bin/systemctl --user start sleep.target 
(code=exited, status=1/FAILURE)

    Jun 10 12:30:41 turing-machine systemd[1]: Service [email protected] 
is not needed anymore. Stopping.
    Jun 10 12:30:41 turing-machine systemd[1]: [email protected]: main 
process exited, code=exited, status=1/FAILURE
    Jun 10 12:30:41 turing-machine systemd[1]: Failed to start sleep.target of 
a systemd user session.
    Jun 10 12:30:41 turing-machine systemd[1]: Unit [email protected] 
entered failed state.|

Can I use "systemctl --user" only at a login shell and not in a systemd
unit? Because using "systemd --user" from tty works great.
My use case is to logout my jabber client before suspend (I hope this
does not sounds to trivial compared to your serious problems, but you
might come up with other use cases).
This cannot be done in a normal .service file, because it does require a
connection to the current dbus session.


Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
systemd-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to