2009-07-21 17:07:30 +00:00
|
|
|
#ifndef _I3STATUS_H
|
|
|
|
#define _I3STATUS_H
|
|
|
|
|
2012-02-16 23:29:29 +00:00
|
|
|
enum { O_DZEN2, O_XMOBAR, O_I3BAR, O_NONE } output_format;
|
2009-10-23 22:38:26 +00:00
|
|
|
|
2009-07-21 17:07:30 +00:00
|
|
|
#include <stdbool.h>
|
2009-10-11 20:11:09 +00:00
|
|
|
#include <confuse.h>
|
2011-04-21 18:49:22 +00:00
|
|
|
#include <time.h>
|
2009-07-21 17:07:30 +00:00
|
|
|
|
2008-10-04 16:42:12 +00:00
|
|
|
#define BEGINS_WITH(haystack, needle) (strncmp(haystack, needle, strlen(needle)) == 0)
|
2009-10-11 20:11:09 +00:00
|
|
|
#define max(a, b) ((a) > (b) ? (a) : (b))
|
2009-07-21 18:23:08 +00:00
|
|
|
|
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
|
|
|
|
2011-12-09 23:30:22 +00:00
|
|
|
/* this needs the coretemp module to be loaded */
|
|
|
|
#define THERMAL_ZONE "dev.cpu.%d.temperature"
|
2009-07-23 16:40:49 +00:00
|
|
|
#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
|
|
|
|
|
2009-10-11 20:11:09 +00:00
|
|
|
/* Allows for the definition of a variable without opening a new scope, thus
|
|
|
|
* suited for usage in a macro. Idea from wmii. */
|
|
|
|
#define with(type, var, init) \
|
|
|
|
for (type var = (type)-1; (var == (type)-1) && ((var=(init)) || 1); )
|
|
|
|
|
|
|
|
#define CASE_SEC(name) \
|
|
|
|
if (BEGINS_WITH(current, name)) \
|
|
|
|
with(cfg_t *, sec, cfg_getsec(cfg, name)) \
|
|
|
|
if (sec != NULL)
|
2009-07-21 17:07:30 +00:00
|
|
|
|
2009-10-11 20:11:09 +00:00
|
|
|
#define CASE_SEC_TITLE(name) \
|
|
|
|
if (BEGINS_WITH(current, name)) \
|
|
|
|
with(const char *, title, current + strlen(name) + 1) \
|
|
|
|
with(cfg_t *, sec, cfg_gettsec(cfg, name, title)) \
|
|
|
|
if (sec != NULL)
|
|
|
|
|
|
|
|
|
|
|
|
typedef enum { CS_DISCHARGING, CS_CHARGING, CS_FULL } charging_status_t;
|
2009-07-21 17:07:30 +00:00
|
|
|
|
|
|
|
/* src/general.c */
|
|
|
|
char *skip_character(char *input, char character, int amount);
|
|
|
|
void die(const char *fmt, ...);
|
2010-11-28 15:45:34 +00:00
|
|
|
bool slurp(const char *filename, char *destination, int size);
|
2009-07-21 17:07:30 +00:00
|
|
|
|
|
|
|
/* src/output.c */
|
2009-10-11 20:11:09 +00:00
|
|
|
void print_seperator();
|
2009-07-21 17:07:30 +00:00
|
|
|
char *color(const char *colorstr);
|
2009-08-18 19:29:44 +00:00
|
|
|
char *endcolor() __attribute__ ((pure));
|
2011-07-13 01:27:57 +00:00
|
|
|
|
|
|
|
/* src/auto_detect_format.c */
|
|
|
|
char *auto_detect_format();
|
2009-07-21 17:07:30 +00:00
|
|
|
|
2010-04-05 13:47:56 +00:00
|
|
|
void print_ipv6_info(const char *format_up, const char *format_down);
|
2009-10-11 21:27:26 +00:00
|
|
|
void print_disk_info(const char *path, const char *format);
|
2011-11-26 18:26:38 +00:00
|
|
|
void print_battery_info(int number, const char *path, const char *format, bool last_full_capacity);
|
2011-04-21 18:49:22 +00:00
|
|
|
void print_time(const char *format, struct tm *current_tm);
|
2011-04-21 23:10:40 +00:00
|
|
|
void print_ddate(const char *format, struct tm *current_tm);
|
2009-07-21 17:07:30 +00:00
|
|
|
const char *get_ip_addr();
|
2009-10-11 20:11:09 +00:00
|
|
|
void print_wireless_info(const char *interface, const char *format_up, const char *format_down);
|
|
|
|
void print_run_watch(const char *title, const char *pidfile, const char *format);
|
2011-01-06 17:22:46 +00:00
|
|
|
void print_cpu_temperature_info(int zone, const char *path, const char *format);
|
2011-02-26 22:45:12 +00:00
|
|
|
void print_cpu_usage(const char *format);
|
2009-10-16 18:14:40 +00:00
|
|
|
void print_eth_info(const char *interface, const char *format_up, const char *format_down);
|
2009-10-11 20:11:09 +00:00
|
|
|
void print_load();
|
2010-07-20 17:30:27 +00:00
|
|
|
void print_volume(const char *fmt, const char *device, const char *mixer, int mixer_idx);
|
2009-07-21 17:07:30 +00:00
|
|
|
bool process_runs(const char *path);
|
|
|
|
|
|
|
|
/* socket file descriptor for general purposes */
|
|
|
|
extern int general_socket;
|
|
|
|
|
2009-10-11 20:11:09 +00:00
|
|
|
extern cfg_t *cfg, *cfg_general;
|
2009-07-21 17:07:30 +00:00
|
|
|
|
|
|
|
#endif
|