]> git.sur5r.net Git - i3/i3status/blob - include/i3status.h
FreeBSD: switch from acpi to coretemp to get the cpu temperature
[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 /* this needs the coretemp module to be loaded */
20 #define THERMAL_ZONE "dev.cpu.%d.temperature"
21 #define BATT_LIFE "hw.acpi.battery.life"
22 #define BATT_TIME "hw.acpi.battery.time"
23 #define BATT_STATE "hw.acpi.battery.state"
24
25 #endif
26
27 #if defined(__FreeBSD_kernel__) && defined(__GLIBC__)
28
29 #include <sys/stat.h>
30 #include <sys/param.h>
31
32 #endif
33
34 /* Allows for the definition of a variable without opening a new scope, thus
35  * suited for usage in a macro. Idea from wmii. */
36 #define with(type, var, init) \
37         for (type var = (type)-1; (var == (type)-1) && ((var=(init)) || 1); )
38
39 #define CASE_SEC(name) \
40         if (BEGINS_WITH(current, name)) \
41                 with(cfg_t *, sec, cfg_getsec(cfg, name)) \
42                         if (sec != NULL)
43
44 #define CASE_SEC_TITLE(name) \
45         if (BEGINS_WITH(current, name)) \
46                 with(const char *, title, current + strlen(name) + 1) \
47                         with(cfg_t *, sec, cfg_gettsec(cfg, name, title)) \
48                                 if (sec != NULL)
49
50
51 typedef enum { CS_DISCHARGING, CS_CHARGING, CS_FULL } charging_status_t;
52
53 /* src/general.c */
54 char *skip_character(char *input, char character, int amount);
55 void die(const char *fmt, ...);
56 bool slurp(const char *filename, char *destination, int size);
57
58 /* src/output.c */
59 void print_seperator();
60 char *color(const char *colorstr);
61 char *endcolor() __attribute__ ((pure));
62
63 /* src/auto_detect_format.c */
64 char *auto_detect_format();
65
66 void print_ipv6_info(const char *format_up, const char *format_down);
67 void print_disk_info(const char *path, const char *format);
68 void print_battery_info(int number, const char *path, const char *format, bool last_full_capacity);
69 void print_time(const char *format, struct tm *current_tm);
70 void print_ddate(const char *format, struct tm *current_tm);
71 const char *get_ip_addr();
72 void print_wireless_info(const char *interface, const char *format_up, const char *format_down);
73 void print_run_watch(const char *title, const char *pidfile, const char *format);
74 void print_cpu_temperature_info(int zone, const char *path, const char *format);
75 void print_cpu_usage(const char *format);
76 void print_eth_info(const char *interface, const char *format_up, const char *format_down);
77 void print_load();
78 void print_volume(const char *fmt, const char *device, const char *mixer, int mixer_idx);
79 bool process_runs(const char *path);
80
81 /* socket file descriptor for general purposes */
82 extern int general_socket;
83
84 extern cfg_t *cfg, *cfg_general;
85
86 #endif