How to run programs in KDE after suspend wakeup

0

How can i run programs after suspend wakeup in an X-Session (KDE)? Especially they are some scripts to set xinput properties, which are lost after suspend and need to be restored.

allo

Posted 2017-02-01T13:45:24.883

Reputation: 731

Answers

0

The prefereed way of doing this on an OS with systemd is by using /usr/lib/systemd/system-sleep/:

systemd runs all executables in /usr/lib/systemd/system-sleep/, passing two arguments to each of them:

Argument 1: either pre or post, depending on whether the machine is going to sleep or waking up Argument 2: suspend, hibernate or hybrid-sleep, depending on which is being invoked

In contrast to pm-utils, systemd will run these scripts concurrently and not one after another.

The output of any custom script will be logged by systemd-suspend.service, systemd-hibernate.service or systemd-hybrid-sleep.service. You can see its output in systemd's journal

An example script:

#!/bin/sh
case $1/$2 in
  pre/*)
    echo "Going to $2..."
    ;;
  post/*)
    echo "Waking up from $2..."
    ;;
esac

Taken from: https://wiki.archlinux.org/index.php/Power_management

t11r

Posted 2017-02-01T13:45:24.883

Reputation: 1

I don't think this works as intended. First it does not seem to have any context depending on the logged in user(s) and second it probably does not have the right variables set to run the programs in the X-Environment (DISPLAY variable, access to x authentication cookies, etc.) – allo – 2017-03-22T09:34:14.347