2009-07-21 17:07:30 +00:00
|
|
|
#ifndef _I3STATUS_H
|
|
|
|
#define _I3STATUS_H
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
#include "queue.h"
|
|
|
|
|
2009-08-18 19:29:44 +00:00
|
|
|
#ifdef DZEN
|
|
|
|
#define BAR "^fg(#333333)^p(5;-2)^ro(2)^p()^fg()^p(5)"
|
|
|
|
#elif XMOBAR
|
|
|
|
#define BAR "<fc=#333333> | </fc>"
|
|
|
|
#endif
|
2008-10-04 16:42:12 +00:00
|
|
|
#define BEGINS_WITH(haystack, needle) (strncmp(haystack, needle, strlen(needle)) == 0)
|
2009-07-21 17:07:30 +00:00
|
|
|
#define max(a, b) (a > b ? a : b)
|
2008-10-04 16:42:12 +00:00
|
|
|
|
2009-07-21 18:23:08 +00:00
|
|
|
#define generate(orderidx, name, function) \
|
|
|
|
do { \
|
2009-07-22 16:39:25 +00:00
|
|
|
write_to_statusbar(order_to_str(order[orderidx], name), function, (j == (highest_order-1))); \
|
2009-07-21 18:23:08 +00:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define generate_order(condition, orderidx, name, function) \
|
|
|
|
do { \
|
|
|
|
if (j == order[orderidx] && condition) \
|
|
|
|
generate(orderidx, name, function); \
|
|
|
|
} while (0)
|
|
|
|
|
2009-07-23 16:40:49 +00:00
|
|
|
#if defined(LINUX)
|
|
|
|
|
|
|
|
#define THERMAL_ZONE "/sys/class/thermal/thermal_zone%d/temp"
|
|
|
|
|
2009-08-31 17:34:57 +00:00
|
|
|
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
2009-07-23 16:40:49 +00:00
|
|
|
|
|
|
|
#define THERMAL_ZONE "hw.acpi.thermal.tz%d.temperature"
|
|
|
|
#define BATT_LIFE "hw.acpi.battery.life"
|
|
|
|
#define BATT_TIME "hw.acpi.battery.time"
|
|
|
|
#define BATT_STATE "hw.acpi.battery.state"
|
|
|
|
|
|
|
|
#endif
|
2009-07-21 18:23:08 +00:00
|
|
|
|
2009-08-31 17:34:57 +00:00
|
|
|
#if defined(__FreeBSD_kernel__) && defined(__GLIBC__)
|
|
|
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/param.h>
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2008-10-04 16:42:12 +00:00
|
|
|
typedef enum { CS_DISCHARGING, CS_CHARGING, CS_FULL } charging_status_t;
|
2009-07-21 18:23:08 +00:00
|
|
|
enum { ORDER_RUN, ORDER_WLAN, ORDER_ETH, ORDER_BATTERY, ORDER_CPU_TEMPERATURE, ORDER_LOAD, ORDER_TIME, ORDER_IPV6, MAX_ORDER };
|
2009-07-21 17:07:30 +00:00
|
|
|
|
|
|
|
struct battery {
|
|
|
|
char *path;
|
|
|
|
/* Use last full capacity instead of design capacity */
|
|
|
|
bool use_last_full;
|
|
|
|
SIMPLEQ_ENTRY(battery) batteries;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* src/general.c */
|
|
|
|
char *skip_character(char *input, char character, int amount);
|
|
|
|
void die(const char *fmt, ...);
|
|
|
|
void create_file(const char *name);
|
2009-07-21 18:23:08 +00:00
|
|
|
char *order_to_str(int number, char *name);
|
2009-07-21 17:07:30 +00:00
|
|
|
void setup(void);
|
|
|
|
void write_to_statusbar(const char *name, const char *message, bool final_entry);
|
2009-07-25 19:32:38 +00:00
|
|
|
bool slurp(char *filename, char *destination, int size);
|
2009-07-21 17:07:30 +00:00
|
|
|
|
|
|
|
/* src/output.c */
|
|
|
|
void write_error_to_statusbar(const char *message);
|
|
|
|
char *color(const char *colorstr);
|
2009-08-18 19:29:44 +00:00
|
|
|
char *endcolor() __attribute__ ((pure));
|
2009-07-21 17:07:30 +00:00
|
|
|
void cleanup_rbar_dir();
|
|
|
|
|
|
|
|
/* src/config.c */
|
|
|
|
int load_configuration(const char *configfile);
|
|
|
|
|
|
|
|
const char *get_ipv6_addr();
|
|
|
|
const char *get_battery_info(struct battery *bat);
|
|
|
|
const char *get_ip_addr();
|
|
|
|
const char *get_wireless_info();
|
|
|
|
const char *get_cpu_temperature_info();
|
|
|
|
const char *get_eth_info();
|
|
|
|
const char *get_load();
|
|
|
|
bool process_runs(const char *path);
|
|
|
|
|
|
|
|
SIMPLEQ_HEAD(battery_head, battery);
|
|
|
|
extern struct battery_head batteries;
|
|
|
|
|
|
|
|
/* socket file descriptor for general purposes */
|
|
|
|
extern int general_socket;
|
|
|
|
|
2009-07-22 16:39:25 +00:00
|
|
|
extern int highest_order;
|
|
|
|
|
2009-07-21 17:07:30 +00:00
|
|
|
extern const char *wlan_interface;
|
|
|
|
extern const char *eth_interface;
|
2009-09-01 21:43:24 +00:00
|
|
|
extern char *wmii_path;
|
2009-07-21 17:07:30 +00:00
|
|
|
extern const char *time_format;
|
|
|
|
extern bool use_colors;
|
|
|
|
extern bool get_ethspeed;
|
2009-07-21 18:23:08 +00:00
|
|
|
extern bool get_ipv6;
|
2009-07-21 17:07:30 +00:00
|
|
|
extern bool get_cpu_temperature;
|
|
|
|
extern char *thermal_zone;
|
|
|
|
extern const char *wmii_normcolors;
|
2009-07-21 18:23:08 +00:00
|
|
|
extern int order[MAX_ORDER];
|
2009-07-21 17:07:30 +00:00
|
|
|
extern const char **run_watches;
|
|
|
|
extern unsigned int num_run_watches;
|
|
|
|
extern unsigned int interval;
|
|
|
|
|
|
|
|
#endif
|