added alternate codepath that gets battery info from dbus when power kernel is not...
authorCreamy Goodness <lance.colton@gmail.com>
Tue, 26 Oct 2010 08:00:49 +0000 (02:00 -0600)
committerCreamy Goodness <lance.colton@gmail.com>
Sat, 18 Dec 2010 21:48:49 +0000 (14:48 -0700)
diskio and temperature won't work without power kernel
minor changes to conf file, version number, changelog for testing purposes

configure
configure.ac
configure.ac.in
debian/changelog
debian/conky.conf
src/conky.h
src/dbus/Makefile
src/linux.c

index 23fc497..e149bfa 100644 (file)
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.61 for Conky 1.8.0.
+# Generated by GNU Autoconf 2.61 for Conky 1.8.5.
 #
 # Report bugs to <brenden1@users.sourceforge.net>.
 #
@@ -728,8 +728,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
 # Identity of this package.
 PACKAGE_NAME='Conky'
 PACKAGE_TARNAME='conky'
-PACKAGE_VERSION='1.8.0'
-PACKAGE_STRING='Conky 1.8.0'
+PACKAGE_VERSION='1.8.5'
+PACKAGE_STRING='Conky 1.8.5'
 PACKAGE_BUGREPORT='brenden1@users.sourceforge.net'
 
 # Factoring default headers for most tests.
@@ -1528,7 +1528,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures Conky 1.8.0 to adapt to many kinds of systems.
+\`configure' configures Conky 1.8.5 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1602,7 +1602,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of Conky 1.8.0:";;
+     short | recursive ) echo "Configuration of Conky 1.8.5:";;
    esac
   cat <<\_ACEOF
 
@@ -1810,7 +1810,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-Conky configure 1.8.0
+Conky configure 1.8.5
 generated by GNU Autoconf 2.61
 
 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1824,7 +1824,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by Conky $as_me 1.8.0, which was
+It was created by Conky $as_me 1.8.5, which was
 generated by GNU Autoconf 2.61.  Invocation command line was
 
   $ $0 $@
@@ -2487,7 +2487,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE=conky
- VERSION=1.8.0
+ VERSION=1.8.5
 
 
 cat >>confdefs.h <<_ACEOF
@@ -29510,7 +29510,7 @@ exec 6>&1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by Conky $as_me 1.8.0, which was
+This file was extended by Conky $as_me 1.8.5, which was
 generated by GNU Autoconf 2.61.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -29563,7 +29563,7 @@ Report bugs to <bug-autoconf@gnu.org>."
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF
 ac_cs_version="\\
-Conky config.status 1.8.0
+Conky config.status 1.8.5
 configured by $0, generated by GNU Autoconf 2.61,
   with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
 
index 21ff0cd..11dd695 100644 (file)
@@ -3,7 +3,7 @@
 dnl major, minor and micro version macros.
 m4_define([conky_version_major], [1])
 m4_define([conky_version_minor], [8])
-m4_define([conky_version_micro], [0])
+m4_define([conky_version_micro], [5])
 m4_define([conky_version_tag]) dnl, [pre]) dnl [] for releases
 m4_define([conky_version_revision],[_rc3])
 m4_define([conky_version],
index 8a51790..3f40c2b 100644 (file)
@@ -3,7 +3,7 @@
 dnl major, minor and micro version macros.
 m4_define([conky_version_major], [1])
 m4_define([conky_version_minor], [8])
-m4_define([conky_version_micro], [2])
+m4_define([conky_version_micro], [5])
 m4_define([conky_version_tag], [pre]) dnl [] for releases
 m4_define([conky_version_revision],[_pre@REVISION@])
 m4_define([conky_version],
index b362b9f..8a631c9 100644 (file)
@@ -1,4 +1,13 @@
-conky (1.8.0-1) unstable; urgency=low
+conky (1.8.5-1) unstable; urgency=low
+
+  * New maemo release:
+    - fixes
+    - changes
+      + example
+
+ -- Lance Colton <lance.colton@gmail.com>  Thu, 21 Oct 2010 12:00:00 -0700
+ conky (1.8.0-1) unstable; urgency=low
 
   * New upstream release:
     - add AF_UNIX socket support
index d93c408..55ef927 100644 (file)
@@ -47,29 +47,39 @@ xftfont Droid Sans Mono:size=11
 xftalpha 0.8
 
 TEXT
-${color       }$nodename - $sysname $kernel on $machine ${color 4072a5}$alignr Uptime:$color $uptime ${color #4072a5}Battery:${color}${battery_short}
+${color       }$sysname $kernel on $machine ${color 4072a5}$alignr Uptime:$color $uptime ${color #4072a5}Battery: ${color}${battery_short} ${battery_temp}°C ${battery_volts}mV
 ${color 4072a5}CPU:${goto 45}${color red}${voffset 2}${cpubar cpu0 14,240}${goto 300}${color 4072a5}Load 1/5/15:$color $loadavg $alignr ${color 4072a5}Processes:$color $processes ${color 4072a5}Running:$color $running_processes
 ${color       }${alignr 460}${voffset -20}$cpu%${voffset 0}#can't alignr two things on the same line. alignr is the only way to get the % symbol to stay lined up. it will move if you use goto
 ${color       }${goto 119}$freq MHz
 ${color 4072a5}CPU:${color black}${cpugraph 16,240 ffffff ff0000 -t}${color 4072a5}${goto 300}Load1 avg:${color black}${loadgraph 16,105 ffffff ff0000 -t -1}${color 4072a5} Dio:${color black}${diskiograph /dev/mmcblk0 16,105 ffffff 00ff00 -t -1}${color 4072a5} Mem:${color black}${memgraph 16,105 ffffff 0000ff -t}
-${color 4072a5}RAM:${goto 45}${color blue}${voffset 2}${membar 16,240}
-${color       }${voffset -20}$color${goto 110}$mem${goto 190}/ $memmax${goto 310}$memperc%${goto 350}
-${color 4072a5}Swap Usage:$color${goto 110}$swap${goto 190}/ $swapmax${goto 310}$swapperc%${goto 350}${color lightgrey}${swapbar 10}
-${color 4072a5}rootfs${goto 110}$color${fs_free /}${goto 190}/ ${fs_size /} ${color grey}${goto 310}free${goto 350}${color lightgrey}${fs_bar 10 /}
-${color 4072a5}home${goto 110}$color${fs_free /home}${goto 190}/ ${fs_size /home} ${color grey}${goto 310}free${goto 350}${color lightgrey}${fs_bar 10 /home}
-${if_mounted /home/user/MyDocs}${color 4072a5}MyDocs${goto 110}$color${fs_free /home/user/MyDocs}${goto 190}/ ${fs_size /home/user/MyDocs} ${color grey}${goto 310}free${goto 350}${color lightgrey}${fs_bar 10 /home/user/MyDocs}$endif
-${if_mounted /media/mmc1}${color 4072a5}SD Card${goto 110}$color${fs_free /media/mmc1}${goto 190}/ ${fs_size /media/mmc1} ${color grey}${goto 310}free${goto 350}${color lightgrey}${fs_bar 10 /media/mmc1}$endif
-${if_up gprs0}${color 4072a5}gprs0: ${color 4072a5}Up:$color ${upspeed gprs0} kB/s ${color 4072a5}Down:$color ${downspeed gprs0} kB/s 
-${color 4072a5}gprs0 Up: ${color black}${upspeedgraph gprs0 20,290 ff0000 00ff00}$alignr${color 4072a5}gprs0 Down: ${color black}${downspeedgraph gprs0 20,290 00ff0000 ff0000}$else${if_empty ${wireless_essid wlan0}}$else${color #4072a5}wlan0 ESSID: $color${wireless_essid wlan0} ${color #4072a5}Rate: ${color}${wireless_bitrate wlan0} ${color #4072a5}Connection Quality: $color${wireless_link_qual_perc wlan0}% ${color #4072a5}Up:$color ${upspeed wlan0} kB/s ${color grey} - ${color #4072a5}Down:$color ${downspeed wlan0} kB/s 
+${color 4072a5}RAM:${goto 47}${color blue}${voffset 2}${membar 16,240}
+${color       }${voffset -20}${goto 110}$mem${goto 160}/ $memmax
+${color       }${alignr 525}${voffset -18}$memperc%
+${color 4072a5}${voffset -18}${goto 315} Cell Radio: $color ${cell_radio_dbm}dBm ${cell_radio_percent}%
+${color 4072a5}Swap:${goto 48}${color green}${swapbar 16,240}                     
+${color       }${voffset -18}${goto 110}$swap${goto 160}/ $swapmax
+${color       }${alignr 525}${voffset -18}$swapperc%
+${color 4072a5}rootfs:${goto 70}${color darkgreen}${fs_bar 16,240 /}
+${color       }${voffset -18}${goto 110}${fs_used /}${goto 160}/ ${fs_size /}
+${color       }${alignr 490}${voffset -20}(${fs_free /})
+${color 4072a5}home:${goto 70}${color darkgreen}${fs_bar 16,240 /home}
+${color       }${voffset -18}${goto 110}${fs_used /home}${goto 160}/ ${fs_size /home}
+${color       }${alignr 490}${voffset -20}(${fs_free /home})
+${if_mounted /home/user/MyDocs}${color 4072a5}MyDocs:${goto 70}${color darkgreen}${fs_bar 16,240 /home/user/MyDocs}
+${color       }${voffset -18}${goto 110}${fs_used /home/user/MyDocs}${goto 160}/ ${fs_size /home/user/MyDocs}
+${color       }${alignr 490}${voffset -20}(${fs_free /home/user/MyDocs})$endif
+${if_mounted /media/mmc1}${color 4072a5}MicroSD:${goto 70}${color darkgreen}${fs_bar 16,240 /media/mmc1}
+${color       }${voffset -18}${goto 110}${fs_used /media/mmc1}${goto 160}/ ${fs_size /media/mmc1}
+${color       }${alignr 490}${voffset -20}(${fs_free /media/mmc1})$endif
+${if_up gprs0}${color 4072a5}gprs0: ${color 4072a5}Up:$color ${upspeed gprs0}/s ${color 4072a5}Down:$color ${downspeed gprs0}/s 
+${color 4072a5}gprs0 Up: ${color black}${upspeedgraph gprs0 20,290 ff0000 00ff00}$alignr${color 4072a5}gprs0 Down: ${color black}${downspeedgraph gprs0 20,290 00ff0000 ff0000}$else${if_empty ${wireless_essid wlan0}}$else${color #4072a5}wlan0 ESSID: $color${wireless_essid wlan0} ${color #4072a5}Rate: ${color}${wireless_bitrate wlan0} ${color #4072a5}Connection Quality: $color${wireless_link_qual_perc wlan0}% ${color #4072a5}Up:$color ${upspeed wlan0}/s ${color grey} - ${color #4072a5}Down:$color ${downspeed wlan0}/s 
 ${color 4072a5}wlan0 Up: ${color black}${upspeedgraph wlan0 20,290 00ff00 ff0000}$alignr${color 4072a5}wlan0 Down: ${color black}${downspeedgraph wlan0 20,290 ff0000 00ff00}$endif$endif
-${color 4072a5}CONNECTIONS [$color${tcp_portmon 1 65535 count}${color 4072a5}](local:remote:port):${goto 400}$color${tcp_portmon 1 65535 lservice 3}~${scroll 34 5${tcp_portmon 1 65535 rhost 3}}${goto 750}:${tcp_portmon 1 65535 rservice 3}
-$color${tcp_portmon 1 65535 lservice 0}:${scroll 34 5${tcp_portmon 1 65535 rhost 0}}${goto 362}:${scroll 5 2${tcp_portmon 1 65535 rservice 0}}$color ${tcp_portmon 1 65535 lservice 4}:${scroll 34 5${tcp_portmon 1 65535 rhost 4}}:${tcp_portmon 1 65535 rservice 4}
-$color${tcp_portmon 1 65535 lservice 1}:${scroll 34 5${tcp_portmon 1 65535 rhost 1}}${goto 362}:${scroll 5 2${tcp_portmon 1 65535 rservice 1}}$color ${tcp_portmon 1 65535 lservice 5}:${scroll 34 5${tcp_portmon 1 65535 rhost 5}}:${tcp_portmon 1 65535 rservice 5}
-$color${tcp_portmon 1 65535 lservice 2}:${scroll 34 5${tcp_portmon 1 65535 rhost 2}}${goto 362}:${scroll 5 2${tcp_portmon 1 65535 rservice 2}}$color ${tcp_portmon 1 65535 lservice 6}:${scroll 34 5${tcp_portmon 1 65535 rhost 6}}:${tcp_portmon 1 65535 rservice 6}
-${color 4072a5}Top CPU%          CPU%  MEM%       ${goto 257}${color 4072a5} | ${color 4072a5}Top Total Memory  RAM     VM                               ${goto 555}${color 4072a5}| ${color 4072a5}CPU TIME         HH:MM.SS
+${color 4072a5}CONNECTIONS [$color${tcp_portmon 1 65535 count}${color 4072a5}] (lport:rservice:rport):$color                                  ${goto 405}${tcp_portmon 1 65535 lservice 3}${goto 450}:${scroll 32 5${tcp_portmon 1 65535 rhost 3}}${goto 744}:${scroll 5 1 ${tcp_portmon 1 65535 rservice 3}}
+$color${tcp_portmon 1 65535 lservice 0}${goto 50}:${scroll 32 5${tcp_portmon 1 65535 rhost 0}}${goto 345}:${scroll 5 2${tcp_portmon 1 65535 rservice 0}}${goto 405}${tcp_portmon 1 65535 lservice 4}${goto 450}:${scroll 32 5${tcp_portmon 1 65535 rhost 4}}${goto 744}:${scroll 5 1 ${tcp_portmon 1 65535 rservice 4}}
+$color${tcp_portmon 1 65535 lservice 1}${goto 50}:${scroll 32 5${tcp_portmon 1 65535 rhost 1}}${goto 345}:${scroll 5 2${tcp_portmon 1 65535 rservice 1}}${goto 405}${tcp_portmon 1 65535 lservice 5}${goto 450}:${scroll 32 5${tcp_portmon 1 65535 rhost 5}}${goto 744}:${scroll 5 1 ${tcp_portmon 1 65535 rservice 5}}
+$color${tcp_portmon 1 65535 lservice 2}${goto 50}:${scroll 32 5${tcp_portmon 1 65535 rhost 2}}${goto 345}:${scroll 5 2${tcp_portmon 1 65535 rservice 2}}${goto 405}${tcp_portmon 1 65535 lservice 6}${goto 450}:${scroll 32 5${tcp_portmon 1 65535 rhost 6}}${goto 744}:${scroll 5 1 ${tcp_portmon 1 65535 rservice 6}}
+${color 4072a5}Top CPU%          CPU%  MEM%       ${goto 257}${color 4072a5} | ${color 4072a5}Top Total Memory  RAM     VM                               ${goto 555}${color 4072a5}| ${color 4072a5}Top CPU TIME     MM:SS.cs
 ${color red}${top name 1}${top cpu 1}${top mem 1} ${goto 257}${color 4072a5} | ${color red}${top_mem name 1}${top_mem mem_res 1}  ${top_mem mem_vsize 1} ${goto 555}${color 4072a5}| ${color red}${top_time name 1}${top_time time 1} ${top_time cpu 1}
 $color${top name 2}${top cpu 2}${top mem 2}       ${goto 257}${color 4072a5} | ${color    }${top_mem name 2}${top_mem mem_res 2}  ${top_mem mem_vsize 2} ${goto 555}${color 4072a5}| ${color    }${top_time name 2}${top_time time 2} ${top_time cpu 2}
 $color${top name 3}${top cpu 3}${top mem 3}       ${goto 257}${color 4072a5} | ${color    }${top_mem name 3}${top_mem mem_res 3}  ${top_mem mem_vsize 3} ${goto 555}${color 4072a5}| ${color    }${top_time name 3}${top_time time 3} ${top_time cpu 3}
-This default config file was loaded from /etc/conky/conky.conf  To customize just copy it to
-/home/user/MyDocs or download or create a new one.
-$color---------1---------2---------3---------4---------5---------6---------7---------8---------9---------0---------1    
\ No newline at end of file
+$color---------1---------2---------3---------4---------5---------6---------7---------8---------9---------0---------1
index 442211d..9ab26bf 100644 (file)
@@ -205,7 +205,10 @@ enum {
        BATTERY_VOLTS,
        BATTERY_TEMP,
        DBUS_CELL_DBM,
-       DBUS_CELL_PERCENT
+       DBUS_CELL_PERCENT,
+       DBUS_HAL_BATTERY_CHRG_STATUS,
+       DBUS_HAL_BATTERY_PERCENT,
+       DBUS_HAL_BATTERY_VOLTS_CURRENT
 };
 
 /* if_up strictness selector
index 6a6266c..f031420 100644 (file)
@@ -180,7 +180,7 @@ BMPx_CFLAGS =
 BMPx_LIBS = 
 BUILD_APCUPSD_FALSE = #
 BUILD_APCUPSD_TRUE = 
-BUILD_ARCH = Linux 2.6.32-24-generic (arm)
+BUILD_ARCH = Linux 2.6.32-25-generic (arm)
 BUILD_AUDACIOUS_FALSE = 
 BUILD_AUDACIOUS_TRUE = #
 BUILD_BMPX_FALSE = 
@@ -189,7 +189,7 @@ BUILD_CONFIG_OUTPUT_FALSE = #
 BUILD_CONFIG_OUTPUT_TRUE = 
 BUILD_CURL_FALSE = 
 BUILD_CURL_TRUE = #
-BUILD_DATE = Tue Oct 19 21:04:16 PDT 2010
+BUILD_DATE = Tue Oct 26 00:32:11 PDT 2010
 BUILD_EVE_FALSE = 
 BUILD_EVE_TRUE = #
 BUILD_FREEBSD_FALSE = 
@@ -287,9 +287,9 @@ OBJEXT = o
 PACKAGE = conky
 PACKAGE_BUGREPORT = brenden1@users.sourceforge.net
 PACKAGE_NAME = Conky
-PACKAGE_STRING = Conky 1.8.0
+PACKAGE_STRING = Conky 1.8.5
 PACKAGE_TARNAME = conky
-PACKAGE_VERSION = 1.8.0
+PACKAGE_VERSION = 1.8.5
 PATH_SEPARATOR = :
 PKG_CONFIG = /scratchbox/tools/bin/pkg-config
 RANLIB = ranlib
@@ -297,7 +297,7 @@ SED = /scratchbox/tools/bin/sed
 SET_MAKE = 
 SHELL = /bin/sh
 STRIP = strip
-VERSION = 1.8.0
+VERSION = 1.8.5
 X11_CFLAGS =  
 X11_LIBS = -lX11  
 XDamage_CFLAGS =  
index abd60e6..1759bbe 100644 (file)
@@ -1558,11 +1558,11 @@ PHYSDEVBUS=i2c
 PHYSDEVDRIVER=bq27200-battery
 POWER_SUPPLY_NAME=bq27200-0
 POWER_SUPPLY_TYPE=Battery
-POWER_SUPPLY_PRESENT=1                                                                                                 << this is always 1, it means the battery is inserted
-POWER_SUPPLY_VOLTAGE_NOW=4039                                                                          << this keeps updating during charging
-POWER_SUPPLY_CURRENT_NOW=1960                   << this goes negative when charging!
-POWER_SUPPLY_CAPACITY=98                                                                                               << supposed to be the %, I THOUGHT it stops updating when charging until it hits 100%, but maybe not?
-POWER_SUPPLY_TEMP=39                                                                                                           << only temperature sensor in n900 :(
+POWER_SUPPLY_PRESENT=1                         << this is always 1, it means the battery is inserted
+POWER_SUPPLY_VOLTAGE_NOW=4039          << this keeps updating during charging
+POWER_SUPPLY_CURRENT_NOW=1960       << this goes negative when charging!
+POWER_SUPPLY_CAPACITY=98                       << supposed to be the %, I THOUGHT it stops updating when charging until it hits 100%, but maybe not?
+POWER_SUPPLY_TEMP=39                           << only temperature sensor in n900 :(
 */
 
 #define SYSFS_BATTERY_BASE_PATH "/sys/class/power_supply"
@@ -1589,6 +1589,9 @@ static unsigned char last_cell_radio_dbm;
 //eg 100
 static unsigned char last_cell_radio_percent;
 
+//eg 'full' 'on' 'off'
+static char last_batt_charge_status[16];
+
 //eg 35
 static int last_battery_temp[MAX_BATTERY_COUNT];
 
@@ -1620,24 +1623,22 @@ void init_batteries(void)
 
 int get_battery_idx(const char *bat)
 {
-       int idx;
-
-       for (idx = 0; idx < MAX_BATTERY_COUNT; idx++) {
-               if (!strlen(batteries[idx]) || !strcmp(batteries[idx], bat)) {
-                       break;
-               }
-       }
-
-       /* if not found, enter a new entry */
-       if (!strlen(batteries[idx])) {
-               snprintf(batteries[idx], 31, "%s", bat);
-       }
+//     int idx;
+//
+//     for (idx = 0; idx < MAX_BATTERY_COUNT; idx++) {
+//             if (!strlen(batteries[idx]) || !strcmp(batteries[idx], bat)) {
+//                     break;
+//             }
+//     }
+//
+//     /* if not found, enter a new entry */
+//     if (!strlen(batteries[idx])) {
+//             snprintf(batteries[idx], 31, "%s", bat);
+//     }
 
-       return idx;
+       return 0;
 }
 
-//void set_return_value(char *buffer, unsigned int n, int item, int idx);
-
 static int dbus_queue = 0;
 
 void set_dbus_retval(char *buffer, unsigned int n, int item);
@@ -1649,16 +1650,19 @@ DBusMessageIter iter;
 DBusBusType type;
 int message_type;
 DBusMessage *reply;
+
 void get_dbus_stuff(char *buffer,unsigned int intMax_length, int item)
 {
        char method[128];
        char path[128];
        char dest[128];
-       if (dbus_queue > 0)
+       char *args = "";
+       if (dbus_queue > 10)
        {
-               set_dbus_retval(buffer, intMax_length, item);
-               //snprintf(buffer,intMax_length,"%i",last_cell_radio_dbm);
-               return;
+               fprintf (stderr, "too much dbus queuing");
+               exit(1);
+//             set_dbus_retval(buffer, intMax_length, item);
+//             return;
        }
        dbus_queue++;//prevent a queue from forming on these requests...
 //fetch data from dbus, store in here as last_cell_radio_dbm
@@ -1694,6 +1698,42 @@ void get_dbus_stuff(char *buffer,unsigned int intMax_length, int item)
                message = dbus_message_new_method_call (dest,path,"Phone.Net",method);
                dbus_message_set_auto_start (message, TRUE);
                break;
+       case DBUS_HAL_BATTERY_CHRG_STATUS:
+               // 'full' 'on' 'off'
+               snprintf(method,127,"GetProperty");
+               args = "maemo.rechargeable.charging_status";
+               snprintf(path,127,"/org/freedesktop/Hal/devices/bme");
+               snprintf(dest,127,"org.freedesktop.Hal");
+               message = dbus_message_new_method_call (dest,path,"org.freedesktop.Hal.Device",method);
+               dbus_message_set_auto_start (message, TRUE);
+               dbus_message_iter_init_append(message, &iter);
+               if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &args))
+                       fprintf (stderr, "OOM appending args\n");
+               break;
+       case DBUS_HAL_BATTERY_PERCENT:
+               // '96'
+               snprintf(method,127,"GetProperty");
+               args = "battery.charge_level.percentage";
+               snprintf(path,127,"/org/freedesktop/Hal/devices/bme");
+               snprintf(dest,127,"org.freedesktop.Hal");
+               message = dbus_message_new_method_call (dest,path,"org.freedesktop.Hal.Device",method);
+               dbus_message_set_auto_start (message, TRUE);
+               dbus_message_iter_init_append(message, &iter);
+               if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &args))
+                       fprintf (stderr, "OOM appending args\n");
+               break;
+       case DBUS_HAL_BATTERY_VOLTS_CURRENT:
+               // '3600' - '4200'
+               snprintf(method,127,"GetProperty");
+               args = "battery.voltage.current";
+               snprintf(path,127,"/org/freedesktop/Hal/devices/bme");
+               snprintf(dest,127,"org.freedesktop.Hal");
+               message = dbus_message_new_method_call (dest,path,"org.freedesktop.Hal.Device",method);
+               dbus_message_set_auto_start (message, TRUE);
+               dbus_message_iter_init_append(message, &iter);
+               if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &args))
+                       fprintf (stderr, "OOM appending args\n");
+               break;
        default:
                fprintf (stderr, "invalid item type in get_dbus_stuff");
                break;
@@ -1708,7 +1748,7 @@ void get_dbus_stuff(char *buffer,unsigned int intMax_length, int item)
          fprintf (stderr, "Not enough memory\n");
          exit (1);
        }
-       dbus_message_iter_init_append (message, &iter);
+
        dbus_error_init (&error);
        reply = dbus_connection_send_with_reply_and_block (connection, message, reply_timeout_ms, &error);
        if (dbus_error_is_set (&error))
@@ -1726,21 +1766,53 @@ void get_dbus_stuff(char *buffer,unsigned int intMax_length, int item)
                {
                        //fprintf (stderr,"dbus-monitor too dumb to decipher arg type '%c'\n", type);
                        current_fieldnumber++;
-                       if (current_fieldnumber == 1)
-                       {
-                               unsigned char val;
-                               dbus_message_iter_get_basic(&iter, &val);
-                               last_cell_radio_percent = val;
-                       }
-                       if (current_fieldnumber == 2)
-                       {
-                               unsigned char val;
-                               dbus_message_iter_get_basic(&iter, &val);
-                               last_cell_radio_dbm = val;
+                       switch(item){
+                       case DBUS_CELL_DBM:
+                               if (current_fieldnumber == 2)
+                               {
+                                       unsigned char val;
+                                       dbus_message_iter_get_basic(&iter, &val);
+                                       last_cell_radio_dbm = val;
+                               }
+                               break;
+                       case DBUS_CELL_PERCENT:
+                               if (current_fieldnumber == 1)
+                               {
+                                       unsigned char val;
+                                       dbus_message_iter_get_basic(&iter, &val);
+                                       last_cell_radio_percent = val;
+                               }
+                               break;
+                       case DBUS_HAL_BATTERY_CHRG_STATUS:
+                               if (current_fieldnumber == 1)
+                               {
+                                       char *val;
+                                       dbus_message_iter_get_basic(&iter, &val);
+                                       snprintf(last_batt_charge_status,16,"%s",val);
+                               }
+                               break;
+                       case DBUS_HAL_BATTERY_PERCENT:
+                               if (current_fieldnumber == 1)
+                               {
+                                       dbus_uint32_t val;
+                                       dbus_message_iter_get_basic(&iter, &val);
+                                       last_battery_perct[0] = val;
+                               }
+                               break;
+                       case DBUS_HAL_BATTERY_VOLTS_CURRENT:
+                               if (current_fieldnumber == 1)
+                               {
+                                       dbus_uint32_t val;
+                                       dbus_message_iter_get_basic(&iter, &val);
+                                       last_battery_volts[0] = val;
+                               }
+                               break;
+                       default:
+                               fprintf (stderr, "invalid item type in get_dbus_stuff reply loop");
+                               break;
                        }
                        dbus_message_iter_next (&iter);
                }
-
                dbus_message_unref (reply);
        }
        set_dbus_retval(buffer, intMax_length, item);
@@ -1758,6 +1830,15 @@ void set_dbus_retval(char *buffer, unsigned int intMax_length, int item)
                case DBUS_CELL_PERCENT:
                        snprintf(buffer, intMax_length, "%d", last_cell_radio_percent);
                        break;
+               case DBUS_HAL_BATTERY_CHRG_STATUS:
+                       snprintf(buffer, intMax_length, "%s", last_batt_charge_status);
+                       break;
+               case DBUS_HAL_BATTERY_PERCENT:
+                       snprintf(buffer, intMax_length, "%i", last_battery_perct[0]);
+                       break;
+               case DBUS_HAL_BATTERY_VOLTS_CURRENT:
+                       snprintf(buffer, intMax_length, "%i", last_battery_volts[0]);
+                       break;
                default:
                        fprintf (stderr, "invalid item type in set_dbus_retval");
                        break;
@@ -1792,16 +1873,12 @@ void get_battery_stuff(char *buffer, unsigned int n, const char *bat, int item)
        //memset(last_battery_volts[idx], 0, sizeof(last_battery_volts[idx]));
        //memset(last_battery_temp[idx], 0, sizeof(last_battery_temp[idx]));
 
-       /* first try SYSFS if that fails try ACPI */
+       /* first try SYSFS if that fails try DBUS */
 
        if (sysfs_bat_fp[idx] == NULL && acpi_bat_fp[idx] == NULL && apm_bat_fp[idx] == NULL) {
                sysfs_bat_fp[idx] = open_file(sysfs_path, &rep);
        }
 
-       if (sysfs_bat_fp[idx] == NULL && acpi_bat_fp[idx] == NULL && apm_bat_fp[idx] == NULL) {
-               acpi_bat_fp[idx] = open_file(acpi_path, &rep1);
-       }
-
        if (sysfs_bat_fp[idx] != NULL) {
                /* SYSFS */
                int present_rate = -9999; //we will put "current now" into this. negative when charging!
@@ -1815,14 +1892,15 @@ void get_battery_stuff(char *buffer, unsigned int n, const char *bat, int item)
                strcpy(charging_state, "unknown");
 
                while (!feof(sysfs_bat_fp[idx])) {
+                       //we are looping through the data here
                        char buf[256];
                        if (fgets(buf, 256, sysfs_bat_fp[idx]) == NULL)
                                break;
 
                        /* let's just hope units are ok */
-                       if (strncmp (buf, "POWER_SUPPLY_PRESENT=1", 22) == 0)
+                       if (strncmp (buf, "POWER_SUPPLY_PRESENT=1", 22) == 0)//does current row match this?
                                strcpy(present, "yes");//n900 always yes
-                       else if (strncmp(buf, "POWER_SUPPLY_VOLTAGE_NOW=", 25) == 0)
+                       else if (strncmp(buf, "POWER_SUPPLY_VOLTAGE_NOW=", 25) == 0)//keep checking possible matches
                                sscanf(buf, "POWER_SUPPLY_VOLTAGE_NOW=%d", &voltage);
 //             else if (strncmp (buf, "POWER_SUPPLY_STATUS=", 20) == 0)
 //                     sscanf(buf, "POWER_SUPPLY_STATUS=%63s", charging_state);
@@ -1902,7 +1980,7 @@ void get_battery_stuff(char *buffer, unsigned int n, const char *bat, int item)
                /* thanks to Lukas Zapletal <lzap@seznam.cz> */
 
                 if (remaining_capacity == 100)
-                               strcpy(last_battery_str[idx], "charged");
+                               strcpy(last_battery_str[idx], "charged 100%");
 
 //             else if (strncmp(charging_state, "Charged", 64) == 0 || strncmp(charging_state, "Full", 64) == 0) {
 //                             /* Below happens with the second battery on my X40,
@@ -1922,170 +2000,207 @@ void get_battery_stuff(char *buffer, unsigned int n, const char *bat, int item)
 //                     else
 //                             strncpy(last_battery_str[idx], "AC", 64);
 //             }
-       } else if (acpi_bat_fp[idx] != NULL) {//skipped on n900
-               /* ACPI */
-               int present_rate = -1;
-               int remaining_capacity = -1;
-               char charging_state[64];
-               char present[4];
-
-               /* read last full capacity if it's zero */
-               if (acpi_last_full[idx] == 0) {
-                       static int rep3 = 0;
-                       char path[128];
-                       FILE *fp;
-
-                       snprintf(path, 127, ACPI_BATTERY_BASE_PATH "/%s/info", bat);
-                       fp = open_file(path, &rep3);
-                       if (fp != NULL) {
-                               while (!feof(fp)) {
-                                       char b[256];
-
-                                       if (fgets(b, 256, fp) == NULL) {
-                                               break;
-                                       }
-                                       if (sscanf(b, "last full capacity: %d",
-                                                               &acpi_last_full[idx]) != 0) {
-                                               break;
-                                       }
-                               }
-
-                               fclose(fp);
-                       }
-               }
-
-               fseek(acpi_bat_fp[idx], 0, SEEK_SET);
-
-               strcpy(charging_state, "unknown");
-
-               while (!feof(acpi_bat_fp[idx])) {
-                       char buf[256];
-
-                       if (fgets(buf, 256, acpi_bat_fp[idx]) == NULL) {
-                               break;
-                       }
-
-                       /* let's just hope units are ok */
-                       if (strncmp(buf, "present:", 8) == 0) {
-                               sscanf(buf, "present: %4s", present);
-                       } else if (strncmp(buf, "charging state:", 15) == 0) {
-                               sscanf(buf, "charging state: %63s", charging_state);
-                       } else if (strncmp(buf, "present rate:", 13) == 0) {
-                               sscanf(buf, "present rate: %d", &present_rate);
-                       } else if (strncmp(buf, "remaining capacity:", 19) == 0) {
-                               sscanf(buf, "remaining capacity: %d", &remaining_capacity);
-                       }
-               }
-               /* Hellf[i]re notes that remaining capacity can exceed acpi_last_full */
-               if (remaining_capacity > acpi_last_full[idx]) {
-                       /* normalize to 100% */
-                       acpi_last_full[idx] = remaining_capacity;
-               }
-
-               /* not present */
-               if (strcmp(present, "no") == 0) {
-                       strncpy(last_battery_str[idx], "not present", 64);
-                       /* charging */
-               } else if (strcmp(charging_state, "charging") == 0) {
-                       if (acpi_last_full[idx] != 0 && present_rate > 0) {
-                               /* e.g. charging 75% */
-                               snprintf(last_battery_str[idx],
-                                               sizeof(last_battery_str[idx]) - 1, "charging %i%%",
-                                               (int) ((remaining_capacity * 100) / acpi_last_full[idx]));
-                               /* e.g. 2h 37m */
-                               format_seconds(last_battery_time_str[idx],
-                                               sizeof(last_battery_time_str[idx]) - 1,
-                                               (long) (((acpi_last_full[idx] - remaining_capacity) *
-                                                               3600) / present_rate));
-                       } else if (acpi_last_full[idx] != 0 && present_rate <= 0) {
-                               snprintf(last_battery_str[idx],
-                                               sizeof(last_battery_str[idx]) - 1, "charging %d%%",
-                                               (int) ((remaining_capacity * 100) / acpi_last_full[idx]));
-                               snprintf(last_battery_time_str[idx],
-                                               sizeof(last_battery_time_str[idx]) - 1, "unknown");
-                       } else {
-                               strncpy(last_battery_str[idx], "charging",
-                                               sizeof(last_battery_str[idx]) - 1);
-                               snprintf(last_battery_time_str[idx],
-                                               sizeof(last_battery_time_str[idx]) - 1, "unknown");
-                       }
-                       /* discharging */
-               } else if (strncmp(charging_state, "discharging", 64) == 0) {
-                       if (present_rate > 0) {
-                               /* e.g. discharging 35% */
-                               snprintf(last_battery_str[idx],
-                                               sizeof(last_battery_str[idx]) - 1, "discharging %i%%",
-                                               (int) ((remaining_capacity * 100) / acpi_last_full[idx]));
-                               /* e.g. 1h 12m */
-                               format_seconds(last_battery_time_str[idx],
-                                               sizeof(last_battery_time_str[idx]) - 1,
-                                               (long) ((remaining_capacity * 3600) / present_rate));
-                       } else if (present_rate == 0) { /* Thanks to Nexox for this one */
-                               snprintf(last_battery_str[idx],
-                                               sizeof(last_battery_str[idx]) - 1, "full");
-                               snprintf(last_battery_time_str[idx],
-                                               sizeof(last_battery_time_str[idx]) - 1, "unknown");
-                       } else {
-                               snprintf(last_battery_str[idx],
-                                               sizeof(last_battery_str[idx]) - 1, "discharging %d%%",
-                                               (int) ((remaining_capacity * 100) / acpi_last_full[idx]));
-                               snprintf(last_battery_time_str[idx],
-                                               sizeof(last_battery_time_str[idx]) - 1, "unknown");
-                       }
-                       /* charged */
-               } else if (strncmp(charging_state, "charged", 64) == 0) {
-                       /* thanks to Lukas Zapletal <lzap@seznam.cz> */
-                       /* Below happens with the second battery on my X40,
-                        * when the second one is empty and the first one being charged. */
-                       if (remaining_capacity == 0) {
-                               strcpy(last_battery_str[idx], "empty");
-                       } else {
-                               strcpy(last_battery_str[idx], "charged");
-                       }
-                       /* unknown, probably full / AC */
-               } else {
-                       if (strncmp(charging_state, "Full", 64) == 0) {
-                               strncpy(last_battery_str[idx], "full", 64);
-                       } else if (acpi_last_full[idx] != 0
-                                       && remaining_capacity != acpi_last_full[idx]) {
-                               snprintf(last_battery_str[idx], 64, "unknown %d%%",
-                                               (int) ((remaining_capacity * 100) / acpi_last_full[idx]));
-                       } else {
-                               strncpy(last_battery_str[idx], "AC", 64);
-                       }
-               }
-               fclose(acpi_bat_fp[idx]);
-               acpi_bat_fp[idx] = NULL;
-       } else {//also skipped on n900
-               /* APM */
-               if (apm_bat_fp[idx] == NULL) {
-                       apm_bat_fp[idx] = open_file(APM_PATH, &rep2);
-               }
-
-               if (apm_bat_fp[idx] != NULL) {
-                       unsigned int ac, status, flag;
-                       int life;
-
-                       fscanf(apm_bat_fp[idx], "%*s %*s %*x %x   %x       %x     %d%%",
-                               &ac, &status, &flag, &life);
+       } else {
+               //if don't have power kernel, use HAL / dbus
+               //int present_rate = 50; //not available via dbus
+               int remaining_capacity = -1; //in %
+               //char charging_state[64];//can't get this without hal bme
+               //int voltage = 6666;//might as well set the default to something with 4 digits so as to not screw up a config layout
+               int temp = -1;
+               remaining_capacity = get_battery_perct(bat);
+ //            fprintf(stderr,"got remaining cap %i",remaining_capacity);
+               get_dbus_stuff(buffer,n,DBUS_HAL_BATTERY_VOLTS_CURRENT);
+               //last_battery_volts[idx] = voltage;
+
+               get_dbus_stuff(buffer,n,DBUS_HAL_BATTERY_CHRG_STATUS);
+               if (strncmp(buffer, "on", 2) == 0) {
+                       snprintf(last_battery_str[idx], sizeof(last_battery_str[idx])-1, "charging %i%%", remaining_capacity);
+                       //strcpy(charging_state, "charging");
+               }
+               else if (strncmp(buffer, "off", 3) == 0) {
+                       snprintf(last_battery_str[idx], sizeof(last_battery_str[idx])-1, "discharging %i%%", remaining_capacity);
+                       //strcpy(charging_state, "discharging");
+               }
+               else if (strncmp(buffer, "full", 4) == 0) {//no, it won't always be 100%. stupid dbus.
+                       snprintf(last_battery_str[idx], sizeof(last_battery_str[idx])-1, "charged %i%%", remaining_capacity);
+                }
+               //strcpy(last_battery_str[idx], charging_state);
 
-                       if (life == -1) {
-                               /* could check now that there is ac */
-                               snprintf(last_battery_str[idx], 64, "AC");
+               last_battery_temp[idx] = temp;
 
-                       /* could check that status == 3 here? */
-                       } else if (ac && life != 100) {
-                               snprintf(last_battery_str[idx], 64, "charging %d%%", life);
-                       } else {
-                               snprintf(last_battery_str[idx], 64, "%d%%", life);
-                       }
+               //already declared
+/*             DBusConnection *connection;
+               DBusError error;
+               DBusMessage *message;
+               DBusMessageIter iter;
+               DBusBusType type;
+               int message_type;
+               DBusMessage *reply;*/
 
-                       /* it seemed to buffer it so file must be closed (or could use
-                        * syscalls directly but I don't feel like coding it now) */
-                       fclose(apm_bat_fp[idx]);
-                       apm_bat_fp[idx] = NULL;
-               }
+               /* ACPI */
+//             int present_rate = -1;
+//             int remaining_capacity = -1;
+//             char charging_state[64];
+//             char present[4];
+//
+//             /* read last full capacity if it's zero */
+//             if (acpi_last_full[idx] == 0) {
+//                     static int rep3 = 0;
+//                     char path[128];
+//                     FILE *fp;
+//
+//                     snprintf(path, 127, ACPI_BATTERY_BASE_PATH "/%s/info", bat);
+//                     fp = open_file(path, &rep3);
+//                     if (fp != NULL) {
+//                             while (!feof(fp)) {
+//                                     char b[256];
+//
+//                                     if (fgets(b, 256, fp) == NULL) {
+//                                             break;
+//                                     }
+//                                     if (sscanf(b, "last full capacity: %d",
+//                                                             &acpi_last_full[idx]) != 0) {
+//                                             break;
+//                                     }
+//                             }
+//
+//                             fclose(fp);
+//                     }
+//             }
+//
+//             fseek(acpi_bat_fp[idx], 0, SEEK_SET);
+//
+//             strcpy(charging_state, "unknown");
+//
+//             while (!feof(acpi_bat_fp[idx])) {
+//                     char buf[256];
+//
+//                     if (fgets(buf, 256, acpi_bat_fp[idx]) == NULL) {
+//                             break;
+//                     }
+//
+//                     /* let's just hope units are ok */
+//                     if (strncmp(buf, "present:", 8) == 0) {
+//                             sscanf(buf, "present: %4s", present);
+//                     } else if (strncmp(buf, "charging state:", 15) == 0) {
+//                             sscanf(buf, "charging state: %63s", charging_state);
+//                     } else if (strncmp(buf, "present rate:", 13) == 0) {
+//                             sscanf(buf, "present rate: %d", &present_rate);
+//                     } else if (strncmp(buf, "remaining capacity:", 19) == 0) {
+//                             sscanf(buf, "remaining capacity: %d", &remaining_capacity);
+//                     }
+//             }
+//             /* Hellf[i]re notes that remaining capacity can exceed acpi_last_full */
+//             if (remaining_capacity > acpi_last_full[idx]) {
+//                     /* normalize to 100% */
+//                     acpi_last_full[idx] = remaining_capacity;
+//             }
+//
+//             /* not present */
+//             if (strcmp(present, "no") == 0) {
+//                     strncpy(last_battery_str[idx], "not present", 64);
+//                     /* charging */
+//             } else if (strcmp(charging_state, "charging") == 0) {
+//                     if (acpi_last_full[idx] != 0 && present_rate > 0) {
+//                             /* e.g. charging 75% */
+//                             snprintf(last_battery_str[idx],
+//                                             sizeof(last_battery_str[idx]) - 1, "charging %i%%",
+//                                             (int) ((remaining_capacity * 100) / acpi_last_full[idx]));
+//                             /* e.g. 2h 37m */
+//                             format_seconds(last_battery_time_str[idx],
+//                                             sizeof(last_battery_time_str[idx]) - 1,
+//                                             (long) (((acpi_last_full[idx] - remaining_capacity) *
+//                                                             3600) / present_rate));
+//                     } else if (acpi_last_full[idx] != 0 && present_rate <= 0) {
+//                             snprintf(last_battery_str[idx],
+//                                             sizeof(last_battery_str[idx]) - 1, "charging %d%%",
+//                                             (int) ((remaining_capacity * 100) / acpi_last_full[idx]));
+//                             snprintf(last_battery_time_str[idx],
+//                                             sizeof(last_battery_time_str[idx]) - 1, "unknown");
+//                     } else {
+//                             strncpy(last_battery_str[idx], "charging",
+//                                             sizeof(last_battery_str[idx]) - 1);
+//                             snprintf(last_battery_time_str[idx],
+//                                             sizeof(last_battery_time_str[idx]) - 1, "unknown");
+//                     }
+//                     /* discharging */
+//             } else if (strncmp(charging_state, "discharging", 64) == 0) {
+//                     if (present_rate > 0) {
+//                             /* e.g. discharging 35% */
+//                             snprintf(last_battery_str[idx],
+//                                             sizeof(last_battery_str[idx]) - 1, "discharging %i%%",
+//                                             (int) ((remaining_capacity * 100) / acpi_last_full[idx]));
+//                             /* e.g. 1h 12m */
+//                             format_seconds(last_battery_time_str[idx],
+//                                             sizeof(last_battery_time_str[idx]) - 1,
+//                                             (long) ((remaining_capacity * 3600) / present_rate));
+//                     } else if (present_rate == 0) { /* Thanks to Nexox for this one */
+//                             snprintf(last_battery_str[idx],
+//                                             sizeof(last_battery_str[idx]) - 1, "full");
+//                             snprintf(last_battery_time_str[idx],
+//                                             sizeof(last_battery_time_str[idx]) - 1, "unknown");
+//                     } else {
+//                             snprintf(last_battery_str[idx],
+//                                             sizeof(last_battery_str[idx]) - 1, "discharging %d%%",
+//                                             (int) ((remaining_capacity * 100) / acpi_last_full[idx]));
+//                             snprintf(last_battery_time_str[idx],
+//                                             sizeof(last_battery_time_str[idx]) - 1, "unknown");
+//                     }
+//                     /* charged */
+//             } else if (strncmp(charging_state, "charged", 64) == 0) {
+//                     /* thanks to Lukas Zapletal <lzap@seznam.cz> */
+//                     /* Below happens with the second battery on my X40,
+//                      * when the second one is empty and the first one being charged. */
+//                     if (remaining_capacity == 0) {
+//                             strcpy(last_battery_str[idx], "empty");
+//                     } else {
+//                             strcpy(last_battery_str[idx], "charged");
+//                     }
+//                     /* unknown, probably full / AC */
+//             } else {
+//                     if (strncmp(charging_state, "Full", 64) == 0) {
+//                             strncpy(last_battery_str[idx], "full", 64);
+//                     } else if (acpi_last_full[idx] != 0
+//                                     && remaining_capacity != acpi_last_full[idx]) {
+//                             snprintf(last_battery_str[idx], 64, "unknown %d%%",
+//                                             (int) ((remaining_capacity * 100) / acpi_last_full[idx]));
+//                     } else {
+//                             strncpy(last_battery_str[idx], "AC", 64);
+//                     }
+//             }
+//             fclose(acpi_bat_fp[idx]);
+//             acpi_bat_fp[idx] = NULL;
        }
+//     else {
+//             /* APM */
+//             if (apm_bat_fp[idx] == NULL) {
+//                     apm_bat_fp[idx] = open_file(APM_PATH, &rep2);
+//             }
+//
+//             if (apm_bat_fp[idx] != NULL) {
+//                     unsigned int ac, status, flag;
+//                     int life;
+//
+//                     fscanf(apm_bat_fp[idx], "%*s %*s %*x %x   %x       %x     %d%%",
+//                             &ac, &status, &flag, &life);
+//
+//                     if (life == -1) {
+//                             /* could check now that there is ac */
+//                             snprintf(last_battery_str[idx], 64, "AC");
+//
+//                     /* could check that status == 3 here? */
+//                     } else if (ac && life != 100) {
+//                             snprintf(last_battery_str[idx], 64, "charging %d%%", life);
+//                     } else {
+//                             snprintf(last_battery_str[idx], 64, "%d%%", life);
+//                     }
+//
+//                     /* it seemed to buffer it so file must be closed (or could use
+//                      * syscalls directly but I don't feel like coding it now) */
+//                     fclose(apm_bat_fp[idx]);
+//                     apm_bat_fp[idx] = NULL;
+//             }
+//     }
        set_return_value(buffer, n, item, idx);
 }
 
@@ -2105,6 +2220,7 @@ void set_return_value(char *buffer, unsigned int n, int item, int idx)
                        snprintf(buffer, n, "%i", last_battery_temp[idx]); // temperature
                        break;
                default:
+                       fprintf (stderr, "invalid item type in set_return_value");
                        break;
        }
 }
@@ -2130,18 +2246,18 @@ void get_battery_short_status(char *buffer, unsigned int n, const char *bat)
        } else if (0 != strncmp("AC", buffer, 2)) {
                buffer[0] = 'U';
                memmove(buffer + 1, buffer + 11, n - 11);
-       }
+       } else fprintf (stderr, "invalid input buffer in get_battery_short_status");
 }
 
 int get_battery_perct(const char *bat)
 {
        static int rep = 0;
        int idx;
-       char acpi_path[128];
+       //char acpi_path[128];
        char sysfs_path[128];
        int remaining_capacity = -1;
 
-       snprintf(acpi_path, 127, ACPI_BATTERY_BASE_PATH "/%s/state", bat);
+       //snprintf(acpi_path, 127, ACPI_BATTERY_BASE_PATH "/%s/state", bat);
        snprintf(sysfs_path, 127, SYSFS_BATTERY_BASE_PATH "/%s/uevent", bat);
 
        init_batteries();
@@ -2154,16 +2270,12 @@ int get_battery_perct(const char *bat)
        }
        last_battery_perct_time[idx] = current_update_time;
 
-       /* Only check for SYSFS */
+       /* try  SYSFS first */
 
-       if (sysfs_bat_fp[idx] == NULL && acpi_bat_fp[idx] == NULL && apm_bat_fp[idx] == NULL) {
+       //if (sysfs_bat_fp[idx] == NULL && acpi_bat_fp[idx] == NULL && apm_bat_fp[idx] == NULL) {
                sysfs_bat_fp[idx] = open_file(sysfs_path, &rep);
-               rep = 0;
-       }
-
-       if (sysfs_bat_fp[idx] == NULL && acpi_bat_fp[idx] == NULL && apm_bat_fp[idx] == NULL) {
-               acpi_bat_fp[idx] = open_file(acpi_path, &rep);
-       }
+       //      rep = 0;
+       //}
 
        if (sysfs_bat_fp[idx] != NULL) {
                /* SYSFS */
@@ -2187,8 +2299,23 @@ int get_battery_perct(const char *bat)
                }
                fclose(sysfs_bat_fp[idx]);
                sysfs_bat_fp[idx] = NULL;
+               last_battery_perct[idx] = remaining_capacity;
 
        }
+       else
+       {
+               char *useless;
+               useless = malloc(128 * sizeof(char));
+               get_dbus_stuff(useless,128,DBUS_HAL_BATTERY_PERCENT);
+               //i told you it's useless...
+               //snprintf(last_battery_perct[idx], 127, "%i", useless);
+               //guess what? dbus battery % doesn't update while charging
+//             get_dbus_stuff(useless,n,DBUS_HAL_BATTERY_CHRG_STATUS);
+//             if (strncmp(useless, "full", 4) == 0)
+//             {
+//
+//             }
+       }
 //     else if (acpi_bat_fp[idx] != NULL) {
 //             /* ACPI */
 //             /* read last full capacity if it's zero */
@@ -2229,23 +2356,20 @@ int get_battery_perct(const char *bat)
 //                     }
 //             }
 //     }
-       if (remaining_capacity < 0) {
-               return 0;
-       }
+
        /* compute the battery percentage */
-       last_battery_perct[idx] =
-               remaining_capacity;
+
                //(int) (((float) remaining_capacity / acpi_design_capacity[idx]) * 100);
        //if (last_battery_perct[idx] > 100) last_battery_perct[idx] = 100;
        return last_battery_perct[idx];
 }
 
-int get_battery_perct_bar(const char *bar)
+int get_battery_perct_bar(const char *bat)
 {
        int idx;
 
-       get_battery_perct(bar);
-       idx = get_battery_idx(bar);
+       get_battery_perct(bat);
+       idx = get_battery_idx(bat);
        return (int) (last_battery_perct[idx] * 2.56 - 1);
 }