4 enum { O_DZEN2, O_XMOBAR, O_NONE } output_format;
9 #define BEGINS_WITH(haystack, needle) (strncmp(haystack, needle, strlen(needle)) == 0)
10 #define max(a, b) ((a) > (b) ? (a) : (b))
14 #define THERMAL_ZONE "/sys/class/thermal/thermal_zone%d/temp"
16 #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
18 #define THERMAL_ZONE "hw.acpi.thermal.tz%d.temperature"
19 #define BATT_LIFE "hw.acpi.battery.life"
20 #define BATT_TIME "hw.acpi.battery.time"
21 #define BATT_STATE "hw.acpi.battery.state"
25 #if defined(__FreeBSD_kernel__) && defined(__GLIBC__)
28 #include <sys/param.h>
32 /* Allows for the definition of a variable without opening a new scope, thus
33 * suited for usage in a macro. Idea from wmii. */
34 #define with(type, var, init) \
35 for (type var = (type)-1; (var == (type)-1) && ((var=(init)) || 1); )
37 #define CASE_SEC(name) \
38 if (BEGINS_WITH(current, name)) \
39 with(cfg_t *, sec, cfg_getsec(cfg, name)) \
42 #define CASE_SEC_TITLE(name) \
43 if (BEGINS_WITH(current, name)) \
44 with(const char *, title, current + strlen(name) + 1) \
45 with(cfg_t *, sec, cfg_gettsec(cfg, name, title)) \
49 typedef enum { CS_DISCHARGING, CS_CHARGING, CS_FULL } charging_status_t;
52 char *skip_character(char *input, char character, int amount);
53 void die(const char *fmt, ...);
54 bool slurp(char *filename, char *destination, int size);
57 void print_seperator();
58 char *color(const char *colorstr);
59 char *endcolor() __attribute__ ((pure));
61 void print_ipv6_info(const char *format_up, const char *format_down);
62 void print_disk_info(const char *path, const char *format);
63 void print_battery_info(int number, const char *format, bool last_full_capacity);
64 void print_time(const char *format);
65 void print_ddate(const char *format);
66 const char *get_ip_addr();
67 void print_wireless_info(const char *interface, const char *format_up, const char *format_down);
68 void print_run_watch(const char *title, const char *pidfile, const char *format);
69 void print_cpu_temperature_info(int zone, const char *format);
70 void print_eth_info(const char *interface, const char *format_up, const char *format_down);
72 bool process_runs(const char *path);
74 /* socket file descriptor for general purposes */
75 extern int general_socket;
77 extern cfg_t *cfg, *cfg_general;