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.

So, I wan't to run it when start work on AC and this or better other script when start work from battery

I tried

  • /etc/acpi/power.sh
  • adding symlink to /etc/laptop-mode/battery-start

It seems to not working

share|improve this question
    
Can you be a bit more precise? What didn't work? How did you observe it? –  user unknown Aug 5 '11 at 8:21
    
@user unknown Oh I was wrong. I tried 1 > /testfile but i forgot "echo". SHould I delete question? –  RiaD Aug 5 '11 at 8:26
    
Don't delete it, but tell us in an answer, which of the both methods above worked, and how you found out. If this is the best answer, you can even accept it. –  user unknown Aug 5 '11 at 8:34
    
Make sure that laptop-mode is actually running.. –  user606723 Aug 5 '11 at 17:46

2 Answers 2

up vote 6 down vote accepted

You should be able to do what you want with a script in /etc/pm/power.d. Quoting from the HOWTO.hooks file in pm-utils:

How to write a pm-utils hook:

PARAMETERS

A pm-utils hook is simply an executable file that accepts at least one parameter.

For hooks in power.d, the potential values of that parameter are:

  • true -- the hook MUST perform whatever action is appropriate when the system transitions TO battery power.
  • false -- The hook MUST perform whatever action is appropriate when the system transitions FROM battery power.

You might also want to read some of the existing power hooks in /usr/lib/pm-utils/power.d for ideas about how to structure your script.

Note that if you use the pm-utils interface, you'll be told whether you're on AC power or not through the first argument: if $1 is true, then you're switching to battery power, and if it is false then you're switching back to mains power.

share|improve this answer

It's not really correct question. I get some error, but now I correct and my power.sh and it works

if on_ac_power; then
  echo 0 > /home/riad/1 
  #on ac
else 
  echo 1 > /home/riad/1
  #on battery
fi

and it works

share|improve this answer
    
Note that if you use the pm-utils interface I described in my answer, you'll be told whether you're on AC power or not through the first argument: if $1 is true, then you're switching to battery power, and if it is false then you're switching back to mains power. –  James Henstridge Aug 5 '11 at 10:29

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.