0

I'm using Debian 8 and I'm booting my system with Linux 4.1.2 with systemd. I had a working script that does something and suspends the pc. After upgrades, the script was not working anymore. When I switched to systemd, it started to work.

The script is working when power button is pressed, but only for the first time. After resuming, the button is not working. Lid switch handler script is not run at all.

Why should it be?

Edit:

It seems that the handler script (/etc/acpi/actions/powerbtn-acpi-support.sh) somehow runs twice when power button is pressed. So the suspend script stucks, and system becomes unresponsive to the next power button press events.

/etc/acpi/events/powerbtn-acpi-support :

event=button[ /]power
action=/etc/acpi/actions/powerbtn-acpi-support.sh

Edit2:

As a workaround to this issue, I changed my suspend script as follows:

#!/bin/bash

timestamp() {
  date +"%s"
}

lfile=/home/ceremcem/cca-suspend.log
echo "simply log the output" >> "$lfile"

ts_file="/tmp/suspend-timestamp"

if [ -f $ts_file ]; then 
    echo "timestamp file is found"
    prev=$(cat $ts_file)
    echo "previous run: $prev"
    time_diff=$(($(timestamp) -$prev))
    echo "which means $time_diff seconds ago"
    if [ $time_diff -lt 10 ]; then 
        echo "this script can not be run within 10 seconds..."
        exit 1
    fi
else
    echo "timestamp file is not found"
fi 

timestamp > "$ts_file"


if [[ $(id -u) > 0 ]]; then
    if [[ "$DISPLAY" == "" ]]; then 
        env >> "$lfile"
        sudo "$0" "$(whoami)"
    else
        env >> "$lfile"
        gksu "$0" "$(whoami)"
    fi
    exit
fi

if [[ "$1" == "" ]]; then 
    user="ceremcem"
else
    user="$1"
fi

echo "locking screen..."
/usr/local/bin/physlock -d -u $user

echo "suspending..."
pm-suspend

echo "exiting..."
exit 0

Now pc suspends whenever power button is pressed...

  • Is it that the script runs whenever the PC is being suspended or shutdown, or that the script itself suspends the PC? – saiarcot895 Oct 11 '15 at 18:59
  • script itself suspends (and locks the screen). – ceremcem Oct 11 '15 at 19:25
  • The question lacks any useful information. What is in the script? How is it started (by hand or via some automation)? What is in the logs after a failed attempt? – intelfx Oct 13 '15 at 13:11
  • The script runs and does whatever it does, and makes system suspended. If I call the script multiple times by terminal, it runs everytime as expected. There is no need to focus on the script. Absolutely, script is run via acpid, so the question is tagget with acpid. It is registered wherever it is needed, because it runs at least for the first time. I think question does not lack any useful information. But if you think so, then I should add these, because it seems that question is hard to understand right now. Thanks. – ceremcem Oct 13 '15 at 13:26
  • I'm not sure where to look when I press power button, dmesg | tail shows nothing about it. – ceremcem Oct 13 '15 at 13:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.