#include <dirent.h>
#include <getopt.h>
+#include "queue.h"
+
#ifdef LINUX
#include <linux/ethtool.h>
#include <linux/sockios.h>
#define BAR "^fg(#333333)^p(5;-2)^ro(2)^p()^fg()^p(5)"
+struct battery {
+ const char *path;
+ SIMPLEQ_ENTRY(battery) batteries;
+};
+
+SIMPLEQ_HEAD(battery_head, battery) batteries;
+
/* socket file descriptor for general purposes */
static int general_socket;
* worn off your battery is.
*
*/
-static char *get_battery_info() {
+static char *get_battery_info(const char *path) {
char buf[1024];
static char part[512];
char *walk, *last;
present_rate = -1;
charging_status_t status = CS_DISCHARGING;
- if ((fd = open(battery_path, O_RDONLY)) == -1)
+ if ((fd = open(path, O_RDONLY)) == -1)
return "No battery found";
memset(part, 0, sizeof(part));
eth_interface = strdup(dest_value);
OPT("time_format")
time_format = strdup(dest_value);
- OPT("battery_path")
- battery_path = strdup(dest_value);
- OPT("color")
+ OPT("battery_path") {
+ struct battery *new = calloc(1, sizeof(struct battery));
+ if (new == NULL)
+ die("Could not allocate memory\n");
+ new->path = strdup(dest_value);
+ SIMPLEQ_INSERT_TAIL(&batteries, new, batteries);
+ } OPT("color")
use_colors = true;
OPT("get_ethspeed")
get_ethspeed = true;
{0, 0, 0, 0}
};
+ SIMPLEQ_INIT(&batteries);
+
while ((o = getopt_long(argc, argv, "c:h", long_options, &option_index)) != -1)
if ((char)o == 'c')
configfile = optarg;
write_to_statusbar(concat(order[ORDER_WLAN], "wlan"), get_wireless_info(), false);
if (eth_interface)
write_to_statusbar(concat(order[ORDER_ETH], "eth"), get_eth_info(), false);
- if (battery_path)
- write_to_statusbar(concat(order[ORDER_BATTERY], "battery"), get_battery_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);
+ }
/* Get load */
#ifdef LINUX