LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-24-2011, 01:29 PM   #1
RabbidRabbit
LQ Newbie
 
Registered: Apr 2011
Posts: 7

Rep: Reputation: 0
xmobar cannot get battery information


I have recently been trying out xmonad and xmobar and it has been working well so far.
However, when I try to add the battery information to xmobar I get this error:
Code:
xmobar: /sys/class/power_supply/BAT0/current_now: hGetBufSome: unsupported operation (No such device)
Here is my .xmobarrc config:
Code:
Config { font = "-*-Fixed-Bold-R-Normal-*-13-*-*-*-*-*-*-*"
       , bgColor = "black"
       , fgColor = "grey"
       , position = TopW L 90
       , lowerOnStart = True
       , commands = [ Run Weather "EGPF" ["-t"," <tempF>F","-L","64","-H","77","--normal","green","--high","red","--low","lightblue"] 36000
                    , Run Cpu ["-L","3","-H","50","--normal","green","--high","red"] 10
		    , Run Battery ["Bat0"] 600
                    , Run Memory ["-t","Mem: <usedratio>%"] 10
                    , Run Swap [] 10
                    , Run Date "%a %b %_d %l:%M" "date" 10
                    , Run StdinReader
                    ]
       , sepChar = "%"
       , alignSep = "}{"
       , template = "%StdinReader% }{ %cpu% | %memory% * %swap%  %battery% <fc=#ee9a00>%date%</fc> | %EGPF%"
       }
 
Old 10-25-2011, 02:31 PM   #2
Ian John Locke II
Member
 
Registered: Mar 2008
Location: /dev/null
Distribution: Slackware, Android, Slackware64
Posts: 130

Rep: Reputation: 17
Could just be that xmobar has stupidly hard-coded the path to the battery. At least on Slackware that would be the incorrect path. For my small script relating to my battery level, the absolute path is /proc/acpi/battery/.

To be safe though you could do the following
Code:
find /sys -name 'BAT*' 2>&1 | grep -v 'Permission denied'
find /proc -name 'BAT*' 2>&1 | grep -v 'Permission denied'
That should tell you where it should be. You can then patch in the correct path.
 
Old 10-25-2011, 04:21 PM   #3
RabbidRabbit
LQ Newbie
 
Registered: Apr 2011
Posts: 7

Original Poster
Rep: Reputation: 0
Unfortunately the path is correct. After looking around on the internet it seems that it is a problem with the bios on my hp laptop. What I need is for Xmobar to launch without the current_now seeing as that only gives information to work out how much longer the battery will last for. I only want a percentage of the capacity left.
 
Old 10-25-2011, 05:09 PM   #4
RabbidRabbit
LQ Newbie
 
Registered: Apr 2011
Posts: 7

Original Poster
Rep: Reputation: 0
I modified the Batt.hs file to ignore the current_now file and now it works as I wanted.
 
Old 11-01-2011, 08:36 AM   #5
Ian John Locke II
Member
 
Registered: Mar 2008
Location: /dev/null
Distribution: Slackware, Android, Slackware64
Posts: 130

Rep: Reputation: 17
Sorry I couldn't help more.
 
Old 05-14-2021, 03:32 AM   #6
xorlop
LQ Newbie
 
Registered: May 2021
Posts: 1

Rep: Reputation: Disabled
There is a way to hardcode a location for battery left

I found that by using "BatteryP", you can specify a location to look if your battery has a strange name that is not "BAT0".. my battery is named "CMB0" and was able to get it to work by doing this:
Code:
Run BatteryP ["/sys/class/power_supply/CMB0"] [ "--template", "<acstatus> <left>"
                                  , "--Low", "10"
                                  , "--High", "80"
                                  , "--low", "darkred"
                                  , "--normal", "darkorange"
                                  , "--high", "darkgreen"
                                  , "--"
                                  , "-O", "<left>% <fc=darkgreen>↻</fc>"
                                  , "-i", "<fc=darkgreen>∞</fc>"
                                  , "-o", "<left>% (<timeleft>)"
                                  ] 1000
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Battery applet/battery monitor problem on Dell Studio lnx Linux - Laptop and Netbook 8 03-28-2011 03:40 AM
LXer: Battery Status 0.1 Released - Improved Battery Applet For The Gnome Desktop LXer Syndicated Linux News 0 05-21-2010 06:30 PM
Xmonad stops working right when xmobar is started on Debian/stable jinnzo Linux - Desktop 0 04-25-2010 11:26 AM
[SOLVED] xmonad: xmobar not working. Switch7 Linux - Desktop 2 10-24-2009 04:46 PM
Battery level information script d0odman Linux - Laptop and Netbook 1 01-21-2006 01:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration