8 #define BAR "^fg(#333333)^p(5;-2)^ro(2)^p()^fg()^p(5)"
10 #define BAR "<fc=#333333> | </fc>"
12 #define BEGINS_WITH(haystack, needle) (strncmp(haystack, needle, strlen(needle)) == 0)
13 #define max(a, b) ((a) > (b) ? (a) : (b))
17 #define THERMAL_ZONE "/sys/class/thermal/thermal_zone%d/temp"
19 #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
21 #define THERMAL_ZONE "hw.acpi.thermal.tz%d.temperature"
22 #define BATT_LIFE "hw.acpi.battery.life"
23 #define BATT_TIME "hw.acpi.battery.time"
24 #define BATT_STATE "hw.acpi.battery.state"
28 #if defined(__FreeBSD_kernel__) && defined(__GLIBC__)
31 #include <sys/param.h>
35 /* Allows for the definition of a variable without opening a new scope, thus
36 * suited for usage in a macro. Idea from wmii. */
37 #define with(type, var, init) \
38 for (type var = (type)-1; (var == (type)-1) && ((var=(init)) || 1); )
40 #define CASE_SEC(name) \
41 if (BEGINS_WITH(current, name)) \
42 with(cfg_t *, sec, cfg_getsec(cfg, name)) \
45 #define CASE_SEC_TITLE(name) \
46 if (BEGINS_WITH(current, name)) \
47 with(const char *, title, current + strlen(name) + 1) \
48 with(cfg_t *, sec, cfg_gettsec(cfg, name, title)) \
52 typedef enum { CS_DISCHARGING, CS_CHARGING, CS_FULL } charging_status_t;
55 char *skip_character(char *input, char character, int amount);
56 void die(const char *fmt, ...);
57 bool slurp(char *filename, char *destination, int size);
60 void print_seperator();
61 char *color(const char *colorstr);
62 char *endcolor() __attribute__ ((pure));
64 void print_ipv6_info(const char *format);
65 void print_disk_info(const char *path, const char *format);
66 void print_battery_info(int number, const char *format);
67 void print_time(const char *format);
68 const char *get_ip_addr();
69 void print_wireless_info(const char *interface, const char *format_up, const char *format_down);
70 void print_run_watch(const char *title, const char *pidfile, const char *format);
71 void print_cpu_temperature_info(int zone, const char *format);
72 void print_eth_info(const char *interface, const char *format);
74 bool process_runs(const char *path);
76 /* socket file descriptor for general purposes */
77 extern int general_socket;
79 extern cfg_t *cfg, *cfg_general;