]> git.sur5r.net Git - i3/i3status/blob - include/i3status.h
a54208f86bfb2ed039117a1de999aa5bda8f0c2a
[i3/i3status] / include / i3status.h
1 #ifndef _I3STATUS_H
2 #define _I3STATUS_H
3
4 enum { O_DZEN2, O_XMOBAR, O_NONE } output_format;
5
6 #include <stdbool.h>
7 #include <confuse.h>
8 #include <time.h>
9
10 #define BEGINS_WITH(haystack, needle) (strncmp(haystack, needle, strlen(needle)) == 0)
11 #define max(a, b) ((a) > (b) ? (a) : (b))
12
13 #if defined(LINUX)
14
15 #define THERMAL_ZONE "/sys/class/thermal/thermal_zone%d/temp"
16
17 #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
18
19 #define THERMAL_ZONE "hw.acpi.thermal.tz%d.temperature"
20 #define BATT_LIFE "hw.acpi.battery.life"
21 #define BATT_TIME "hw.acpi.battery.time"
22 #define BATT_STATE "hw.acpi.battery.state"
23
24 #endif
25
26 #if defined(__FreeBSD_kernel__) && defined(__GLIBC__)
27
28 #include <sys/stat.h>
29 #include <sys/param.h>
30
31 #endif
32
33 /* Allows for the definition of a variable without opening a new scope, thus
34  * suited for usage in a macro. Idea from wmii. */
35 #define with(type, var, init) \
36         for (type var = (type)-1; (var == (type)-1) && ((var=(init)) || 1); )
37
38 #define CASE_SEC(name) \
39         if (BEGINS_WITH(current, name)) \
40                 with(cfg_t *, sec, cfg_getsec(cfg, name)) \
41                         if (sec != NULL)
42
43 #define CASE_SEC_TITLE(name) \
44         if (BEGINS_WITH(current, name)) \
45                 with(const char *, title, current + strlen(name) + 1) \
46                         with(cfg_t *, sec, cfg_gettsec(cfg, name, title)) \
47                                 if (sec != NULL)
48
49
50 typedef enum { CS_DISCHARGING, CS_CHARGING, CS_FULL } charging_status_t;
51
52 /* src/general.c */
53 char *skip_character(char *input, char character, int amount);
54 void die(const char *fmt, ...);
55 bool slurp(const char *filename, char *destination, int size);
56
57 /* src/output.c */
58 void print_seperator();
59 char *color(const char *colorstr);
60 char *endcolor() __attribute__ ((pure));
61
62 /* src/auto_detect_format.c */
63 char *auto_detect_format();
64
65 void print_ipv6_info(const char *format_up, const char *format_down);
66 void print_disk_info(const char *path, const char *format);
67 void print_battery_info(int number, const char *path, const char *format, bool last_full_capacity);
68 void print_time(const char *format, struct tm *current_tm);
69 void print_ddate(const char *format, struct tm *current_tm);
70 const char *get_ip_addr();
71 void print_wireless_info(const char *interface, const char *format_up, const char *format_down);
72 void print_run_watch(const char *title, const char *pidfile, const char *format);
73 void print_cpu_temperature_info(int zone, const char *path, const char *format);
74 void print_cpu_usage(const char *format);
75 void print_eth_info(const char *interface, const char *format_up, const char *format_down);
76 void print_load();
77 void print_volume(const char *fmt, const char *device, const char *mixer, int mixer_idx);
78 bool process_runs(const char *path);
79
80 /* socket file descriptor for general purposes */
81 extern int general_socket;
82
83 extern cfg_t *cfg, *cfg_general;
84
85 #endif