topic title: batti-gtk (SOLVED)
Posts: 4,164
rokytnji
Joined: 20 Feb 2009
#1
Batti is a simple battery monitor for the system tray, similar to batterymon. Unlike the latter batti uses UPower, and if that is missing DeviceKit.Power, for it's power information.

Features

one tray icon per inserted battery
tray icons (dis-)appear with the battery (un-)plugging
notification on low and critical battery status
suspend/hibernate menu on left-click, if allowed by PolicyKit


========= SCRAPER REMOVED AN EMBEDDED LINK HERE ===========
url was:"https://code.google.com/p/batti-gtk/"
linktext was:"https://code.google.com/p/batti-gtk/"
====================================


I am trying this out on my netbook to save some screenspace on my 9" screen since conky is getting sorta big for me. I like the looks of the icon
and it fits nice next to the redshift icon and clock on the taskbar r/h side OK.

Icon is inbetween red bulb and time clock.
Icon is inbetween red bulb and time clock.


Right now I can only turn it on after Icewm startup by left clicking on the batti file. Autostart in ~/.icewm/startup I have tried

/home/harry/batti-0.3.8/batti &

Then dragging batti text exec to /home and make a symlink and do

~/batti & ,or even, sleep 2 ~/batti &

Then tried dragging and dropping batti to /usr/local/bin and symlink to internal batti inside batti-0.3.8 folder and startup line of

sleep 2 batti &

but I am not getting the bugger to autostart when I log out and back in.
__{{emoticon}}__

What I like is that the lightning bolt goes away after the charger cable is unplugged and comes back on again if you re-insert the charger cable.
Just like on my Blackberry phone. It also gives a current status readout on mouse hover over it.

Edit: Logged out and back into all different window managers, Fluxbox,JWM, It works OK in the slit and JWM taskbar also.
Posts: 2,238
dolphin_oracle
Joined: 16 Dec 2007
#2
Nice find roky. I've been looking for something similar, and using xfce-power-manager seemed to be overkill. I'll check this out!
Posts: 1,028
SamK
Joined: 21 Aug 2011
#3
rokytnji wrote:...in ~/.icewm/startup I have tried
/home/harry/batti-0.3.8/batti &
[...]
...but I am not getting the bugger to autostart when I log out and back in.
__{{emoticon}}__
From this it seems you are starting it from the extracted download. Perhaps try installing it.

In in a terminal in the extracted download folder run

Code: Select all

 sudo ./setup.py --dry-run --verbose build install
This will show what the actual command will do without making any changes to your system. After reviewing the pending changes run the command again without the --dry-run parameter and the app will be installed.

Refresh the antiX menu and an entry will be displayed in Applications-->System Tools-->Batti.

Add an entry to your ~/.WM/startup similar to

Code: Select all

# start the battery monitor
batti &
Reboot, and it should start automatically.
Posts: 4,164
rokytnji
Joined: 20 Feb 2009
#4

Code: Select all

warning: install_lib: 'build/lib.linux-i686-2.7' does not exist -- no Python modules to install
was the only error on dry run install/ Full readout.

Code: Select all

harry@biker:~/batti-0.3.8
$ sudo ./setup.py --dry-run --verbose build install
[sudo] password for harry: 
running build
running build_py
creating build
creating build/lib.linux-i686-2.7
creating build/lib.linux-i686-2.7/batti
copying src/Battery.py -> build/lib.linux-i686-2.7/batti
copying src/BatteryMonitor.py -> build/lib.linux-i686-2.7/batti
copying src/Constants.py -> build/lib.linux-i686-2.7/batti
copying src/Notificator.py -> build/lib.linux-i686-2.7/batti
copying src/PowerBackend.py -> build/lib.linux-i686-2.7/batti
copying src/__init__.py -> build/lib.linux-i686-2.7/batti
running build_scripts
creating build/scripts-2.7
copying and adjusting batti -> build/scripts-2.7
changing mode of build/scripts-2.7/batti
compiling po/de.po -> build/mo/de/batti.mo
compiling po/es.po -> build/mo/es/batti.mo
compiling po/ru.po -> build/mo/ru/batti.mo
compiling po/sv.po -> build/mo/sv/batti.mo
running install
running install_lib
warning: install_lib: 'build/lib.linux-i686-2.7' does not exist -- no Python modules to install

running install_scripts
running install_data
creating /usr/local/share/applications
copying data/batti.desktop -> /usr/local/share/applications/
creating /usr/local/share/icons
creating /usr/local/share/icons/hicolor
creating /usr/local/share/icons/hicolor/16x16
creating /usr/local/share/icons/hicolor/16x16/actions
copying data/icons/16x16/actions/batti-hibernate.png -> /usr/local/share/icons/hicolor/16x16/actions
copying data/icons/16x16/actions/batti-suspend.png -> /usr/local/share/icons/hicolor/16x16/actions
creating /usr/local/share/icons/hicolor/16x16/apps
copying data/icons/16x16/apps/batti.png -> /usr/local/share/icons/hicolor/16x16/apps
creating /usr/local/share/icons/hicolor/22x22
creating /usr/local/share/icons/hicolor/22x22/actions
copying data/icons/22x22/actions/batti-hibernate.png -> /usr/local/share/icons/hicolor/22x22/actions
copying data/icons/22x22/actions/batti-suspend.png -> /usr/local/share/icons/hicolor/22x22/actions
creating /usr/local/share/icons/hicolor/22x22/apps
copying data/icons/22x22/apps/batti.png -> /usr/local/share/icons/hicolor/22x22/apps
creating /usr/local/share/icons/hicolor/24x24
creating /usr/local/share/icons/hicolor/24x24/actions
copying data/icons/24x24/actions/batti-hibernate.png -> /usr/local/share/icons/hicolor/24x24/actions
copying data/icons/24x24/actions/batti-suspend.png -> /usr/local/share/icons/hicolor/24x24/actions
creating /usr/local/share/icons/hicolor/24x24/apps
copying data/icons/24x24/apps/batti.png -> /usr/local/share/icons/hicolor/24x24/apps
creating /usr/local/share/icons/hicolor/32x32
creating /usr/local/share/icons/hicolor/32x32/actions
copying data/icons/32x32/actions/batti-hibernate.png -> /usr/local/share/icons/hicolor/32x32/actions
copying data/icons/32x32/actions/batti-suspend.png -> /usr/local/share/icons/hicolor/32x32/actions
creating /usr/local/share/icons/hicolor/32x32/apps
copying data/icons/32x32/apps/batti.png -> /usr/local/share/icons/hicolor/32x32/apps
creating /usr/local/share/icons/hicolor/48x48
creating /usr/local/share/icons/hicolor/48x48/actions
copying data/icons/48x48/actions/batti-hibernate.png -> /usr/local/share/icons/hicolor/48x48/actions
copying data/icons/48x48/actions/batti-suspend.png -> /usr/local/share/icons/hicolor/48x48/actions
creating /usr/local/share/icons/hicolor/48x48/apps
copying data/icons/48x48/apps/batti.png -> /usr/local/share/icons/hicolor/48x48/apps
creating /usr/local/share/icons/hicolor/scalable
creating /usr/local/share/icons/hicolor/scalable/actions
copying data/icons/scalable/actions/batti-hibernate.svg -> /usr/local/share/icons/hicolor/scalable/actions
copying data/icons/scalable/actions/batti-suspend.svg -> /usr/local/share/icons/hicolor/scalable/actions
creating /usr/local/share/icons/hicolor/scalable/apps
copying data/icons/scalable/apps/batti.svg -> /usr/local/share/icons/hicolor/scalable/apps
creating /usr/local/share/locale
creating /usr/local/share/locale/de
creating /usr/local/share/locale/de/LC_MESSAGES
copying build/mo/de/batti.mo -> /usr/local/share/locale/de/LC_MESSAGES
creating /usr/local/share/locale/es
creating /usr/local/share/locale/es/LC_MESSAGES
copying build/mo/es/batti.mo -> /usr/local/share/locale/es/LC_MESSAGES
creating /usr/local/share/locale/ru
creating /usr/local/share/locale/ru/LC_MESSAGES
copying build/mo/ru/batti.mo -> /usr/local/share/locale/ru/LC_MESSAGES
creating /usr/local/share/locale/sv
creating /usr/local/share/locale/sv/LC_MESSAGES
copying build/mo/sv/batti.mo -> /usr/local/share/locale/sv/LC_MESSAGES
running install_egg_info
Writing /usr/local/lib/python2.7/dist-packages/batti-0.3.8.egg-info
harry@biker:~/batti-0.3.8
If warning is nothing to be concerned about. Will

Code: Select all

sudo ./setup.py --verbose build install
Be enough to do the job SamK?

DOH __{{emoticon}}__
After reviewing the pending changes run the command again without the --dry-run parameter and the app will be installed

========= SCRAPER REMOVED AN EMBEDDED LINK HERE ===========
url was:"https://www.google.com/#q=lib.linux-i686-2.7+debian"
linktext was:"Searching shows mostly Ubuntu current stuff"
====================================


Just the error message is the only question. Sorry.
Posts: 4,164
rokytnji
Joined: 20 Feb 2009
#5
Damn, this dumb-ass biker thinks he is looking at a kernel log.

Code: Select all

$ apt-cache policy python 2.7
python:
  Installed: 2.7.3-4+deb7u1
  Candidate: 2.7.3-4+deb7u1
  Version table:
 *** 2.7.3-4+deb7u1 0
        500 http://ftp.us.debian.org/debian/ wheezy/main i386 Packages
        100 /var/lib/dpkg/status
python2.7-openscap:
  Installed: (none)
  Candidate: (none)
  Version table:
<snip> 
Tired of scrolling
Trust me anybody reading this, I am a long ass readout.
Posts: 1,028
SamK
Joined: 21 Aug 2011
#6
rokytnji wrote:

Code: Select all

warning: install_lib: 'build/lib.linux-i686-2.7' does not exist -- no Python modules to install
was the only error on dry run install...
As far as iI can tell this is produced because of the --dry-run parameter. It prevents the file from being created
during the build section, therefore cannot be found when it is referenced later in the install section.

To test it, I booted live antiX-13.1-Full ISO.
Using the command with the --dry-run parameter, the error message is generated.
Installing Batti (i.e. excluding --dry-run) completes successfully without producing the error message.
Posts: 4,164
rokytnji
Joined: 20 Feb 2009
#7
Ok, nothing ventured, nothing gained. If it breaks. It breaks. I'll post back with results.

Just figured I would depart from my bull rush routine for a change and show some caution. Something I never did very well in any thing I try out when new at it.

Code: Select all

harry@biker:~/batti-0.3.8
$ sudo ./setup.py --verbose build install
[sudo] password for harry: 
running build
running build_py
creating build/lib.linux-i686-2.7
creating build/lib.linux-i686-2.7/batti
copying src/Battery.py -> build/lib.linux-i686-2.7/batti
copying src/BatteryMonitor.py -> build/lib.linux-i686-2.7/batti
copying src/Constants.py -> build/lib.linux-i686-2.7/batti
copying src/Notificator.py -> build/lib.linux-i686-2.7/batti
copying src/PowerBackend.py -> build/lib.linux-i686-2.7/batti
copying src/__init__.py -> build/lib.linux-i686-2.7/batti
running build_scripts
creating build/scripts-2.7
copying and adjusting batti -> build/scripts-2.7
changing mode of build/scripts-2.7/batti from 644 to 755
running install
running install_lib
creating /usr/local/lib/python2.7/dist-packages/batti
copying build/lib.linux-i686-2.7/batti/Battery.py -> /usr/local/lib/python2.7/dist-packages/batti
copying build/lib.linux-i686-2.7/batti/BatteryMonitor.py -> /usr/local/lib/python2.7/dist-packages/batti
copying build/lib.linux-i686-2.7/batti/Constants.py -> /usr/local/lib/python2.7/dist-packages/batti
copying build/lib.linux-i686-2.7/batti/Notificator.py -> /usr/local/lib/python2.7/dist-packages/batti
copying build/lib.linux-i686-2.7/batti/PowerBackend.py -> /usr/local/lib/python2.7/dist-packages/batti
copying build/lib.linux-i686-2.7/batti/__init__.py -> /usr/local/lib/python2.7/dist-packages/batti
byte-compiling /usr/local/lib/python2.7/dist-packages/batti/Battery.py to Battery.pyc
byte-compiling /usr/local/lib/python2.7/dist-packages/batti/BatteryMonitor.py to BatteryMonitor.pyc
byte-compiling /usr/local/lib/python2.7/dist-packages/batti/Constants.py to Constants.pyc
byte-compiling /usr/local/lib/python2.7/dist-packages/batti/Notificator.py to Notificator.pyc
byte-compiling /usr/local/lib/python2.7/dist-packages/batti/PowerBackend.py to PowerBackend.pyc
byte-compiling /usr/local/lib/python2.7/dist-packages/batti/__init__.py to __init__.pyc
running install_scripts
copying build/scripts-2.7/batti -> /usr/local/bin
changing mode of /usr/local/bin/batti to 755
running install_data
creating /usr/local/share/applications
copying data/batti.desktop -> /usr/local/share/applications/
creating /usr/local/share/icons
creating /usr/local/share/icons/hicolor
creating /usr/local/share/icons/hicolor/16x16
creating /usr/local/share/icons/hicolor/16x16/actions
copying data/icons/16x16/actions/batti-hibernate.png -> /usr/local/share/icons/hicolor/16x16/actions
copying data/icons/16x16/actions/batti-suspend.png -> /usr/local/share/icons/hicolor/16x16/actions
creating /usr/local/share/icons/hicolor/16x16/apps
copying data/icons/16x16/apps/batti.png -> /usr/local/share/icons/hicolor/16x16/apps
creating /usr/local/share/icons/hicolor/22x22
creating /usr/local/share/icons/hicolor/22x22/actions
copying data/icons/22x22/actions/batti-hibernate.png -> /usr/local/share/icons/hicolor/22x22/actions
copying data/icons/22x22/actions/batti-suspend.png -> /usr/local/share/icons/hicolor/22x22/actions
creating /usr/local/share/icons/hicolor/22x22/apps
copying data/icons/22x22/apps/batti.png -> /usr/local/share/icons/hicolor/22x22/apps
creating /usr/local/share/icons/hicolor/24x24
creating /usr/local/share/icons/hicolor/24x24/actions
copying data/icons/24x24/actions/batti-hibernate.png -> /usr/local/share/icons/hicolor/24x24/actions
copying data/icons/24x24/actions/batti-suspend.png -> /usr/local/share/icons/hicolor/24x24/actions
creating /usr/local/share/icons/hicolor/24x24/apps
copying data/icons/24x24/apps/batti.png -> /usr/local/share/icons/hicolor/24x24/apps
creating /usr/local/share/icons/hicolor/32x32
creating /usr/local/share/icons/hicolor/32x32/actions
copying data/icons/32x32/actions/batti-hibernate.png -> /usr/local/share/icons/hicolor/32x32/actions
copying data/icons/32x32/actions/batti-suspend.png -> /usr/local/share/icons/hicolor/32x32/actions
creating /usr/local/share/icons/hicolor/32x32/apps
copying data/icons/32x32/apps/batti.png -> /usr/local/share/icons/hicolor/32x32/apps
creating /usr/local/share/icons/hicolor/48x48
creating /usr/local/share/icons/hicolor/48x48/actions
copying data/icons/48x48/actions/batti-hibernate.png -> /usr/local/share/icons/hicolor/48x48/actions
copying data/icons/48x48/actions/batti-suspend.png -> /usr/local/share/icons/hicolor/48x48/actions
creating /usr/local/share/icons/hicolor/48x48/apps
copying data/icons/48x48/apps/batti.png -> /usr/local/share/icons/hicolor/48x48/apps
creating /usr/local/share/icons/hicolor/scalable
creating /usr/local/share/icons/hicolor/scalable/actions
copying data/icons/scalable/actions/batti-hibernate.svg -> /usr/local/share/icons/hicolor/scalable/actions
copying data/icons/scalable/actions/batti-suspend.svg -> /usr/local/share/icons/hicolor/scalable/actions
creating /usr/local/share/icons/hicolor/scalable/apps
copying data/icons/scalable/apps/batti.svg -> /usr/local/share/icons/hicolor/scalable/apps
creating /usr/local/share/locale
creating /usr/local/share/locale/de
creating /usr/local/share/locale/de/LC_MESSAGES
copying build/mo/de/batti.mo -> /usr/local/share/locale/de/LC_MESSAGES
creating /usr/local/share/locale/es
creating /usr/local/share/locale/es/LC_MESSAGES
copying build/mo/es/batti.mo -> /usr/local/share/locale/es/LC_MESSAGES
creating /usr/local/share/locale/ru
creating /usr/local/share/locale/ru/LC_MESSAGES
copying build/mo/ru/batti.mo -> /usr/local/share/locale/ru/LC_MESSAGES
creating /usr/local/share/locale/sv
creating /usr/local/share/locale/sv/LC_MESSAGES
copying build/mo/sv/batti.mo -> /usr/local/share/locale/sv/LC_MESSAGES
running install_egg_info
Writing /usr/local/lib/python2.7/dist-packages/batti-0.3.8.egg-info
harry@biker:~/batti-0.3.8
Now to edit startups and reboot with the news.
rokytnji
Posts: 4,164
rokytnji
Joined: 20 Feb 2009
#8
Reboot done

Code: Select all

harry@biker:~
$ locate batti
harry@biker:~
$ which batti
/usr/local/bin/batti
harry@biker:~
Located in Applications>System Tools>Batti
in Icewm menu.

Code: Select all

sleep 2 batti &
In ~/.icewm/startup and ~/fluxbox/startup

a no go but will start from menu when clicked. My jwm ~/.jwm/startup is

Code: Select all

(sleep 2 && batti) &
Maybe the full path /usr/local/bin/batti is needed? I have not logged out yet and tested JWM or Fluxbox yet but my hopes aint high.

Edit: shoot, whaddya know. Batti auto starts in jWM OK. Just being stubborn in Icewm and Fluxbox. I said screw it and commented out my BATT: entries in ~/.conky/conky_icewm and ~/.conkyrc since a startup glitch is not a game ender for me yet. __{{emoticon}}__
Posts: 1,028
SamK
Joined: 21 Aug 2011
#9
rokytnji wrote:In ~/.icewm/startup and ~/fluxbox/startup
a no go but will start from menu when clicked.
[...]
...commented out my BATT: entries in ~/.conky/conky_icewm and ~/.conkyrc...
Cannot reproduce this behaviour.
Automatically starting Batti and Conky (inc BATT) via IceWM and JWM startup files works as expected.

rokytnji wrote:

Code: Select all

sleep 2 batti &
This command looks malformed.

Try

Code: Select all

sleep 2 && batti &
Alternatively try the command I suggested previously
SamK wrote:

Code: Select all

# start the battery monitor
batti &
I usually strip the sleep commands from the WM startup file without experiencing any ill affects.
In return a faster startup time is obtained.
Posts: 4,164
rokytnji
Joined: 20 Feb 2009
#10
I changed to

Code: Select all

batti &
in ~/.icewm/startup and ~/.fluxbox/startup as SamK suggested and all is well. Batti auto starts now on login on all Window Managers.

Thanks a bunch SamK for being a bro in this. I owe ya as usual. I am going to mark this thread as solved.
Posts: 4,164
rokytnji
Joined: 20 Feb 2009
#11
As stated by skidoo in this thread post48440.html#p48440
rok, do you remember the"batti" tray widget?
batti-gtk-solved-t4662.html?hilit=battery%20monitor
It's not in debian repos & its googlecode project page is gone
I'm just spreading the love.



Nothing newer than 0.3.8 that I know of.

Edit; seems there is

post48442.html#p48442

Anyways. Still works fine and dandy for me.
Damn. I went to arch linux page and the source file is gone from there also.

========= SCRAPER REMOVED AN EMBEDDED LINK HERE ===========
url was:"https://aur.archlinux.org/packages/batti/"
linktext was:"https://aur.archlinux.org/packages/batti/"
====================================


Maybe the issues got it pulled?

========= SCRAPER REMOVED AN EMBEDDED LINK HERE ===========
url was:"https://code.google.com/archive/p/batti-gtk/issues"
linktext was:"https://code.google.com/archive/p/batti-gtk/issues"
====================================
Posts: 604
thriftee
Joined: 27 Feb 2009
#12
I downloaded the 3.8 version and installed it as shown above, but when I try to run it from the menu nothing happens. And if I try it from Terminal as root it comes back with an error message. Can anyone tell me how to correct it? Thanks...

#batti
Can't import batti's BatteryMonitor module
Exiting
Posts: 1,444
skidoo
Joined: 09 Feb 2012
#13
Did you run 'setup.py' or did you just extract the files from archive and execute 'batti'?

Find out whether the"BatteryMonitor.py" file exists and, if so, where is it? What is its filepath?
sudo updatedb
sudo locate BatteryMonitor.py

Code: Select all

    if os.path.isdir(os.path.join(".","src")) and os.path.isfile(os.path.join(".","setup.py")):
        from src import BatteryMonitor
    else:
        from batti import BatteryMonitor
FYI
When batti runs and detects 'src' subdirectory exists (setup.py has not already run), it expects to find BatteryMonitor.py in that child subdirectory named 'src'.
Posts: 604
thriftee
Joined: 27 Feb 2009
#14
Great clues, Skidoo!

BatteryMinitor was there, but I was in terminal with batti in the directory above it. Once I moved up a level the error went away, and was replaced by a different error saying DeviceKit.Power or UPower couldn't be initialized, so I had seen a package called upower, so I installed it, and called batti again and no more error.. Being the oblivious type, it would help for me if the battery icon blinked red before things died, so I will go back and see if I can implements the very low level blink.

Thanks for the help.

A question... Since antiX doesn't seem to have a battery monitor, why don't we make a package out of this that could be included in Synaptic? Od at least one that could be easily installed? Of coourse, as you might guess, I've never done that berfore.
Posts: 1,444
skidoo
Joined: 09 Feb 2012
#15
It's a tiny utility (148Kb, including icon imagefiles) and many folks would probably appreciate having it preinstalled...

...but antiX users already have battery info available via the conky display.
(Yeah, available _if_ they read the docs and know to remove those configfile comment chars, eh?)

...and the debian packaging files inside the debfile would probably be larger than the payload.

If someone creates a .deb for batti, I guess they'll know to check (and mark upower as a"depends" for batti).
In the meantime, the batti should be modded so that it tests for presence of upower, and balks if that's not found.
edit: I typed"the batti". What I meant was the file that is named (literally) 'batti' inside the the archivefile

Code: Select all

try:
    if os.path.isfile('/usr/lib/upower/upowerd') == False:
except ImportError:
    sys.stderr.write("Please install debian package 'upower' before trying to use batti.\nExiting\n")
    sys.exit(1)

if __name__ =="__main__":
The line if __name__ =="__main__": already exists.
I'm just showing it for contextual reference; the code performing the extra check should be inserted immediately above that line.