5

for some reason my machine has problems with suspension, specifically, it resumes as soon as it suspends. After some research I was able to solve this problem on 14.04 by using the following loop, as per this answer: https://askubuntu.com/a/268172

#!/bin/bash
case $1 in
    hibernate)
            echo "Going to suspend to disk!"
            ;;
    suspend)
            echo "Fixing acpi settings."
            for usb in 'XHC' 'EHC1' 'EHC2';
            do
                    state=`cat /proc/acpi/wakeup | grep $usb | cut -f3 | cut -d' ' -f1 | tr -d '*'`
                    echo "device = $usb, state = $state"
                    if [ "$state" == "enabled" ]
                    then
                            echo $usb > /proc/acpi/wakeup
                    fi
            done
            echo "Suspending to RAM."
            ;;
    thaw)
            echo "Suspend to disk is now over!"
            ;;
    resume)
            echo "We are now resuming."
            ;;
    *)
            echo "Somebody is callin me totally wrong."
            ;;
esac

However with the new systemd this solution isnt working anymore, I managed to create and place the same script on /usr/lib/systemd/system-sleep/, however this doesnt work as it doesnt execute, here is the output of my journal:

may 22 22:59:43 waiobook systemd[1]: Starting Suspend...
may 22 22:59:43 waiobook systemd-sleep[1372]: Suspending system...
may 22 22:59:49 waiobook systemd-sleep[1372]: System resumed.
may 22 22:59:49 waiobook systemd[1]: Started Suspend.
may 22 20:09:03 waiobook systemd[1]: Starting Suspend...
may 22 20:09:03 waiobook systemd-sleep[2674]: Suspending system...
may 22 20:09:07 waiobook systemd-sleep[2674]: System resumed.
may 22 20:09:07 waiobook systemd[1]: Started Suspend.

So i'm guessing im doing something wrong with the script?

Any help is aprecciated.

1 Answer 1

1

The script parameters have changed as well as directory. $1 is "post" on resume/thaw, "pre" otherwise. $2 in both cases contains either "suspend", "hibernate", or "hybrid-sleep". Modifying your example:

#!/bin/bash
case $1 in
pre) case $2 in
    hibernate)
            echo "Going to suspend to disk!"
            ;;
    hybrid-sleep)
            echo "Going to suspend to disk and ram!"
            ;;
    suspend)
            echo "Fixing acpi settings."
            for usb in 'XHC' 'EHC1' 'EHC2';
            do
                    state=`cat /proc/acpi/wakeup | grep $usb | cut -f3 | cut -d' ' -f1 | tr -d '*'`
                    echo "device = $usb, state = $state"
                    if [ "$state" == "enabled" ]
                    then
                            echo $usb > /proc/acpi/wakeup
                    fi
            done
            echo "Suspending to RAM."
            ;;
    *)
            echo "Somebody is callin me totally wrong."
            ;;
    esac ;;

post)
        echo "We are now resuming from $2."
        ;;
*)
        echo "Somebody is callin me totally wrong."
        ;;
esac
1
  • In which directory should this be put into?
    – Reloader
    Sep 5, 2016 at 20:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .