編集する:

編集する:

私はDebian 8を使用しており、systemdでLinux 4.1.2を使用してシステムを起動しました。タスクを実行し、コンピュータを一時停止するタスクスクリプトがあります。アップグレード後、スクリプトは機能しなくなります。 systemdに切り替えたときに動作し始めました。

スクリプトは電源ボタンを押すと機能しますが、初めてのみ機能します。復元後、ボタンは機能しません。カバースイッチハンドラスクリプトはまったく実行されません。

なぜですか?

編集する:

/etc/acpi/actions/powerbtn-acpi-support.sh電源ボタンを押すと、ハンドラscript()が2回実行されるようです。その結果、一時停止スクリプトが中断され、システムが次の電源ボタン押下イベントに応答しなくなります。

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

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

編集2:

この問題の回避策として、一時停止スクリプトを次のように変更しました。

#!/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

これで、電源ボタンを押すたびにコンピュータが一時停止します。

ベストアンサー1

おすすめ記事