-# Conky, a system monitor, based on torsmo
-#
-# Any original torsmo code is licensed under the BSD license
-#
-# All code written since the fork of torsmo is licensed under the GPL
-#
-# Please see COPYING for details
-#
-# Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
-# Copyright (c) 2005-2010 Brenden Matthews, Philip Kovacs, et. al. (see AUTHORS)
-# All rights reserved.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
+# cpu red > white
+# memory blue > white
+# disk green > white
+#
+#
+#
+# cool blue > cyan: 0000ff 00FFFF
+#
alignment top_left
background no
+maximum_width 800
border_width 1
cpu_avg_samples 2
default_color white
default_outline_color white
default_shade_color white
+diskio_avg_samples 2
draw_borders no
draw_graph_borders yes
draw_outline no
draw_shades no
-use_xft yes
-xftfont DejaVu Sans Mono:size=12
-gap_x 5
+double_buffer yes
+gap_x 20
gap_y 60
minimum_size 5 5
net_avg_samples 2
no_buffers yes
out_to_console no
-out_to_stderr no
-extra_newline no
own_window yes
own_window_class Conky
-own_window_type desktop
+own_window_type normal
+own_window_transparent no
+own_window_hints undecorated
+#own_window_colour ff0000
+override_utf8_locale yes
+show_graph_scale no
+show_graph_range no
+short_units yes
stippled_borders 0
-update_interval 1.0
+temperature_unit celsius
+update_interval 1
+update_interval_on_battery 5
uppercase no
use_spacer none
-show_graph_scale no
-show_graph_range no
+use_xft yes
+xftfont Droid Sans Mono:size=11
+xftalpha 0.8
TEXT
-${scroll 16 $nodename - $sysname $kernel on $machine | }
-$hr
-${color grey}Uptime:$color $uptime
-${color grey}Frequency (in MHz):$color $freq
-${color grey}Frequency (in GHz):$color $freq_g
-${color grey}RAM Usage:$color $mem/$memmax - $memperc% ${membar 4}
-${color grey}Swap Usage:$color $swap/$swapmax - $swapperc% ${swapbar 4}
-${color grey}CPU Usage:$color $cpu% ${cpubar 4}
-${color grey}Processes:$color $processes ${color grey}Running:$color $running_processes
-$hr
-${color grey}File systems:
- / $color${fs_used /}/${fs_size /} ${fs_bar 6 /}
-${color grey}Networking:
-Up:$color ${upspeed eth0} ${color grey} - Down:$color ${downspeed eth0}
-$hr
-${color grey}Name PID CPU% MEM%
-${color lightgrey} ${top name 1} ${top pid 1} ${top cpu 1} ${top mem 1}
-${color lightgrey} ${top name 2} ${top pid 2} ${top cpu 2} ${top mem 2}
-${color lightgrey} ${top name 3} ${top pid 3} ${top cpu 3} ${top mem 3}
-${color lightgrey} ${top name 4} ${top pid 4} ${top cpu 4} ${top mem 4}
+${color }$alignr$sysname $kernel on $machine ${color 4072a5}Uptime:$color $uptime
+${color }$alignr${color #4072a5}Battery: ${color}${battery_short} ${battery_temp}°C ${battery_volts}mV
+${color }$alignr${color #4072a5}Cell Radio: $color ${cell_radio_dbm}dBm ${cell_radio_percent}%
+${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 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} #something could go here
+
+${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}] (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}
+$color---------1---------2---------3---------4---------5---------6---------7---------8---------9---------0---------1
+#imagetest: ${image /home/user/image-test.png -p 100,410}
\ No newline at end of file
Build-Depends: debhelper (>= 5.0.0), libtool, automake,
pkg-config (>= 0.19), libx11-dev, libxft-dev,
libxdamage-dev, libxext-dev, libglib2.0-dev,
- libxml2-dev,
+ libxml2-dev, libimlib2-dev,
libiw-dev[!kfreebsd-i386 !kfreebsd-amd64 !hurd-i386],
libasound2-dev [!kfreebsd-i386 !kfreebsd-amd64 !hurd-i386],
libkvm-dev [kfreebsd-i386 kfreebsd-amd64],
libdevstat-dev [kfreebsd-i386 kfreebsd-amd64],
- libncurses5-dev, liblua5.1-0-dev, lib-dbus-1-dev
+ libncurses5-dev, liblua5.1-0-dev, libdbus-1-dev
Homepage: http://conky.sourceforge.net/
Standards-Version: 3.8.4
-
-Package: conky
-Architecture: all
-Priority: extra
-Depends: conky-all, ${misc:Depends}
-Description: Highly configurable system monitor (transitional package)
- Conky is a system monitor that can display just about anything,
- either on your root desktop or in its own window.
- Conky has many built-in objects, as well as the ability to execute
- external programs or scripts (either external or through built-in
- lua support).
- .
- This is a dummy package to ease transition to the new packaging scheme.
- It may be safely removed after upgrade/installation.
-
-#DML# Package: conky-std
-#DML# Architecture: any
-#DML# Depends: ${shlibs:Depends}, ${misc:Depends}
-#DML# Suggests: apcupsd, moc, mpd
-#DML# Conflicts: conky-cli, conky-all
-#DML# Replaces: conky-cli, conky-all
-#DML# Description: highly configurable system monitor (default version)
-#DML# Conky is a system monitor that can display just about anything,
-#DML# either on your root desktop or in its own window.
-#DML# Conky has many built-in objects, as well as the ability to execute
-#DML# external programs or scripts (either external or through built-in
-#DML# lua support).
-#DML# .
-#DML# This package should be a good compromise for most users that do not
-#DML# need special features.
-#DML# It includes the following support:
-#DML# .
-#DML# X11, XDamage, XDBE, Xft, MPD, MOC, math, hddtemp, portmon,
-#DML# wireless, ALSA mixer, apcupsd, I/O stats, argb and Lua.
-
-#DML# Package: conky-cli
-#DML# Architecture: any
-#DML# Depends: ${shlibs:Depends}, ${misc:Depends}
-#DML# Suggests: apcupsd, moc, mpd
-#DML# Conflicts: conky-std, conky-all
-#DML# Replaces: conky-std, conky-all
-#DML# Description: highly configurable system monitor (basic version)
-#DML# Conky is a system monitor that can display just about anything,
-#DML# either on your root desktop or in its own window.
-#DML# Conky has many built-in objects, as well as the ability to execute
-#DML# external programs or scripts (either external or through built-in
-#DML# lua support).
-#DML# .
-#DML# This is a basic package that can be useful in servers or piped with dzen2.
-#DML# It includes the following support:
-#DML# .
-#DML# MPD, MOC, math, apcupsd, ncurses and I/O stats.
-
-Package: conky-all
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, liblua5.1-0
-Suggests: apcupsd, moc, mpd
+Package: conky-n900
+Architecture: armel
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Recommends:
+Suggests: moc, mpd
Conflicts: conky-std, conky-cli
-Replaces: conky, conky-std, conky-cli
+Replaces: conky, conky-std, conky-cli, conky-all
Description: Highly configurable system monitor (most features enabled)
Conky is a system monitor that can display just about anything,
either on your root desktop or in its own window.
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_VOLTAGE_NOW=4039 << this keeps updating during charging, both here and in dbus
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_CAPACITY=98 << supposed to be the %, it keeps updating while charging, unlike the dbus vals that freeze
POWER_SUPPLY_TEMP=39 << only temperature sensor in n900 :(
*/
#define MAX_BATTERY_COUNT 4 //more like 1
static FILE *sysfs_bat_fp[MAX_BATTERY_COUNT] = { NULL, NULL, NULL, NULL };
-static FILE *acpi_bat_fp[MAX_BATTERY_COUNT] = { NULL, NULL, NULL, NULL };
-static FILE *apm_bat_fp[MAX_BATTERY_COUNT] = { NULL, NULL, NULL, NULL };
+//static FILE *acpi_bat_fp[MAX_BATTERY_COUNT] = { NULL, NULL, NULL, NULL };
+//static FILE *apm_bat_fp[MAX_BATTERY_COUNT] = { NULL, NULL, NULL, NULL };
static int batteries_initialized = 0;
static char batteries[MAX_BATTERY_COUNT][32];
-static int acpi_last_full[MAX_BATTERY_COUNT];
-static int acpi_design_capacity[MAX_BATTERY_COUNT];
+//static int acpi_last_full[MAX_BATTERY_COUNT];
+//static int acpi_design_capacity[MAX_BATTERY_COUNT];
//eg 4100
static int last_battery_volts[MAX_BATTERY_COUNT];
char *args = "";
if (dbus_queue > 10)
{
- fprintf (stderr, "too much dbus queuing");
+ fprintf (stderr, "too much dbus queuing\n");
exit(1);
// set_dbus_retval(buffer, intMax_length, item);
// return;
void get_battery_stuff(char *buffer, unsigned int n, const char *bat, int item)
{
- static int idx, rep = 0, rep1 = 0, rep2 = 0;
+ static int idx, rep = 0;
char acpi_path[128];
char sysfs_path[128];
memset(last_battery_str[idx], 0, sizeof(last_battery_str[idx]));
memset(last_battery_time_str[idx], 0, sizeof(last_battery_time_str[idx]));
- //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 DBUS */
- if (sysfs_bat_fp[idx] == NULL && acpi_bat_fp[idx] == NULL && apm_bat_fp[idx] == NULL) {
+ if (sysfs_bat_fp[idx] == NULL) {
sysfs_bat_fp[idx] = open_file(sysfs_path, &rep);
}
int remaining_capacity = -1; //in %
char charging_state[64];//can't get this without hal bme
int voltage = -1;
- //int capacity = -1;
int temp = 9999;
char present[4];
strcpy(present, "no");
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)//does current row match this?
strcpy(present, "yes");//n900 always yes
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);
else if (strncmp(buf, "POWER_SUPPLY_CURRENT_NOW=", 25) == 0)
sscanf(buf, "POWER_SUPPLY_CURRENT_NOW=%d", &present_rate);
else if (strncmp(buf, "POWER_SUPPLY_CAPACITY=", 22) == 0)
sscanf(buf, "POWER_SUPPLY_CAPACITY=%d", &remaining_capacity);
else if (strncmp(buf, "POWER_SUPPLY_TEMP=", 18) == 0)
sscanf(buf, "POWER_SUPPLY_TEMP=%d", &temp);
-// else if (strncmp(buf, "POWER_SUPPLY_ENERGY_NOW=", 24) == 0)
-// sscanf(buf, "POWER_SUPPLY_ENERGY_NOW=%d", &remaining_capacity);
-// else if (strncmp(buf, "POWER_SUPPLY_ENERGY_FULL=", 25) == 0)
-// sscanf(buf, "POWER_SUPPLY_ENERGY_FULL=%d", &acpi_last_full[idx]);
-// else if (strncmp(buf, "POWER_SUPPLY_CHARGE_NOW=", 24) == 0)
-// sscanf(buf, "POWER_SUPPLY_CHARGE_NOW=%d", &remaining_capacity);
-// else if (strncmp(buf, "POWER_SUPPLY_CHARGE_FULL=", 25) == 0)
-// sscanf(buf, "POWER_SUPPLY_CHARGE_FULL=%d", &acpi_last_full[idx]);
}
-
fclose(sysfs_bat_fp[idx]);
sysfs_bat_fp[idx] = NULL;
last_battery_volts[idx] = voltage;
last_battery_temp[idx] = temp;
- /* Hellf[i]re notes that remaining capacity can exceed acpi_last_full */
- //lance notes, we don't care
-// if (remaining_capacity > acpi_last_full[idx])
-// acpi_last_full[idx] = remaining_capacity; /* normalize to 100% */
-
- /* not present */
- //not possible
-// if (strcmp(present, "no") == 0) {
-// strncpy(last_battery_str[idx], "not present", 64);
-// }
/* charging */
- if (present_rate <= 0) {//if charging
+ if (present_rate <= 0) {
/* e.g. charging 75% */
snprintf(last_battery_str[idx], sizeof(last_battery_str[idx])-1, "charging %i%%", remaining_capacity);
snprintf(last_battery_time_str[idx], sizeof(last_battery_time_str[idx]) - 1, "unknown");
- /* e.g. 2h 37m */
-// format_seconds(last_battery_time_str[idx], sizeof(last_battery_time_str[idx])-1,
-// (long) (((float)(acpi_last_full[idx] - remaining_capacity) / present_rate) * 3600));
}
-
-// else if (acpi_last_full[idx] != 0 && present_rate <= 0) {//supposed to be guessing the time to fully charge, won't work though.
-// snprintf(last_battery_str[idx], sizeof(last_battery_str[idx])-1, "charging %d%%",
-// (int) (((float)remaining_capacity / acpi_last_full[idx]) * 100));
-// 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 (present_rate > 0) {
-
/* e.g. discharging 35% */
snprintf(last_battery_str[idx], sizeof(last_battery_str[idx])-1, "discharging %i%%", remaining_capacity);
-
- snprintf(last_battery_time_str[idx],
- sizeof(last_battery_time_str[idx]) - 1, "unknown");
- /* e.g. 1h 12m */
-// format_seconds(last_battery_time_str[idx], sizeof(last_battery_time_str[idx])-1,
-// (long) (((float) remaining_capacity / present_rate) * 3600));
-// else {
-// snprintf(last_battery_str[idx], sizeof(last_battery_str[idx])-1,
-// "discharging %d%%",
-// (int) (((float)remaining_capacity / acpi_last_full[idx]) * 100));
-// snprintf(last_battery_time_str[idx],
-// sizeof(last_battery_time_str[idx]) - 1, "unknown");
-// }
+ snprintf(last_battery_time_str[idx], sizeof(last_battery_time_str[idx]) - 1, "unknown");
}
/* charged */
- /* thanks to Lukas Zapletal <lzap@seznam.cz> */
-
if (remaining_capacity == 100)
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,
-// * 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 (acpi_last_full[idx] != 0
-// && remaining_capacity != acpi_last_full[idx])
-// snprintf(last_battery_str[idx], 64, "unknown %d%%",
-// (int) (((float)remaining_capacity / acpi_last_full[idx]) * 100));
-// else
-// strncpy(last_battery_str[idx], "AC", 64);
-// }
} 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);
-
last_battery_temp[idx] = temp;
-
- //already declared
-/* DBusConnection *connection;
- DBusError error;
- DBusMessage *message;
- DBusMessageIter iter;
- DBusBusType type;
- int message_type;
- DBusMessage *reply;*/
-
- /* 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);
}
{
static int rep = 0;
int idx;
- //char acpi_path[128];
char sysfs_path[128];
int remaining_capacity = -1;
-
- //snprintf(acpi_path, 127, ACPI_BATTERY_BASE_PATH "/%s/state", bat);
snprintf(sysfs_path, 127, SYSFS_BATTERY_BASE_PATH "/%s/uevent", bat);
init_batteries();
-
idx = get_battery_idx(bat);
/* don't update battery too often */
- if (current_update_time - last_battery_perct_time[idx] < 30) {
+ if (current_update_time - last_battery_perct_time[idx] < 29.5) {
return last_battery_perct[idx];
}
last_battery_perct_time[idx] = current_update_time;
/* try SYSFS first */
-
- //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;
- //}
-
+ sysfs_bat_fp[idx] = open_file(sysfs_path, &rep);
if (sysfs_bat_fp[idx] != NULL) {
/* SYSFS */
while (!feof(sysfs_bat_fp[idx])) {