2018-05-12 16:03:00 +00:00
|
|
|
/*
|
2010-01-07 03:45:19 +00:00
|
|
|
*
|
|
|
|
* Conky, a system monitor, based on torsmo
|
|
|
|
*
|
|
|
|
* Please see COPYING for details
|
|
|
|
*
|
2018-05-12 16:03:00 +00:00
|
|
|
* Copyright (c) 2005-2018 Brenden Matthews, Philip Kovacs, et. al.
|
2010-01-07 03:45:19 +00:00
|
|
|
* (see AUTHORS)
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
2009-09-22 16:19:08 +00:00
|
|
|
*/
|
2009-07-28 21:44:22 +00:00
|
|
|
|
2008-12-15 21:40:24 +00:00
|
|
|
#ifndef _COMMON_H
|
|
|
|
#define _COMMON_H
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2008-12-23 03:59:42 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2008-12-15 21:40:24 +00:00
|
|
|
#include <sys/socket.h>
|
2018-05-12 16:03:00 +00:00
|
|
|
#include <string>
|
2010-03-07 12:20:16 +00:00
|
|
|
#include "setting.hh"
|
2018-05-12 16:03:00 +00:00
|
|
|
#include "text_object.h"
|
2008-06-14 18:41:12 +00:00
|
|
|
|
2018-05-12 16:03:00 +00:00
|
|
|
char *readfile(const char *filename, int *total_read, char showerror);
|
2010-04-15 14:05:42 +00:00
|
|
|
|
2018-08-07 23:22:23 +00:00
|
|
|
void print_to_bytes(struct text_object *, char *, unsigned int);
|
2010-01-04 17:06:14 +00:00
|
|
|
|
2009-07-21 21:41:47 +00:00
|
|
|
void strfold(char *start, int count);
|
2009-11-16 22:30:53 +00:00
|
|
|
int check_mount(struct text_object *);
|
2008-06-14 18:41:12 +00:00
|
|
|
void prepare_update(void);
|
2010-05-05 16:46:04 +00:00
|
|
|
int update_uptime(void);
|
|
|
|
int update_meminfo(void);
|
|
|
|
int update_net_stats(void);
|
|
|
|
int update_cpu_usage(void);
|
|
|
|
int update_total_processes(void);
|
|
|
|
int update_uname(void);
|
|
|
|
int update_threads(void);
|
|
|
|
int update_running_processes(void);
|
2009-08-07 07:24:24 +00:00
|
|
|
void update_stuff(void);
|
2008-06-14 18:41:12 +00:00
|
|
|
char get_freq(char *, size_t, const char *, int, unsigned int);
|
2018-08-07 23:22:23 +00:00
|
|
|
void print_voltage_mv(struct text_object *, char *, unsigned int);
|
|
|
|
void print_voltage_v(struct text_object *, char *, unsigned int);
|
2010-05-05 16:46:04 +00:00
|
|
|
int update_load_average(void);
|
2008-06-14 18:41:12 +00:00
|
|
|
void free_all_processes(void);
|
|
|
|
struct process *get_first_process(void);
|
|
|
|
void get_cpu_count(void);
|
2008-12-15 21:40:24 +00:00
|
|
|
double get_time(void);
|
|
|
|
|
2010-03-04 10:42:38 +00:00
|
|
|
/* Converts '~/...' paths to '/home/blah/...'
|
2018-05-12 16:03:00 +00:00
|
|
|
* It's similar to variable_substitute, except only cheques for $HOME and ~/ in
|
|
|
|
* path */
|
2010-03-04 10:42:38 +00:00
|
|
|
std::string to_real_path(const std::string &source);
|
2009-07-22 20:08:31 +00:00
|
|
|
FILE *open_file(const char *file, int *reported);
|
|
|
|
int open_fifo(const char *file, int *reported);
|
2010-08-26 18:03:53 +00:00
|
|
|
std::string variable_substitute(std::string s);
|
2008-12-15 21:40:24 +00:00
|
|
|
|
2018-05-12 23:26:31 +00:00
|
|
|
void format_seconds(char *buf, unsigned int n, long seconds);
|
|
|
|
void format_seconds_short(char *buf, unsigned int n, long seconds);
|
2008-12-15 21:40:24 +00:00
|
|
|
|
2009-05-18 05:30:10 +00:00
|
|
|
int round_to_int_temp(float);
|
|
|
|
|
|
|
|
unsigned int round_to_int(float);
|
2008-12-15 21:40:24 +00:00
|
|
|
|
2010-03-07 12:20:16 +00:00
|
|
|
extern conky::simple_config_setting<bool> no_buffers;
|
2018-08-17 17:46:40 +00:00
|
|
|
extern conky::simple_config_setting<std::string> bar_fill;
|
|
|
|
extern conky::simple_config_setting<std::string> bar_unfill;
|
2018-08-25 16:07:03 +00:00
|
|
|
extern conky::simple_config_setting<std::string> github_token;
|
2008-12-15 21:40:24 +00:00
|
|
|
|
2008-06-14 18:41:12 +00:00
|
|
|
int open_acpi_temperature(const char *name);
|
|
|
|
double get_acpi_temperature(int fd);
|
2018-05-12 16:03:00 +00:00
|
|
|
void get_acpi_ac_adapter(char *p_client_buffer, size_t client_buffer_size,
|
|
|
|
const char *adapter);
|
2008-06-14 18:41:12 +00:00
|
|
|
void get_acpi_fan(char *, size_t);
|
|
|
|
void get_battery_stuff(char *buf, unsigned int n, const char *bat, int item);
|
|
|
|
int get_battery_perct(const char *bat);
|
2009-12-04 00:17:47 +00:00
|
|
|
double get_battery_perct_bar(struct text_object *);
|
2009-02-18 04:49:45 +00:00
|
|
|
void get_battery_short_status(char *buf, unsigned int n, const char *bat);
|
2008-06-14 18:41:12 +00:00
|
|
|
|
2010-04-17 13:19:44 +00:00
|
|
|
void scan_no_update(struct text_object *, const char *);
|
2018-08-07 23:22:23 +00:00
|
|
|
void print_no_update(struct text_object *, char *, unsigned int);
|
2010-04-17 13:19:44 +00:00
|
|
|
void free_no_update(struct text_object *);
|
|
|
|
|
2009-10-25 12:49:10 +00:00
|
|
|
void scan_loadavg_arg(struct text_object *, const char *);
|
2018-08-07 23:22:23 +00:00
|
|
|
void print_loadavg(struct text_object *, char *, unsigned int);
|
2010-01-07 02:38:12 +00:00
|
|
|
#ifdef BUILD_X11
|
2009-10-25 12:49:10 +00:00
|
|
|
void scan_loadgraph_arg(struct text_object *, const char *);
|
2009-12-04 00:49:31 +00:00
|
|
|
double loadgraphval(struct text_object *);
|
2010-01-07 02:38:12 +00:00
|
|
|
#endif /* BUILD_X11 */
|
2009-10-25 12:49:10 +00:00
|
|
|
|
2009-11-25 00:30:21 +00:00
|
|
|
uint8_t cpu_percentage(struct text_object *);
|
2009-12-04 00:19:07 +00:00
|
|
|
double cpu_barval(struct text_object *);
|
2009-11-25 23:09:38 +00:00
|
|
|
|
2018-08-07 23:22:23 +00:00
|
|
|
void print_mem(struct text_object *, char *, unsigned int);
|
|
|
|
void print_memwithbuffers(struct text_object *, char *, unsigned int);
|
|
|
|
void print_memeasyfree(struct text_object *, char *, unsigned int);
|
|
|
|
void print_memfree(struct text_object *, char *, unsigned int);
|
|
|
|
void print_memmax(struct text_object *, char *, unsigned int);
|
|
|
|
void print_memdirty(struct text_object *, char *, unsigned int);
|
|
|
|
void print_swap(struct text_object *, char *, unsigned int);
|
|
|
|
void print_swapfree(struct text_object *, char *, unsigned int);
|
|
|
|
void print_swapmax(struct text_object *, char *, unsigned int);
|
2009-11-25 00:33:13 +00:00
|
|
|
uint8_t mem_percentage(struct text_object *);
|
2009-12-04 00:22:36 +00:00
|
|
|
double mem_barval(struct text_object *);
|
2010-02-18 17:17:27 +00:00
|
|
|
double mem_with_buffers_barval(struct text_object *);
|
2009-11-25 00:34:54 +00:00
|
|
|
uint8_t swap_percentage(struct text_object *);
|
2009-12-04 00:25:41 +00:00
|
|
|
double swap_barval(struct text_object *);
|
2009-11-22 17:02:56 +00:00
|
|
|
|
2018-08-07 23:22:23 +00:00
|
|
|
void print_kernel(struct text_object *, char *, unsigned int);
|
|
|
|
void print_machine(struct text_object *, char *, unsigned int);
|
|
|
|
void print_nodename(struct text_object *, char *, unsigned int);
|
|
|
|
void print_nodename_short(struct text_object *, char *, unsigned int);
|
|
|
|
void print_sysname(struct text_object *, char *, unsigned int);
|
2009-11-25 23:12:44 +00:00
|
|
|
|
2012-06-28 16:56:01 +00:00
|
|
|
#if defined(__DragonFly__)
|
2018-08-07 23:22:23 +00:00
|
|
|
void print_version(struct text_object *obj, char *p, unsigned int p_max_size);
|
2012-06-28 16:56:01 +00:00
|
|
|
#endif
|
|
|
|
|
2018-08-07 23:22:23 +00:00
|
|
|
void print_uptime(struct text_object *, char *, unsigned int);
|
|
|
|
void print_uptime_short(struct text_object *, char *, unsigned int);
|
2009-11-25 23:34:01 +00:00
|
|
|
|
2018-08-07 23:22:23 +00:00
|
|
|
void print_processes(struct text_object *, char *, unsigned int);
|
|
|
|
void print_running_processes(struct text_object *, char *, unsigned int);
|
|
|
|
void print_running_threads(struct text_object *, char *, unsigned int);
|
|
|
|
void print_threads(struct text_object *, char *, unsigned int);
|
2009-11-26 00:06:53 +00:00
|
|
|
|
2018-08-07 23:22:23 +00:00
|
|
|
void print_buffers(struct text_object *, char *, unsigned int);
|
|
|
|
void print_cached(struct text_object *, char *, unsigned int);
|
2009-11-26 00:10:19 +00:00
|
|
|
|
2018-08-07 23:22:23 +00:00
|
|
|
void print_evaluate(struct text_object *, char *, unsigned int);
|
2009-11-26 00:15:33 +00:00
|
|
|
|
2009-11-26 00:30:58 +00:00
|
|
|
int if_empty_iftest(struct text_object *);
|
|
|
|
int if_existing_iftest(struct text_object *);
|
|
|
|
int if_running_iftest(struct text_object *);
|
|
|
|
|
2009-11-26 00:38:53 +00:00
|
|
|
#ifndef __OpenBSD__
|
2018-08-07 23:22:23 +00:00
|
|
|
void print_acpitemp(struct text_object *, char *, unsigned int);
|
2009-11-26 00:38:53 +00:00
|
|
|
void free_acpitemp(struct text_object *);
|
|
|
|
#endif /* !__OpenBSD__ */
|
|
|
|
|
2018-08-07 23:22:23 +00:00
|
|
|
void print_freq(struct text_object *, char *, unsigned int);
|
|
|
|
void print_freq_g(struct text_object *, char *, unsigned int);
|
2009-11-26 00:42:54 +00:00
|
|
|
|
2009-11-26 00:51:41 +00:00
|
|
|
#ifndef __OpenBSD__
|
2018-08-07 23:22:23 +00:00
|
|
|
void print_acpifan(struct text_object *, char *, unsigned int);
|
|
|
|
void print_acpiacadapter(struct text_object *, char *, unsigned int);
|
|
|
|
void print_battery(struct text_object *, char *, unsigned int);
|
|
|
|
void print_battery_time(struct text_object *, char *, unsigned int);
|
2009-11-26 00:51:41 +00:00
|
|
|
uint8_t battery_percentage(struct text_object *);
|
2018-08-07 23:22:23 +00:00
|
|
|
void print_battery_short(struct text_object *, char *, unsigned int);
|
2018-08-19 18:04:28 +00:00
|
|
|
void print_battery_status(struct text_object *, char *, unsigned int);
|
2009-11-26 00:51:41 +00:00
|
|
|
#endif /* !__OpenBSD__ */
|
|
|
|
|
2018-08-07 15:54:01 +00:00
|
|
|
void free_cpu(struct text_object *);
|
|
|
|
|
2018-08-07 23:22:23 +00:00
|
|
|
void print_blink(struct text_object *, char *, unsigned int);
|
|
|
|
void print_include(struct text_object *, char *, unsigned int);
|
2009-11-29 11:47:11 +00:00
|
|
|
|
2018-08-07 23:22:23 +00:00
|
|
|
void print_updates(struct text_object *, char *, unsigned int);
|
2009-11-29 18:50:59 +00:00
|
|
|
int updatenr_iftest(struct text_object *);
|
2009-11-29 18:48:24 +00:00
|
|
|
|
2010-04-19 12:54:03 +00:00
|
|
|
#ifdef BUILD_CURL
|
2018-08-25 16:07:03 +00:00
|
|
|
void print_github(struct text_object *, char *, unsigned int);
|
2018-08-07 23:22:23 +00:00
|
|
|
void print_stock(struct text_object *, char *, unsigned int);
|
2010-04-19 12:45:05 +00:00
|
|
|
void free_stock(struct text_object *);
|
2010-04-19 12:54:03 +00:00
|
|
|
#endif /* BUILD_CURL */
|
2008-12-15 21:40:24 +00:00
|
|
|
#endif /* _COMMON_H */
|