I’m trying to set up a systemd sleep hook following this description
https://wiki.archlinux.org/index.php/Power_management#Sleep_hooks

The normal action in logind.conf is to suspend on lid close, but I also want the screen to get locked.
My idea was to use gnome-screensaver-command -l for that purpose which works well from command line

I’ve enable the root-suspend.service. However, the service fails

● root-suspend.service - Local system suspend actions
   Loaded: loaded (/etc/systemd/system/root-suspend.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Mon 2017-02-13 22:23:39 GMT; 4s ago
  Process: 2851 ExecStart=/usr/bin/gnome-screensaver-command -l (code=exited, status=1/FAILURE)
 Main PID: 2851 (code=exited, status=1/FAILURE)

Feb 13 22:23:39 martin-ant systemd[1]: Started Local system suspend actions.
Feb 13 22:23:39 martin-ant systemd[1]: root-suspend.service: Main process exited, code=exited, status=1/FAILURE
Feb 13 22:23:39 martin-ant systemd[1]: root-suspend.service: Unit entered failed state.
Feb 13 22:23:39 martin-ant systemd[1]: root-suspend.service: Failed with result 'exit-code'.

my root-suspend.service

[Unit]
Description=Local system suspend actions
Before=sleep.target

[Service]
Type=simple
Environment=DISPLAY=:0
ExecStart=/usr/bin/gnome-screensaver-command -l
#ExecStartPre=/usr/bin/echo "pre call"
#ExecStartPost=/usr/bin/sleep 1
#ExecStart=/usr/bin/echo "call"

[Install]
WantedBy=sleep.target