Fedora Linux Support Community & Resources Center
  #1  
Old 18th January 2007, 04:18 PM
SoniX's Avatar
SoniX Offline
Registered User
 
Join Date: Dec 2006
Location: Belgium
Age: 24
Posts: 24
Acpi battery script

I made myself this battery script:

Code:
#!/bin/sh
# Using the script to change brigtness when going to battery mode
ACAD_BRIGHTNESS=21
BATT_BRIGHTNESS=5
                                                                                                                                
# ac/battery event handler
                                                                                                                                    
status=`awk '/^state: / { print $2 }' /proc/acpi/ac_adapter/ADP1/state`
                                                                                                                                     
case $status in
       "on-line")
               logger "Changing brightness to ACAD level"
	       /usr/bin/smartdimmer --set=$ACAD_BRIGHTNESS 
               exit 0
       ;;
       "off-line")
               logger "Changing brightness to BATT level"
	       /usr/bin/smartdimmer --set=$BATT_BRIGHTNESS
               exit 0
       ;;
esac
Placed it into /etc/acpi/actions and made it executable!

Made myself this conf file

Code:
# Battery configuration
# Written by SoniX

#event=battery.*
#action=/etc/acpi/actions/battery.sh
Placed it into /etc/acpi/events

Reloaded the acpid deamon but this doesn't seem to work... Any idea's?
Reply With Quote
  #2  
Old 18th January 2007, 04:39 PM
SoniX's Avatar
SoniX Offline
Registered User
 
Join Date: Dec 2006
Location: Belgium
Age: 24
Posts: 24
NOTE: I Have a SONY VAIO VGN-FE21H
Reply With Quote
  #3  
Old 19th January 2007, 10:00 AM
SoniX's Avatar
SoniX Offline
Registered User
 
Join Date: Dec 2006
Location: Belgium
Age: 24
Posts: 24
Found a solution, removed all the previous files, made this script:

Code:
#!/bin/sh
# Using the script to change brigtness when going to battery mode
# Made by SoniX
FILENAME="state"
ACAD_BRIGHTNESS=21
BATT_BRIGHTNESS=5
      
while [ true ]
do                                                                                                             
	# ac/battery event handler                                                                                                                                  
	status=`awk '/^state: / { print $2 }' /proc/acpi/ac_adapter/ADP1/state`
	
	oldstatus=`cat $FILENAME`
                                                                                                                                 
	case $oldstatus in
		$status);;
		*)
			case $status in
			       "on-line")	       						
					/usr/bin/smartdimmer --set=$ACAD_BRIGHTNESS
		 			echo $status > $FILENAME
			       ;;
			       "off-line")
				       /usr/bin/smartdimmer --set=$BATT_BRIGHTNESS
		 			echo $status > $FILENAME
			       ;;
			esac

			echo $status > $FILENAME
			
			sleep 1
			;;
	esac
done
Put it somewhere and make gnome run this script in the background when starting a session
Reply With Quote
  #4  
Old 19th January 2007, 11:15 AM
baschti Offline
Registered User
 
Join Date: Nov 2005
Location: Old Europe
Posts: 377
hi SoniX,

i guess you script needs to much cpu time, 'cause of the while true statement - sure you have a sleep call, but it's better to use the event based approach
your config file isn't working because you commented out the interesting stuff
so it should look like:
Code:
# Battery configuration
# Written by SoniX

event=battery.*
action=/etc/acpi/actions/battery.sh
__________________
my JID: baschti@jabber.ccc.de
Reply With Quote
  #5  
Old 19th January 2007, 03:42 PM
SoniX's Avatar
SoniX Offline
Registered User
 
Join Date: Dec 2006
Location: Belgium
Age: 24
Posts: 24
STUPID ME!

Now ok, I will chance it to work with acpi, it's indeed much better. But the second script I wrote doesn't take so much cpu power. I don't see a difference, neither with "top" or an applet...
Reply With Quote
  #6  
Old 19th January 2007, 03:52 PM
nosnahoj Offline
Registered User
 
Join Date: Aug 2005
Location: Sweden
Posts: 40
Why dont you just do two events. One that activates when going from battery to ac (event=ac_adapter) and one from ac to battery (event=battery.*).
Reply With Quote
  #7  
Old 19th January 2007, 05:13 PM
SoniX's Avatar
SoniX Offline
Registered User
 
Join Date: Dec 2006
Location: Belgium
Age: 24
Posts: 24
I don't know why you should need 2 events... Everything works fine now after uncommenting those 2 lines. But I had to add /etc/acpi/actions/battery.sh to the gnome sessions. Otherwise when restarting it won't apply... Now everything works fine
Reply With Quote
  #8  
Old 19th January 2007, 05:37 PM
nosnahoj Offline
Registered User
 
Join Date: Aug 2005
Location: Sweden
Posts: 40
I thought this was a bit simpler:

event=battery.*
action=/usr/bin/smartdimmer --set=5

event=ac_adapter
action=/usr/bin/smartdimmer --set=21
Reply With Quote
  #9  
Old 19th January 2007, 07:05 PM
SoniX's Avatar
SoniX Offline
Registered User
 
Join Date: Dec 2006
Location: Belgium
Age: 24
Posts: 24
Quote:
Originally Posted by nosnahoj
I thought this was a bit simpler:

event=battery.*
action=/usr/bin/smartdimmer --set=5

event=ac_adapter
action=/usr/bin/smartdimmer --set=21
True, but I wan't to add more options, like getting the cpu level down, slowing fans, ... This was just a start :-)

EDIT
I don't think it will work, 'cause the battery event is trigerred when pluging and unpluging the power cable...

Last edited by SoniX; 19th January 2007 at 07:07 PM.
Reply With Quote
  #10  
Old 19th January 2007, 07:52 PM
nosnahoj Offline
Registered User
 
Join Date: Aug 2005
Location: Sweden
Posts: 40
Oh, my bad.. i forgot that..
Try this, Its nice if you want your hd to spin down:
http://dries.ulyssis.org/rpm/package...ools/info.html
Reply With Quote
Reply

Tags
acpi, battery, script

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Toshiba Satelliet A35 S159 Battery/ACPI Trouble AI8W Hardware & Laptops 2 22nd August 2007 09:09 PM
ACPI battery exception u39820984579842 Hardware & Laptops 0 30th May 2007 09:15 AM
battery/acpi problem newbie_fin Hardware & Laptops 9 10th April 2006 07:19 AM


Current GMT-time: 12:02 (Thursday, 23-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat