Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Openbox Pipe Menu: ACPI Laptop Users
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
GaMMa
l33t
l33t


Joined: 23 Aug 2002
Posts: 684
Location: USA

PostPosted: Wed Oct 20, 2004 11:22 pm    Post subject: Openbox Pipe Menu: ACPI Laptop Users Reply with quote

Here's my second script, I was sick of manually changing cpu frequency scheduling and messing with files to see how much longer I had on my battery. You must have ACPI battery and frequency scaling support compiled in the kernel to use this, and you have to follow the directions in the file itself. Don't forget to chmod +x.

NEED SUGGESTIONS FOR MORE FEATURES

NOTE: Some locations of files may be different for certain users, please review all locations in the script before running it.

Here it is in action
laptop.py

ChangeLog:
0.4: Now displays the temperature, and the temp_state
0.3: Made some changes.. Gov: displays the current scaling_governor, when clicked if scaling_gov is performance it'll switch to powersave, and if it's anything else it goes to performance. Did a quick change where it says (AC) next to the battery if it's plugged in.
0.2: Switched to battery percent and added Cpu speed. FIXED
0.1: Initial release, more of a proof of concept thing. The menu gives a rough estimation of remaining battery life based on current capacity remaining divided by how fast it's draining. The next version will feature the % of the battery that is remaining also.
_________________
Ubuntu Linux Dapper Drake running Gnome-2.14.1
[Website | Screenshot | Portage Guide]


Last edited by GaMMa on Fri Jan 28, 2005 10:07 pm; edited 4 times in total
Back to top
View user's profile Send private message
plbe
l33t
l33t


Joined: 01 May 2004
Posts: 661

PostPosted: Fri Oct 22, 2004 12:53 am    Post subject: Reply with quote

Yay another ob script they seem neverending, you should learn c unless you already know it of course and apply to be an ob dev, would be nice to have updates every once in a while
Back to top
View user's profile Send private message
Moofed
Apprentice
Apprentice


Joined: 22 Oct 2002
Posts: 158
Location: Bloomington, IN

PostPosted: Sat Oct 23, 2004 10:00 am    Post subject: Reply with quote

Neat script. My battery is in '/proc/acpi/battery/CMB1', not BAT0, so I had to change that to display any text. I don't know if that is common, maybe I have an odd laptop (Crusoe proc...).

I added a battery time left display to the script. Modifications are in bold:
Quote:

file = open('/proc/acpi/battery/CMB1/state','r')
tmp = file.readlines()
state = tmp[4].split()[2]
rate = tmp[3].split()[2]
file.close()

Quote:

remaining = round(((float(state) / float(capacity)) * 100),1)
if rate != '0':
timeleft = str(int(state) / int(rate)) + ':' + string.zfill(str(int((float(state) / float(rate)) % 1 * 60)), 2)

Indent the timeleft definition!
Quote:

print " <item label=\"Bat: " + str(remaining) + "% (AC)\">"
else:
print " <item label=\"Bat: " + str(remaining) + "% (" + timeleft + ")\">"
Back to top
View user's profile Send private message
GaMMa
l33t
l33t


Joined: 23 Aug 2002
Posts: 684
Location: USA

PostPosted: Sun Oct 24, 2004 4:28 am    Post subject: Reply with quote

Yea I took out timeleft from the script because it gave too rough of an estimate. You open the pipe menu while opening openoffice and it'd say you have an hour of time left. If you idle and open the pipemenu up you could have 4+ hours left. The only way to successfully do this is poll estimated battery life every second, and average the calculations together, but that would require a daemon and can't be done with a pipemenu.

I guess everyone's ACPI battery is different :P and yes, more pipe menus. Now to figure out how to order food from Papa Johns via pipe menu...
_________________
Ubuntu Linux Dapper Drake running Gnome-2.14.1
[Website | Screenshot | Portage Guide]
Back to top
View user's profile Send private message
s3ntient
Guru
Guru


Joined: 13 Apr 2003
Posts: 304
Location: Lyon, France

PostPosted: Mon Oct 25, 2004 3:21 am    Post subject: Reply with quote

I modified your script to work with FVWM:
https://forums.gentoo.org/viewtopic.php?p=1687824

The only thing I found to add yet was Temperature.

It's really handy, thanks :wink:
_________________
http://blog.chaostrophy.org
Back to top
View user's profile Send private message
Kioshen
Tux's lil' helper
Tux's lil' helper


Joined: 23 Sep 2003
Posts: 109
Location: Montreal, PQ

PostPosted: Mon Oct 25, 2004 5:04 pm    Post subject: Reply with quote

:o That is a god send ! hehehe

I'm going to try this right now to see how it goes. Thanks a lot !
_________________
-= United we share =-

Adopt an unanswered post today!
Why emerge -U will kill your Gentoo
Back to top
View user's profile Send private message
okidit
n00b
n00b


Joined: 22 Sep 2003
Posts: 15
Location: Mexico DF

PostPosted: Tue Jan 25, 2005 7:47 pm    Post subject: New Feature Reply with quote

Hi GaMMa, could you add the possibility to read the temperature,
I had tried but I don't know Python, the parts that I wrote are this:
Code:

file = open('/proc/acpi/thermal_zone/THM/temperature','r')
temp = file.readline().split()[1]
file.close

file = open('/proc/acpi/thermal_zone/THM/state','r')
temp_state = file.readline().split()[1]
file.close

print "  <item label=\"Temperature: " + str(temp) + str(temp_state)">"
print "  </item>"
Back to top
View user's profile Send private message
GaMMa
l33t
l33t


Joined: 23 Aug 2002
Posts: 684
Location: USA

PostPosted: Thu Jan 27, 2005 11:53 am    Post subject: Reply with quote

There we go, all updated and added :D. Script link is still the same, and is in the first post.
_________________
Ubuntu Linux Dapper Drake running Gnome-2.14.1
[Website | Screenshot | Portage Guide]
Back to top
View user's profile Send private message
amne
Bodhisattva
Bodhisattva


Joined: 17 Nov 2002
Posts: 6378
Location: Graz / EU

PostPosted: Thu Jan 27, 2005 6:28 pm    Post subject: Reply with quote

Moved from GC.
_________________
Dinosaur week! (Ok, this thread is so last week)
Back to top
View user's profile Send private message
Kioshen
Tux's lil' helper
Tux's lil' helper


Joined: 23 Sep 2003
Posts: 109
Location: Montreal, PQ

PostPosted: Fri Jan 28, 2005 3:14 pm    Post subject: Reply with quote

GaMMa wrote:
There we go, all updated and added :D. Script link is still the same, and is in the first post.


Not to be a bother be there seems to have a typo in your new revision ;)

Code:

kioshen@blackdrop % ./.config/openbox/scripts/laptop.py                                                             
Traceback (most recent call last):
  File "./.config/openbox/scripts/laptop.py", line 38, in ?
    file = open('/proc/acpi/thermal_zone/THM/temperature','r')
IOError: [Errno 2] No such file or directory: '/proc/acpi/thermal_zone/THM/temperature'
kioshen@blackdrop % cat /proc/acpi/thermal_zone/THRM/temperature                                                     
temperature:             45 C


[EDIT] Fixed a typo in my own post lool and removed trailing ~ because of zsh
_________________
-= United we share =-

Adopt an unanswered post today!
Why emerge -U will kill your Gentoo
Back to top
View user's profile Send private message
GaMMa
l33t
l33t


Joined: 23 Aug 2002
Posts: 684
Location: USA

PostPosted: Fri Jan 28, 2005 10:06 pm    Post subject: Reply with quote

Very weird, It's THM on my system. People were having problems with other portions of the script being in different locations too. My guess is ACPI isn't uniform. :P If someone else complains I'll change it. I'm going to make a note on the first post too...
_________________
Ubuntu Linux Dapper Drake running Gnome-2.14.1
[Website | Screenshot | Portage Guide]
Back to top
View user's profile Send private message
GaMMa
l33t
l33t


Joined: 23 Aug 2002
Posts: 684
Location: USA

PostPosted: Sat Aug 20, 2005 4:57 pm    Post subject: Reply with quote

Does anyone know how the gnome cpufrequency applet changes frequency without the need of a password? It'd be cool if I could to that too for the pipe menu.
_________________
Ubuntu Linux Dapper Drake running Gnome-2.14.1
[Website | Screenshot | Portage Guide]
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks 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