Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Question: How to assign a script to run when selecting the suspend option on the power menu?

Context:
I have a Sony VAIO laptop, which was a recent purchase. I have managed to install the AMD Radeon drivers after a few problems, but I would like to be able to disable/enable the discrete graphics card. I have no problem in doing this but it causes problems when suspending & resuming from suspend.

When the session is resumed from suspend (with the discrete DPU disabled), the fan will spin up uncontrollably, what I would like to do is edit the suspend script or assign a new script to the suspend option on the power menu. This is so I can re-enable the GPU before suspending. Power Menu

EDIT: After some research I think it has something to do with the files in /etc/pm/sleep.d/?

If I put a custom script in there would it be run when suspending and resuming from suspend?

How do I differentiate in the script between suspending/resuming?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

You are right. You have to write a script and save it to /etc/pm/sleep.d/. The difference between suspending and resuming is given as a paramater to the script:

#!/bin/bash

case "$1" in
    suspend)
        # executed on suspend
        ;;
    resume) 
        # executed on resume
        ;;
    *)
        ;;
esac

If you also want to do it for hibernate, the arguments would be hibernate and thaw.

share|improve this answer
    
I'd seen this in other scripts and was wondering on the specific requirements for such a script. Thank you :) –  D4nC00per Feb 25 '13 at 13:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.