read some more battery data using new bme.c file but not stable, crashes after 23...
[monky] / src / conky.h
index 8b38a94..3e96cb3 100644 (file)
@@ -1,4 +1,7 @@
-/* Conky, a system monitor, based on torsmo
+/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
+ * vim: ts=4 sw=4 noet ai cindent syntax=c
+ *
+ * Conky, a system monitor, based on torsmo
  *
  * Any original torsmo code is licensed under the BSD license
  *
@@ -7,7 +10,7 @@
  * Please see COPYING for details
  *
  * Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
- * Copyright (c) 2005-2008 Brenden Matthews, Philip Kovacs, et. al.
+ * Copyright (c) 2005-2010 Brenden Matthews, Philip Kovacs, et. al.
  *     (see AUTHORS)
  * All rights reserved.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
- * $Id$
- *
  */
 
 #ifndef _conky_h_
 #define _conky_h_
 
+#include "config.h"    /* defines */
+#include "common.h"    /* at least for struct dns_data */
+#include <sys/utsname.h> /* struct uname_s */
+#include <arpa/inet.h>
+
 #if defined(HAS_MCHECK_H)
 #include <mcheck.h>
 #endif /* HAS_MCHECK_H */
 #define FALSE 0
 #define TRUE 1
 
-#include "config.h"
-#include <sys/utsname.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <locale.h>
-#include <langinfo.h>
-#include <wchar.h>
-#include <sys/param.h>
+#define DEFAULT_BAR_WIDTH_NO_X 10
 
 #if !defined(__GNUC__)
 #  define __attribute__(x) /* nothing */
 #endif
 
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
-#include "freebsd.h"
-#endif /* __FreeBSD__ || __FreeBSD_kernel__ */
-
-#if defined(__OpenBSD__)
-#include "openbsd.h"
-#endif /* __OpenBSD__ */
-
 #ifndef HAVE_STRNDUP
 // use our own strndup() if it's not available
 char *strndup(const char *s, size_t n);
 #endif /* HAVE_STRNDUP */
 
+/* headers of optional features
+ * include them here, so we don't need to run the check
+ * in every code file optionally using the feature
+ */
+
+/* forward define to make gcc happy */
+struct text_object;
+
 #ifdef AUDACIOUS
 #include "audacious.h"
 #endif
 
-#ifdef XMMS2
-#include <xmmsclient/xmmsclient.h>
-#endif
-
-#ifdef RSS
-#include "rss.h"
+#ifdef BMPX
+#include "bmpx.h"
 #endif
 
 #ifdef EVE
 #include "eve.h"
 #endif
 
-#ifdef SMAPI
-#include "smapi.h"
-#endif
+#ifdef HDDTEMP
+#include "hddtemp.h"
+#endif /* HDDTEMP */
 
-#ifdef NVIDIA
-#include "nvidia.h"
+#ifdef MOC
+#include "moc.h"
 #endif
 
-#include "mboxscan.h"
-#include "timed_thread.h"
-#include "top.h"
-
-#define DEFAULT_TEXT_BUFFER_SIZE 256
-extern unsigned int text_buffer_size;
-
-/* maximum number of special things, e.g. fonts, offsets, aligns, etc. */
-#define MAX_SPECIALS_DEFAULT 512
-
-/* maximum size of config TEXT buffer, i.e. below TEXT line. */
-#define MAX_USER_TEXT_DEFAULT 16384
-
-#include <sys/socket.h>
-
-#define ERR(...) { \
-       fprintf(stderr, PACKAGE_NAME": "); \
-       fprintf(stderr, __VA_ARGS__); \
-       fprintf(stderr, "\n"); \
-}
-
-/* critical error */
-#define CRIT_ERR(...) \
-       { ERR(__VA_ARGS__); exit(EXIT_FAILURE); }
-
-struct net_stat {
-       const char *dev;
-       int up;
-       long long last_read_recv, last_read_trans;
-       long long recv, trans;
-       double recv_speed, trans_speed;
-       struct sockaddr addr;
-       char* addrs;
-       double net_rec[15], net_trans[15];
-       // wireless extensions
-       char essid[32];
-       char bitrate[16];
-       char mode[16];
-       int link_qual;
-       int link_qual_max;
-       char ap[18];
-};
-
-struct dns_data {
-       int nscount;
-       char **ns_list;
-};
+#ifdef MPD
+#include "mpd.h"
+#endif
 
-struct fs_stat {
-       char path[DEFAULT_TEXT_BUFFER_SIZE];
-       char type[DEFAULT_TEXT_BUFFER_SIZE];
-       long long size;
-       long long avail;
-       long long free;
-       char set;
-};
+#ifdef HAVE_CURL
+#include "ccurl_thread.h"
+#endif /* HAVE_CURL */
 
-#include "diskio.h"
-
-struct mail_s {                        // for imap and pop3
-       unsigned long unseen;
-       unsigned long messages;
-       unsigned long used;
-       unsigned long quota;
-       unsigned long port;
-       unsigned int retries;
-       float interval;
-       double last_update;
-       char host[128];
-       char user[128];
-       char pass[128];
-       char command[1024];
-       char folder[128];
-       timed_thread *p_timed_thread;
-       char secure;
-};
+#ifdef RSS
+#include "rss.h"
+#endif /* RSS */
 
-/* struct cpu_stat {
-       unsigned int user, nice, system, idle, iowait, irq, softirq;
-       int cpu_avg_samples;
-}; */
+#ifdef XOAP
+#ifndef WEATHER
+#error "WEATHER needs to be defined if XOAP is defined"
+#endif /* WEATHER */
+#endif /* XOAP */
 
-#ifdef MPD
-#include "mpd.h"
-#endif
+#ifdef WEATHER
+#include "weather.h"
+#endif /* WEATHER */
 
-#ifdef MOC
-#include "moc.h"
+#ifdef TCP_PORT_MONITOR
+#include "tcp-portmon.h"
 #endif
 
 #ifdef XMMS2
 #include "xmms2.h"
 #endif
 
-#ifdef AUDACIOUS
-#include "audacious.h"
+#ifdef IBM
+#include "ibm.h"
+#include "smapi.h"
 #endif
 
-#ifdef BMPX
-#include "bmpx.h"
+#ifdef APCUPSD
+#include "apcupsd.h"
 #endif
 
-void update_entropy(void);
-struct entropy_s {
-       unsigned int entropy_avail;
-       unsigned int poolsize;
-};
+/* sony support */
+#include "sony.h"
+
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib.h>
+#include <glib.h>
+#include <mce/mode-names.h>
+
+
+DBusConnection* conn;//session bus
+DBusConnection* conn2;//system bus
+DBusMessage* msg;
+DBusMessageIter args;
+DBusError err;
+int ret;
+
+/* A size for temporary, static buffers to use when
+ * one doesn't know what to choose. Defaults to 256.  */
+extern unsigned int text_buffer_size;
 
 struct usr_info {
        char *names;
        char *times;
+       char *ctime;
        char *terms;
        int number;
 };
 
-struct gateway_info {
-       char *iface;
-       char *ip;
-       int count;
-};
-
 #ifdef X11
 struct monitor_info {
        int number;
        int current;
 };
 
+struct desktop_info {
+        int current;
+        int number;
+        unsigned int nitems;
+        char *all_names;
+        char *name;
+};
+
 struct x11_info {
        struct monitor_info monitor;
+       struct desktop_info desktop;
 };
-#endif
 
-#ifdef TCP_PORT_MONITOR
-#include "libtcp-portmon.h"
-#endif
+int get_stippled_borders(void);
 
-enum {
-       INFO_CPU = 0,
-       INFO_MAIL = 1,
-       INFO_MEM = 2,
-       INFO_NET = 3,
-       INFO_PROCS = 4,
-       INFO_RUN_PROCS = 5,
-       INFO_UPTIME = 6,
-       INFO_BUFFERS = 7,
-       INFO_FS = 8,
-       INFO_SYSFS = 9,
-       INFO_MIXER = 10,
-       INFO_LOADAVG = 11,
-       INFO_UNAME = 12,
-       INFO_FREQ = 13,
-#ifdef MPD
-       INFO_MPD = 14,
-#endif
-       INFO_TOP = 15,
-       INFO_WIFI = 16,
-       INFO_DISKIO = 17,
-       INFO_I8K = 18,
-#ifdef TCP_PORT_MONITOR
-       INFO_TCP_PORT_MONITOR = 19,
-#endif
-#ifdef AUDACIOUS
-       INFO_AUDACIOUS = 20,
-#endif
-#ifdef BMPX
-       INFO_BMPX = 21,
-#endif
-#ifdef XMMS2
-       INFO_XMMS2 = 22,
-#endif
-       INFO_ENTROPY = 23,
-#ifdef RSS
-       INFO_RSS = 24,
-#endif
-#ifdef SMAPI
-       INFO_SMAPI = 25,
-#endif
-       INFO_USERS = 26,
-       INFO_GW = 27,
-#ifdef NVIDIA
-       INFO_NVIDIA = 28,
-#endif
-#ifdef X11
-       INFO_X11 = 29,
-#endif
-       INFO_DNS = 30,
-#ifdef MOC
-  INFO_MOC = 31
-#endif
+#endif /* X11 */
+
+/* defined in conky.c */
+extern long default_fg_color, default_bg_color, default_out_color;
+extern long color0, color1, color2, color3, color4, color5, color6, color7,
+          color8, color9;
+void set_current_text_color(long colour);
+long get_current_text_color(void);
+
+void set_updatereset(int);
+int get_updatereset(void);
+
+int percent_print(char *, int, unsigned);
+void human_readable(long long, char *, int);
+
+struct conftree {
+       char* string;
+       struct conftree* horz_next;
+       struct conftree* vert_next;
+       struct conftree* back;
 };
 
-/* get_battery_stuff() item selector */
+char load_config_file(const char *);
+
+char *get_global_text(void);
+extern long global_text_lines;
+
+//adds newstring to to the tree unless you can already see it when travelling back.
+//if it's possible to attach it then it returns a pointer to the leaf, else it returns NULL
+struct conftree* conftree_add(struct conftree* previous, const char* newstring);
+
+extern struct conftree *currentconffile;
+
+#define MAX_TEMPLATES 10
+char **get_templates(void);
+
+/* get_xxxxx_stuff() item selector
+ * needed by conky.c, linux.c and freebsd.c */
 enum {
        BATTERY_STATUS,
-       BATTERY_TIME
+       BATTERY_TIME,
+       BATTERY_VOLTS,
+       BATTERY_TEMP,
+        BATTERY_RATE,
+       DBUS_CELL_DBM,
+       DBUS_CELL_PERCENT,
+       DBUS_HAL_BATTERY_CHRG_STATUS,
+       DBUS_HAL_BATTERY_PERCENT,
+       DBUS_HAL_BATTERY_VOLTS_CURRENT
 };
 
-/* if_up strictness selector */
+/* if_up strictness selector
+ * needed by conky.c and linux.c (and potentially others) */
 enum {
        IFUP_UP,
        IFUP_LINK,
        IFUP_ADDR
 } ifup_strictness;
 
-/* Update interval */
-double update_interval;
-
-volatile int g_signal_pending;
-
 struct information {
        unsigned int mask;
 
@@ -311,35 +243,27 @@ struct information {
        double uptime;
 
        /* memory information in kilobytes */
-       unsigned long long mem, memeasyfree, memfree, memmax, swap, swapmax;
+       unsigned long long mem, memeasyfree, memfree, memmax, swap, swapfree, swapmax;
        unsigned long long bufmem, buffers, cached;
 
        unsigned short procs;
        unsigned short run_procs;
+       unsigned short threads;
+       unsigned short run_threads;
 
        float *cpu_usage;
        /* struct cpu_stat cpu_summed; what the hell is this? */
-       unsigned int cpu_count;
-       unsigned int cpu_avg_samples;
+       int cpu_count;
+       int cpu_avg_samples;
+
+       int net_avg_samples;
 
-       unsigned int net_avg_samples;
+       int diskio_avg_samples;
 
        float loadavg[3];
 
-       struct mail_s *mail;
-       int mail_running;
-#ifdef MPD
-       struct mpd_s mpd;
-#endif
-#ifdef MOC
-  struct moc_s moc;
-#endif
 #ifdef XMMS2
        struct xmms2_s xmms2;
-       int xmms2_conn_state;
-       xmms_socket_t xmms2_fd;
-       fd_set xmms2_fdset;
-       xmmsc_connection_t *xmms2_conn;
 #endif
 #ifdef AUDACIOUS
        AUDACIOUS_S audacious;
@@ -348,29 +272,32 @@ struct information {
        struct bmpx_s bmpx;
 #endif
        struct usr_info users;
-       struct gateway_info gw_info;
-       struct dns_data nameserver_info;
        struct process *cpu[10];
        struct process *memu[10];
+       struct process *time[10];
+#ifdef IOSTATS
+       struct process *io[10];
+#endif
        struct process *first_process;
        unsigned long looped;
-#ifdef TCP_PORT_MONITOR
-       tcp_port_monitor_collection_t *p_tcp_port_monitor_collection;
-#endif
-       struct entropy_s entropy;
        double music_player_interval;
 
 #ifdef X11
        struct x11_info x11;
 #endif
 
-       short kflags;   /* kernel settings, see enum KFLAG */
+#ifdef APCUPSD
+       APCUPSD_S apcupsd;
+#endif
 
-       unsigned int diskio_value;
-       unsigned int diskio_read_value;
-       unsigned int diskio_write_value;
+       short kflags;   /* kernel settings, see enum KFLAG */
 };
 
+#ifdef HAVE_LUA
+#include "llua.h"
+#endif /* HAVE_LUA */
+
+/* needed by linux.c and top.c -> outsource somewhere */
 enum {
        /* set to true if kernel uses "long" format for /proc/stats */
        KFLAG_IS_LONGSTAT = 0x01,
@@ -380,84 +307,79 @@ enum {
        /* bits 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 available for future use */
        /* KFLAG_NEXT_ONE = 0x04 */
 };
-
 #define KFLAG_SETON(a) info.kflags |= a
 #define KFLAG_SETOFF(a) info.kflags &= (~a)
 #define KFLAG_FLIP(a) info.kflags ^= a
 #define KFLAG_ISSET(a) info.kflags & a
 
-#define TO_X 1
-#define TO_STDOUT 2
-int output_methods;
-
-int top_cpu;
-int top_mem;
-
-int use_spacer;
+/* defined in conky.c, needed by top.c */
+extern int top_cpu, top_mem, top_time;
+#ifdef IOSTATS
+extern int top_io;
+#endif
+extern int top_running;
 
-enum spacer_opts { NO_SPACER = 0, LEFT_SPACER, RIGHT_SPACER };
+/* defined in conky.c, needed by top.c */
+extern int cpu_separate;
 
-char *tmpstring1;
-char *tmpstring2;
+/* struct that has all info to be shared between
+ * instances of the same text object */
+extern struct information info;
 
-#ifdef X11
-#include "x11.h"
-#endif /* X11 */
+/* defined in users.c */
+int update_users(void);
+void update_user_time(char *tty);
 
-int cpu_separate;
-int short_units;
+/* defined in conky.c */
+extern double current_update_time, last_update_time, update_interval;
+extern int update_heartbeat_min, update_heartbeat_max, update_heartbeat_battery_skip, update_skips_when_sleeping;
+/* defined in conky.c */
+int spaced_print(char *, int, const char *, int, ...)
+       __attribute__((format(printf, 3, 5)));
+extern int inotify_fd;
 
-/* struct that has all info */
-struct information info;
+/* defined in conky.c
+ * evaluates 'text' and places the result in 'p' of max length 'p_max_size'
+ */
+void evaluate(const char *text, char *p, int p_max_size);
 
-void signal_handler(int);
-void reload_config(void);
-void clean_up(void);
+/* maximum size of config TEXT buffer, i.e. below TEXT line. */
+extern unsigned int max_user_text;
 
-void update_uname(void);
-double get_time(void);
-FILE *open_file(const char *file, int *reported);
-void variable_substitute(const char *s, char *dest, unsigned int n);
-void format_seconds(char *buf, unsigned int n, long t);
-void format_seconds_short(char *buf, unsigned int n, long t);
-struct net_stat *get_net_stat(const char *dev);
-void clear_net_stats(void);
-void free_dns_data(void);
-void update_dns_data(void);
-void update_users(void);
+/* path to config file */
+extern char *current_config;
 
 #ifdef X11
-void update_x11info(void);
-#endif
-
-void update_stuff(void);
-
-int round_to_int(float f);
-
-extern unsigned long long need_mask;
-
-extern double current_update_time, last_update_time;
+#define TO_X 1
+#endif /* X11 */
+#define TO_STDOUT 2
+#define TO_STDERR 4
+#define OVERWRITE_FILE 8
+#define APPEND_FILE 16
+#ifdef NCURSES
+#define TO_NCURSES 32
+#endif /* NCURSES */
+enum x_initialiser_state {
+       NO = 0,
+       YES = 1,
+       NEVER = 2
+};
+extern int output_methods;
+extern enum x_initialiser_state x_initialised;
 
-extern int no_buffers;
+void set_update_interval(double interval);
 
-#if defined(__linux__)
-#include "linux.h"
-#endif
+#define DEFAULT_TEXT_BUFFER_SIZE_S "##DEFAULT_TEXT_BUFFER_SIZE"
 
-#include "fs.h"
-#include "mixer.h"
-#include "mail.h"
+#define NOBATTERY 0
 
-#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \
-               || defined(__OpenBSD__)) && (defined(i386) || defined(__i386__))
-int apm_getinfo(int fd, apm_info_t aip);
-char *get_apm_adapter(void);
-char *get_apm_battery_life(void);
-char *get_apm_battery_time(void);
-#endif
+/* to get rid of 'unused variable' warnings */
+#define UNUSED(a)  (void)a
+#define UNUSED_ATTR __attribute__ ((unused))
 
-#ifdef HDDTEMP
-#include "hddtemp.h"
-#endif /* HDDTEMP */
+void parse_conky_vars(struct text_object *, const char *,
+                       char *, int, struct information *);
 
-#endif
+void generate_text_internal(char *, int, struct text_object,
+                                   struct information *);
+#endif /* _conky_h_ */