Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How to toggle laptop-mode-tools between AC and Battery
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
keivan
n00b
n00b


Joined: 22 Nov 2010
Posts: 42

PostPosted: Thu Jan 01, 2015 6:59 am    Post subject: How to toggle laptop-mode-tools between AC and Battery Reply with quote

:!: 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?

:idea: 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
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6228
Location: Room 101

PostPosted: Thu Jan 01, 2015 3:43 pm    Post subject: Reply with quote

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
View user's profile Send private message
tclover
Guru
Guru


Joined: 10 Apr 2011
Posts: 516

PostPosted: Fri Jan 02, 2015 12:07 am    Post subject: Easy... Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum