View previous topic :: View next topic |
Author |
Message |
keivan n00b

Joined: 22 Nov 2010 Posts: 42
|
Posted: Thu Jan 01, 2015 6:59 am Post subject: How to toggle laptop-mode-tools between AC and Battery |
|
|
I am trying to set a keyboard shortcut to toggle laptop-mode-tools between AC and Battery settings.
Is there any idea how to do that?
I know how to set a shortcut in KDE. I just want a good script to setup the shortcut. I mean an script which switches laptop-mode-tools to battery mode on the first run and then switches back to AC mode on the second run and so on.
Happy new year!!! |
|
Back to top |
|
 |
khayyam Watchman


Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Thu Jan 01, 2015 3:43 pm Post subject: |
|
|
keivan ...
generally such things are run from acpid, see the section 'ac_adapter' in /etc/acpid/default.sh. Anyhow, such a toggle script would look something like the following (requires sys-power/acpi):
Code: | #!/bin/sh
if [ $(acpi -a | awk '/^Adapter/{print $3}') = "online" ] ; then
# do something here ... ie, switch laptop-mode-tools to 'ac'
else
# do the opposite thing here ... ie, switch laptop-mode-tools to 'battery'
fi |
Of course you really don't want to do this, I'm sure laptop-mode-tools has some machanism for querying acpi and changing state ... at least I'd expect so.
best ... khay |
|
Back to top |
|
 |
tclover Guru

Joined: 10 Apr 2011 Posts: 516
|
Posted: Fri Jan 02, 2015 12:07 am Post subject: Easy... |
|
|
That's easy to do... but it seems you want to do it manually.
Some resources on the... ACPI article has `default.sh' script which has an automated variant relying on ACPI, so if hardware ACPI is functionnal do not hesitate to give it a try. Note that, that automated variant rely on hprofile (there is an article as well) which you can adapt to have a manual variant if you feel like it... which brings in a second resource.
Happy RTFMing. _________________ home/:mkinitramfs-ll/:supervision/:e-gtk-theme/:overlay/ |
|
Back to top |
|
 |
|