.fi
..
-.TH i3status 1 "APRIL 2009" Linux "User Manuals"
+.TH i3status 1 "MAY 2009" Linux "User Manuals"
.SH NAME
i3status \- Generates a status line for dzen2 or wmii
small number of systemcalls (as the bar should be updated every second or at
your specified interval). This ensures that even under high load, your status bar
is updated correctly and it saves a little bit of battery life by not spawning
-new processes every second like shell scripts do.
+new processes every second like shell scripts does.
.SH CONFIGURATION
.TP
specify it if you don't want the time to be shown.
.TP
-.B battery_path
-The path to your battery's uevent file in /sys, e.g.
-/sys/class/power_supply/BAT0/uevent. You can specify this directive multiple
-times to display data of more than one battery. Don't specify if you don't have
-a battery.
+.B battery
+The number of the battery you want to display. This option can be specified
+multiple times to display multiple batteries. Don't specify it if you don't
+have a battery. To get the number of the specific battery, see
+/sys/class/power_supply/BAT*
+
+If you want i3status to use the last full capacity instead of the design capacity
+of the battery, specify the f-flag, like this:
+
+.Vb 10
+# Use the last full capacity
+battery 0,f
+.Ve
.TP
.B run_watch
\ð eth0
\&wmii_path /mnt/wmii/rbar/
\&time_format %d.%m.%Y %H:%M:%S
-\&battery_path /sys/class/power_supply/BAT0/uevent
+\&battery 0
+\&battery 1,f
\&run_watch DHCP /var/run/dhclient*.pid
\&run_watch VPN /var/run/vpnc*.pid
\&order run,wlan,eth,battery,load,time
#define BAR "^fg(#333333)^p(5;-2)^ro(2)^p()^fg()^p(5)"
struct battery {
- const char *path;
+ char *path;
+ /* Use last full capacity instead of design capacity */
+ bool use_last_full;
SIMPLEQ_ENTRY(battery) batteries;
};
static const char *eth_interface;
static char *wmii_path;
static const char *time_format;
-static const char *battery_path;
static bool use_colors;
static bool get_ethspeed;
static const char *wmii_normcolors = "#222222 #333333";
create_file(concat(order[ORDER_WLAN],"wlan"));
if (eth_interface)
create_file(concat(order[ORDER_ETH],"eth"));
- if (battery_path)
- create_file(concat(order[ORDER_BATTERY],"battery"));
create_file(concat(order[ORDER_LOAD],"load"));
if (time_format)
create_file(concat(order[ORDER_TIME],"time"));
*
*/
void die(const char *fmt, ...) {
- if (wmii_path != NULL) {
- char buffer[512];
- va_list ap;
- va_start(ap, fmt);
- (void)vsnprintf(buffer, sizeof(buffer), fmt, ap);
- va_end(ap);
+ char buffer[512];
+ va_list ap;
+ va_start(ap, fmt);
+ (void)vsnprintf(buffer, sizeof(buffer), fmt, ap);
+ va_end(ap);
+ if (wmii_path != NULL)
write_error_to_statusbar(buffer);
- }
+ else
+ fprintf(stderr, "%s", buffer);
exit(EXIT_FAILURE);
}
* worn off your battery is.
*
*/
-static char *get_battery_info(const char *path) {
+static char *get_battery_info(struct battery *bat) {
char buf[1024];
static char part[512];
char *walk, *last;
present_rate = -1;
charging_status_t status = CS_DISCHARGING;
- if ((fd = open(path, O_RDONLY)) == -1)
+ if ((fd = open(bat->path, O_RDONLY)) == -1)
return "No battery found";
memset(part, 0, sizeof(part));
(void)read(fd, buf, sizeof(buf));
- for (walk = buf, last = buf; (walk-buf) < 1024; walk++)
- if (*walk == '=') {
- if (BEGINS_WITH(last, "POWER_SUPPLY_ENERGY_FULL_DESIGN") ||
- BEGINS_WITH(last, "POWER_SUPPLY_CHARGE_FULL_DESIGN"))
- full_design = atoi(walk+1);
- else if (BEGINS_WITH(last, "POWER_SUPPLY_ENERGY_NOW") ||
- BEGINS_WITH(last, "POWER_SUPPLY_CHARGE_NOW"))
- remaining = atoi(walk+1);
- else if (BEGINS_WITH(last, "POWER_SUPPLY_CURRENT_NOW"))
- present_rate = atoi(walk+1);
- else if (BEGINS_WITH(last, "POWER_SUPPLY_STATUS=Charging"))
- status = CS_CHARGING;
- else if (BEGINS_WITH(last, "POWER_SUPPLY_STATUS=Full"))
- status = CS_FULL;
- } else if (*walk == '\n')
+ for (walk = buf, last = buf; (walk-buf) < 1024; walk++) {
+ if (*walk == '\n') {
last = walk+1;
+ continue;
+ }
+
+ if (*walk != '=')
+ continue;
+
+ if (BEGINS_WITH(last, "POWER_SUPPLY_ENERGY_NOW") ||
+ BEGINS_WITH(last, "POWER_SUPPLY_CHARGE_NOW"))
+ remaining = atoi(walk+1);
+ else if (BEGINS_WITH(last, "POWER_SUPPLY_CURRENT_NOW"))
+ present_rate = atoi(walk+1);
+ else if (BEGINS_WITH(last, "POWER_SUPPLY_STATUS=Charging"))
+ status = CS_CHARGING;
+ else if (BEGINS_WITH(last, "POWER_SUPPLY_STATUS=Full"))
+ status = CS_FULL;
+ else {
+ /* The only thing left is the full capacity */
+ if (bat->use_last_full) {
+ if (!BEGINS_WITH(last, "POWER_SUPPLY_ENERGY_FULL") &&
+ !BEGINS_WITH(last, "POWER_SUPPLY_CHARGE_FULL"))
+ continue;
+ } else {
+ if (!BEGINS_WITH(last, "POWER_SUPPLY_CHARGE_FULL_DESIGN") &&
+ !BEGINS_WITH(last, "POWER_SUPPLY_ENERGY_FULL_DESIGN"))
+ continue;
+ }
+
+ full_design = atoi(walk+1);
+ }
+ }
(void)close(fd);
if ((full_design == 1) || (remaining == -1))
eth_interface = strdup(dest_value);
OPT("time_format")
time_format = strdup(dest_value);
- OPT("battery_path") {
+ OPT("battery") {
struct battery *new = calloc(1, sizeof(struct battery));
if (new == NULL)
die("Could not allocate memory\n");
- new->path = strdup(dest_value);
+ if (asprintf(&(new->path), "/sys/class/power_supply/BAT%d/uevent", atoi(dest_value)) == -1)
+ die("Could not build battery path\n");
+
+ /* check if flags were specified for this battery */
+ if (strstr(dest_value, ",") != NULL) {
+ char *flags = strstr(dest_value, ",");
+ flags++;
+ if (*flags == 'f')
+ new->use_last_full = true;
+ }
SIMPLEQ_INSERT_TAIL(&batteries, new, batteries);
} OPT("color")
use_colors = true;
write_to_statusbar(concat(order[ORDER_ETH], "eth"), get_eth_info(), false);
struct battery *current_battery;
SIMPLEQ_FOREACH(current_battery, &batteries, batteries) {
- write_to_statusbar(concat(order[ORDER_BATTERY], "battery"), get_battery_info(current_battery->path), false);
+ write_to_statusbar(concat(order[ORDER_BATTERY], "battery"), get_battery_info(current_battery), false);
}
/* Get load */