You are not logged in.
Pages: 1
So with the recent updates I have adopted systemd and figuring out my configurations. I went through the wiki and I am left with a couple of questions that I would appreciate if someone could help me out with.
1. I have systemd handle my suspend and hibernate tasks but I am as yet unable to have it trigger "slock" for locking my xsession after wake. I looked into having script in system-sleep with no effect.
2. How would I change the function of my powerkey so it does not poweroff but suspends by laptop?
Thanks
Offline
I don't use slock or any locker for that matter. But regarding the power key, I don't think that systemd can handle this itself. It has some very basic power-button, sleep-button, and lid-button functionality. But changing the function is beyond it I am pretty sure. I think what you will need to do is use xmodmap or xev to determine what your power key is labeled as. For instance, mine is xf86-poweroff, so I would then use the configuration of my window manager or desktop environment to set that to "systemctl suspend" or simply just "suspend" if you have installed systemd-sysvcompat.
I guess you could also use something like xbindkeys. Just make sure that you have disabled any other tool's ability to set the power key to poweroff. Oh yeah, if you use acpid, you could simply edit the handler.sh to perform suspend rather than poweroff.
Offline
Thanks will give that a shot. The only issue with this however is that my power-button will not function outside my X session.
Offline
I would imagine that if you were motivated enough, you could modify the underying keyboard layout to actually change your power button to a sleep button. So you know how you have to set the keyboard layout in vconsole.conf? That is directing your system to the correct keyboard layout. So find that file and see about modifying it.
Offline
Indeed, configuring the console keymap might be the "key" then for me.
Now to solve my slock issue.
Offline
How is was slock called when using initscripts?
Offline
I had a rather rudimentary way of doing it. I had a small script that sort of resembled:
pm-suspend
slock
In effect, the laptop would go to sleep and on wake slock would take effect. I had an if statement that checked for x session so slock wouldn't be called if I was not in my wm.
Offline
What if you simply put something like so in /usr/systemd/system-sleep
#!/bin/bash
if [[ $1 == 'post' ]] && [[ $2 == 'suspend' ]] ; then
slock
elif [[ $1 == 'post' ]] && [[ $2 == 'hibernate' ]] ; then
slock #assuming you want to run slock with either suspend or hibernate
fi
When you suspend, systemd will run anything in this directory with two arguments, the first ($1) is pre or post, and the second ($2) is suspend or hibernate. See man systemd-sleep for more info.
Offline
Yes, after reading the wiki and the man page(s) I had already tried a script in "/usr/lib/systemd/system-sleep" but with no effect as I mentioned in my first post.
I know the script is being executed, because if there are any errors I see it with "journalctl _SYSTEMD_UNIT=systemd-suspend.service".
I also tried yours, but journalctl _SYSTEMD_UNIT=systemd-suspend.service tells me there is a segmentation fault at line 6. This I find confusing :\.
Offline
you will have to make sure that slock is started as the correct user (with su) and DISPLAY is set, otherwise it can't work.
Offline
you will have to make sure that slock is started as the correct user (with su) and DISPLAY is set, otherwise it can't work.
Yep. I am using this script (modified from pm-utils-screen-lock)
#!/bin/sh
# Lock screen
# based on pm-utils-screen-lock by byronc http://aur.archlinux.org/packages.php?ID=36219
# detects the locker/screensaver daemon each user is running
# each user can also set a custom locker command:
# - plain commandline in $HOME/.xlock
# - or create executable script or symlink as $HOME/.xlock
user_locker()
{
## based on "/usr/bin/xflock4"
if [ -x "/home/$1/.xlock" ]; then
XLOCK="/home/$1/.xlock" ## XLOCK set by user
elif [ -f "/home/$1/.xlock" ]; then
XLOCK=$(cat "/home/$1/.xlock")
elif pgrep -u "$1" xscreensaver > /dev/null 2>&1; then
XLOCK="xscreensaver-command -lock"
elif pgrep -u "$1" gnome-screensav > /dev/null 2>&1; then
XLOCK="gnome-screensaver-command --lock"
elif pgrep -u "$1" -f startkde > /dev/null 2>&1; then
XLOCK="dbus-send --session --dest=org.kde.krunner \
--type='method_call' --print-reply \
/ScreenSaver org.freedesktop.ScreenSaver.Lock"
elif pgrep -u "$1" xautolock > /dev/null 2>&1; then
XLOCK="xautolock -locknow"
elif [ -x /usr/bin/i3lock ]; then
XLOCK="i3lock"
else
XLOCK="xlock -mode blank $* &"
fi
}
lock_screen()
{
## based on "/etc/acpi/sleep.sh" and "/usr/share/acpi-support/power-funcs"
for x in /tmp/.X11-unix/*; do
displaynum=`echo $x | sed s#/tmp/.X11-unix/X##`
user=`who | grep -m1 "(:$displaynum)" | awk '{print $1}'`
if [ x"$user" = x"" ]; then
user=`who | grep -m1 ":$displaynum" | awk '{print $1}'`
fi
if [ x"$user" != x"" ]; then
XLOCK=""
user_locker "$user"
export DISPLAY=":$displaynum"
/bin/su -c "$XLOCK" "$user"
fi
done
}
if [ "$1" = "pre" ]; then
case "$2" in
hibernate|suspend)
lock_screen
;;
esac
fi
| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |
Offline
You can use acpid as a socket activated systemd unit. In acpid you can define any action for your power button (which is likely to produce an acpi event). It seems to me a much cleaner and more general solution than a keyboard binding in X or console. Systemd tries to replace a minimum of acpid functionality, but does not force you to be limited to that minimum.
Mortuus in anima, curam gero cutis
Offline
Pages: 1