Search Results for 'xbattbar'

Forum Forums Search Search Results for 'xbattbar'

Viewing 6 results - 16 through 21 (of 21 total)
  • Author
    Search Results
  • #7508
    Moderator
    BobC

      Well, it only lasted about 10 minutes. It did come back up happier, though, so what you suggested worked. I put in a different battery, and now my conky is working. You have to click it to see the battery part up near the top. It needs the acpitool and xbattbar installed to work…

      
      #!/bin/bash
      # conky-battery.sh - build battery string to return to conky
      #   can't pass parm from conky, so get status byte from acpi -b (should be same as 1st char of battery_short), nothing comes back if not present
      FILE='/home/bobc/conky-battery_0.tmp'
      today=<code>date '+%Y_%m_%d__%H_%M_%S'</code>;
      OUTPUT="$(acpi -b | tr '\n' ' ' | sed -e 's/Battery 0: //g')"
      STATUS1="$(acpi -b | tr '\n' ' ' | sed -e 's/Battery 0: //g' | cut -c1-1)"
      if [[ -z "STATUS1" ]]; then
      	STATUS1=N
      fi
      #C is displayed instead of charging, D for discharging, F for full, N for not present, E for empty and U for unknown
      case $STATUS1 in
      	F|E|U )
      		acpi -bi | tr '\n' ' ' | sed -e 's/Battery 0://g' -e 's/, rate information unavailable//' -e 's/ Full, //' -e 's/ full / /' \
      			-e 's/ design //' -e 's/last capacity //' -e 's/ capacity / = /' -e 's/100% =/Full, Max/' -e 's/mAh,/mAh, Last Full/' \
      			-e 's/Discharging,/Draining,/' > $FILE
      		;;
      	N )
      		printf "Not Present" > $FILE
      		;;
      	* )
      		tail -n 1 ~/xbattbar.log | sed -e 's/^.*\(line\:.*min\.\).*$/\1/' -e 's/line\: //' > $FILE
      		;;
      esac
      cat $FILE
      
      • This reply was modified 5 years, 2 months ago by BobC.
      • This reply was modified 5 years, 2 months ago by BobC.
      • This reply was modified 5 years, 2 months ago by BobC. Reason: acpitool, not acpitools
      Attachments:
      Moderator
      BobC

        I switched the battery in my laptop, and ever since I have lost all current settings on it. It knows how big the battery is in mAh, but doesn’t know how much the battery will hold now when full or its current charge. I have tried 3 different batteries, and none show up correctly, even though all are good. I think reinstalling the OS will fix it, but that seems very harsh. The files showing “no such device” seem to be the problem. I have tried draining it all the way and rebooting, etc, but nothing seems to reset it. tlp recalibrate only works for Thinkpads, it looks, and this is an HP Pavilion dv9917cl. This did work fine initially.

        Is there some way to reset the value when I swap in a different battery?

        The battery is full, and although old, will hold the machine for over an hour. All the utilities like conky and xbattbar come up wrong with the similar wrong info as the acpi -bi

        /sys/class/power_supply/BAT0# acpi -bi
        Battery 0: Unknown, 0%, rate information unavailable
        Battery 0: design capacity 6000 mAh, last full capacity -60 mAh = -1%

        I have done lots of googling and found nothing that worked…

        Any ideas on things to try?

        When I run tlp-stat I get this:

        +++ Battery Status
        /sys/class/power_supply/BAT0/manufacturer = Hewlett-Packard
        /sys/class/power_supply/BAT0/model_name = Primary
        /sys/class/power_supply/BAT0/cycle_count = (not supported)
        /sys/class/power_supply/BAT0/charge_full_design = 6000 [mAh]
        /sys/class/power_supply/BAT0/charge_full = (not available)
        /sys/class/power_supply/BAT0/charge_now = (not available)
        /sys/class/power_supply/BAT0/current_now = (not available)
        cat: /sys/class/power_supply/BAT0/charge_full: No such device
        cat: /sys/class/power_supply/BAT0/charge_now: No such device
        /sys/class/power_supply/BAT0/status = Unknown

        inxi -Fzx
        System: Host: hpdv9917d Kernel: 4.9.0-5-amd64 x86_64 bits: 64 gcc: 6.3.0 Desktop: IceWM 1.4.2
        Distro: antiX-17_x64-full Heather Heyer 24 October 2017
        Machine: Device: laptop System: Hewlett-Packard product: HP Pavilion dv9700 Notebook PC v: Rev 1 serial: <filter>
        Mobo: Quanta model: 30D1 v: 85.26 serial: <filter> BIOS: Hewlett-Packard v: F.30 date: 04/24/2008
        Battery BAT0: charge: 100% condition: NA/88.8 Wh model: Hewlett-Packard Primary status: N/A
        CPU: Dual core AMD Turion 64 X2 Mobile TL-62 (-MCP-) arch: K8 rev.F+ cache: 1024 KB
        flags: (lm nx sse sse2 sse3 svm) bmips: 8401
        clock speeds: max: 2100 MHz 1: 2100 MHz 2: 2100 MHz
        Graphics: Card: NVIDIA C67 [GeForce 7150M / nForce 630M] bus-ID: 00:12.0
        Display Server: X.Org 1.19.2 drivers: nouveau (unloaded: modesetting,fbdev,vesa)
        Resolution: 1440×900@60.00hz
        OpenGL: renderer: Gallium 0.4 on NV67 version: 2.1 Mesa 13.0.6 Direct Render: Yes
        Audio: Card NVIDIA MCP67 High Definition Audio driver: snd_hda_intel bus-ID: 00:07.0
        Sound: Advanced Linux Sound Architecture v: k4.9.0-5-amd64
        Network: Card-1: NVIDIA MCP67 Ethernet driver: forcedeth port: 30f8 bus-ID: 00:0a.0
        IF: eth0 state: dormant speed: 100 Mbps duplex: full mac: <filter>
        Card-2: Qualcomm Atheros AR242x / AR542x Wireless Network Adapter (PCI-Express)
        driver: ath5k bus-ID: 03:00.0
        IF: wlan0 state: down mac: <filter>
        Drives: HDD Total Size: 532.1GB (5.5% used)
        ID-1: /dev/sda model: HGST_HTS725050A7 size: 500.1GB
        ID-2: /dev/sdb model: SanDisk_SSD_U110 size: 32.0GB
        Partition: ID-1: / size: 15G used: 5.7G (42%) fs: ext4 dev: /dev/sdb5
        ID-2: swap-1 size: 4.29GB used: 0.46GB (11%) fs: swap dev: /dev/sda12
        Sensors: System Temperatures: cpu: 67.0C mobo: N/A gpu: 67.0
        Fan Speeds (in rpm): cpu: N/A
        Info: Processes: 173 Uptime: 10 days Memory: 1959.1/3704.3MB Init: SysVinit runlevel: 5 Gcc sys: 6.3.0
        Client: Shell (bash 4.4.121) inxi: 2.3.54

        • This topic was modified 5 years, 2 months ago by BobC.
        #6535
        Anonymous

          purpose of the -s scriptfile option?

          Yeah, the manpage is unclear:

          https://sources.debian.org/src/xbattbar/1.4.8-1/xbattbar.man/

          xbattbar [-a] [blahblahblah] [-s script-name]
          You can use your external script for check battery status. It must print two lines to STDOUT ‘battery=value’ and ‘ac_line=on|off

          xbattbar.c reads values from an external datasource
          apm | acpi | sys | myscript
          The default datasource is apm; via options, we can instruct it to use an alternative datasource: -c (acpi), -r (sys aka sysfs), or -s (myscript)

          #6503
          Moderator
          BobC

            I found this was the only small footprint app that estimates reasonably the amount of life left in the battery and time left to fully charge, but when I tried to redirect it to a file, the file was empty.

            I looked and found it on the debian package site for stretch, and found a git link to the source. I installed git and I found the source code and figured out that the reason is that printf is being used, but was not being flushed to the disk with an fflush(stdout); afterwards. So I fixed the code. I also added the info from the display box along with time/date as well as seconds since epoch to the logfile and made a way to easily use tail and sed to process it so I could feed it to my conky.

            I had to install enough things to then compile and test it, but I am still missing some because xmkmf -a doesn’t work and make install doesn’t work…

            build-essential
            apt-file
            libx11-dev

            Then I compiled and tested, and it now works right. I found out who the debian packager is and sent him the code (I also attached it here) with a nice email in hopes he’ll add my changes since I don’t know anything about packaging. I suppose I could also post the object here in a zipfile if anyone wants it so they don’t need to recompile it.

            In my startup I start it, redirecting output to the log file
            xbattbar -c -t 4 -I green -O brown -i red -o black > ~/xbattbar.log &

            Output:
            Battery at Tue Feb 13 02:23:31 2018 1518510211 seconds AC on-line: Charging 67% Needs 0 hr. 49 min. 30 sec.
            Battery at Tue Feb 13 02:28:50 2018 1518510530 seconds AC on-line: Charging 68% Needs 2 hr. 45 min. 20 sec.
            Battery at Tue Feb 13 02:29:32 2018 1518510572 seconds AC off-line: Depleting 67% Left 0 hr. 41 min. 20 sec.
            Battery at Tue Feb 13 02:30:23 2018 1518510623 seconds AC off-line: Depleting 66% Left 0 hr. 50 min. 50 sec.
            Battery at Tue Feb 13 02:31:14 2018 1518510674 seconds AC off-line: Depleting 65% Left 0 hr. 50 min. 0 sec.
            Battery at Tue Feb 13 02:32:26 2018 1518510746 seconds AC off-line: Depleting 64% Left 1 hr. 8 min. 50 sec.

            And it writes the log out to the drive, and I get the last line of it to output on my conky screen

            tail -n 1 ~/xbattbar.log | sed -e ‘s/^.*\(line\:.*min\.\).*$/\1/’ -e ‘s/line\: //’

            Output:
            Depleting 64% Left 1 hr. 8 min.

            Also, what is the purpose of the -s scriptfile option? I haven’t found an example where I understand what they are doing with it…

            • This reply was modified 5 years, 2 months ago by BobC.
            Attachments:
            #3329
            Member
            mroot

              Thank you. There was some info on xbattbar on the old forum and I thought an update would be useful to someone especially since xbattbar isn’t well known.

              -mroot

              #3253
              Member
              mroot

                Do you have an old battery that has lost its capacity or an energy intensive cpu that makes monitoring the battery critical? Or even worse do you have both like me? Do you get busy and hide conky behind a window and then realize that your battery is approaching 0% charge? Well, xbattbar may work as battery monitor for you. Xbattbar is an older battery monitor that works on systems that use either acpi or the much older apm for power management. Xbattbar places a line on the length of your screen’s border that changes color as your battery is discharging or charging. The line can be located on the top, bottom, left, or right of the screen depending on the preference of the user. If you move your cursor over the line it shows the exact percentage of charge remaining and whether the battery is charging or discharging.

                I attached pictures of xbattbar in the charging and discharging state below as it looks with fluxbox on my system. Xbattbar being located on the bottom edge of the screen.

                The code used for this is below and is placed in control center —- > session —- > User Desktop-Session for automatic startup.

                xbattbar -t 4 -p 1 -I gray -i black -O purple -o red -c &

                My xbattbar is located on the bottom of the screen since I don’t want to cover my panel which is located on the top of the screen. The bottom position happens to be the default for xbattbar. Most of you have your panel on the bottom and may prefer to have xbattbar on the top of the screen which is easily provided by the following:

                xbattbar -t 4 -p 1 -I gray -i black -O purple -o red -c top &

                Thickness of the bar is controlled by the number following -t in my case the thickness is 4 pixels. The update interval is controlled by the number following -p in my case the update interval is 1 second. Colors are also user selectable. In general, I find xbattbar be unobtrusive and yet highly visible.

                Once you have installed xbattbar on your system additional information can be found by typing:

                man xbattbar or xbattbar –help in a terminal

                -mroot

                • This topic was modified 5 years, 5 months ago by mroot.
              Viewing 6 results - 16 through 21 (of 21 total)