lahwaacz / sxlock

MIT License
41 stars 21 forks source link

Add After=suspend.target #7

Closed orschiro closed 10 years ago

orschiro commented 10 years ago

This fixes some compatibility issues on resume with other application. Thus it is better to run sxlock after the suspend.target.

orschiro commented 10 years ago

I was hoping that the After target will resolve a specific issue that I encountered. I start the following service on resume:

~ cat /usr/lib/systemd/system/powersaving-resume.service 
[Unit]
Description=Run powersaving settings on resume
After=suspend.target

[Service]
Type=oneshot
ExecStart=/usr/bin/powersaving-helper

[Install]
WantedBy=suspend.target

This executes a brightness setting:

~ cat /usr/bin/powersaving-off 
#!/bin/bash

# Turn off powersaving 
echo "Running powersaving on AC"

# Setting environmental variables
export DISPLAY=:0
export XAUTHORITY=/home/orschiro/.Xauthority

# screen power saving
echo 14 > /sys/class/backlight/acpi_video0/brightness

This works perfectly without sxlock running on resume, too. However, for some reasons sxlock blocks the brightness from being changed.

Do you have any idea why this could happen?

Does the blacking of the screen somehow block the DISPLAY variable?

lahwaacz commented 10 years ago

You do not need any DISPLAY or XAUTHORITY for changing values under /sys, this should work even from console. The interesting part is that sleep.target contains StopWhenUnneeded=yes, whereas suspend.target and hibernate.target do not. The quick fix for you is to use After=sleep.target for your service, but this might be a bug in systemd.

orschiro commented 10 years ago

@lahwaacz

Thanks, issue resolved by using After=sleep.target!