Jump to content

Shutdown automatically when battery is low


highking
 Share

Recommended Posts

Hi,

 

On my laptop, KLaptop is able to execute a command when the battery is low. Now I would like to insert this command:

 

shutdown -h 1

 

So I would have 1 minute to save my work, before the laptop starts shutting itself down.

 

Well, I thought this would work, but since normal users aren't able to shut down the system, it doesn't!

 

Is there a way to enable shutdown for all users? So this thing works?

Link to comment
Share on other sites

You can configure sudo to allow you to run a command without asking for a password - I've only recently rebuilt my machine and not got round to doing this myself yet so I'm afraid I don't have an example.

 

I believe that the config files installed with sudo may have some examples in them though...

Link to comment
Share on other sites

Well, it doesn't really work after all.

 

It seems like the command should be run from a console, but since the command is run directly by KLaptop, it simply doesn't run. :wall:

 

Maybe someone could tell me how I can make KLaptop start a shell before it runs the command? :unsure:

Link to comment
Share on other sites

Can't help you there I'm afraid as I don't use KLaptop - I'm not sure I understand what you mean by "run in a console"...

 

One thing you could try (and this is how my system is set up) is write a shell script to perform the shutdown (and anything else you need to do to make it a neat, clean shutdown) and get KLaptop to run that instead of the sudo command directly.

 

As I say, this is how my system is set up, and I run the scripts from a Dock app - not directly from a console

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...