You are not logged in.

#1 2022-07-16 15:02:07

salmund
Member
Registered: 2022-07-16
Posts: 2

Can't enable suspend@.service (can't lock the screen before suspend)

Hello,

Recently I installed i3 on my machine with arch, and I want to configure it so that at each "systemctl suspend", I can at the same time lock the screen with betterlock (in the same way as i3lock).

Here is my /etc/systemd/system/suspend@.service

[Unit]
Description=User suspend actions
Before=sleep.target

[Service]
User=%I
Type=forking
Environment=DISPLAY=:0
ExecStart=/usr/bin/betterlockscreen -l dim

[Install]
WantedBy=sleep.target

And this I what I get when I want to do

systemctl enable /etc/systemd/system/suspend@.service
Failed to enable unit: File sleep.target: Identifier removed

Of course I searched on Google for anything related to this, but I can't find anything...

Last edited by salmund (2022-07-16 15:38:41)

Offline

#2 2022-07-16 15:09:25

salmund
Member
Registered: 2022-07-16
Posts: 2

Re: Can't enable suspend@.service (can't lock the screen before suspend)

I don't know if it helps, but I tried to locate sleep.target with find,

and I got it, it's here :

/usr/lib/systemd/system/sleep.target
  1 #  SPDX-License-Identifier: LGPL-1.1-or-later
  2 #
  3 #  This file is part of systemd.
  4 #
  5 #  systemd is free software; you can redistribute it and/or modify it
  6 #  under the terms of the GNU Lesser General Public License as published by
  7 #  the Free Software Foundation; either version 2.1 of the License, or
  8 #  (at your option) any later version.
  9 
 10 [Unit]
 11 Description=Sleep
 12 Documentation=man:systemd.special(7)
 13 DefaultDependencies=no
 14 RefuseManualStart=yes
 15 StopWhenUnneeded=yes                                                                                                                      

Offline

#3 2023-10-03 11:07:25

recluzegeek
Member
Registered: 2023-10-03
Posts: 1

Re: Can't enable suspend@.service (can't lock the screen before suspend)

Just had the same issue as yours and resolved by adding username for which I'm trying to enable the service. Like this

 systemctl enable /etc/systemd/system/suspend@<username>.service

Offline

Board footer

Powered by FluxBB