mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-01-26 16:48:28 +00:00
Preliminary import from 2.8.1 git release
* don't use kvm_* calls, just sysctl (so no suid perm necessary) * sysctls calls in general aren't thread safe, collapse callbacks using same sysctls (specifically total/running procs and proc list ones). Some sysctls need two calls (first to get size of obj returned, second to get object self); if different threads use this schema on same sysctl, weird values are returned (first/second calls sequence should be serialized). In general it makes not much sense too having more threads that use the same sysctl; just get info once and populate all data. * add DragonFly specific extended uname string ($version in conky.conf) with git version and signature Todo: - top process list logic is old style, use top.cc funcs. - find a solution for cpu freq Signed-off-by: Pavel Labath <pavelo@centrum.sk>
This commit is contained in:
parent
4c1ec83174
commit
98196d0e6b
@ -38,6 +38,10 @@ if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||
set(OS_FREEBSD true)
|
||||
endif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "DragonFly")
|
||||
set(OS_DRAGONFLY true)
|
||||
endif(CMAKE_SYSTEM_NAME MATCHES "DragonFly")
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
|
||||
set(OS_OPENBSD true)
|
||||
endif(CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
|
||||
@ -50,9 +54,9 @@ if(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
|
||||
set(OS_NETBSD true)
|
||||
endif(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
|
||||
|
||||
if(NOT OS_LINUX AND NOT OS_FREEBSD AND NOT OS_OPENBSD)
|
||||
if(NOT OS_LINUX AND NOT OS_FREEBSD AND NOT OS_OPENBSD AND NOT OS_DRAGONFLY)
|
||||
message(FATAL_ERROR "Your platform, '${CMAKE_SYSTEM_NAME}', is not currently supported. Patches are welcome.")
|
||||
endif(NOT OS_LINUX AND NOT OS_FREEBSD AND NOT OS_OPENBSD)
|
||||
endif(NOT OS_LINUX AND NOT OS_FREEBSD AND NOT OS_OPENBSD AND NOT OS_DRAGONFLY)
|
||||
|
||||
include(FindThreads)
|
||||
find_package(Threads)
|
||||
|
@ -131,7 +131,7 @@ option(BUILD_BMPX "Build BMPx (music player) support" false)
|
||||
|
||||
option(BUILD_MPD "Enable if you want MPD (music player) support" true)
|
||||
|
||||
option(BUILD_MYSQL "Enable if you want MySQL support" true)
|
||||
option(BUILD_MYSQL "Enable if you want MySQL support" false)
|
||||
|
||||
option(BUILD_MOC "Enable if you want MOC (music player) support" true)
|
||||
|
||||
|
@ -56,6 +56,11 @@ if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||
set(conky_libs ${conky_libs} -lkvm -ldevstat)
|
||||
endif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "DragonFly")
|
||||
set(OS_DRAGONFLY true)
|
||||
set(conky_libs ${conky_libs} -ldevstat)
|
||||
endif(CMAKE_SYSTEM_NAME MATCHES "DragonFly")
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
|
||||
set(OS_OPENBSD true)
|
||||
endif(CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
|
||||
@ -68,9 +73,13 @@ if(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
|
||||
set(OS_NETBSD true)
|
||||
endif(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
|
||||
|
||||
if(NOT OS_LINUX AND NOT OS_FREEBSD AND NOT OS_OPENBSD)
|
||||
if(NOT OS_LINUX AND NOT OS_FREEBSD AND NOT OS_OPENBSD AND NOT OS_DRAGONFLY)
|
||||
message(FATAL_ERROR "Your platform, '${CMAKE_SYSTEM_NAME}', is not currently supported. Patches are welcome.")
|
||||
endif(NOT OS_LINUX AND NOT OS_FREEBSD AND NOT OS_OPENBSD)
|
||||
endif(NOT OS_LINUX AND NOT OS_FREEBSD AND NOT OS_OPENBSD AND NOT OS_DRAGONFLY)
|
||||
|
||||
if(BUILD_I18N AND OS_DRAGONFLY)
|
||||
set(conky_libs ${conky_libs} -lintl)
|
||||
endif(BUILD_I18N AND OS_DRAGONFLY)
|
||||
|
||||
if(BUILD_MATH)
|
||||
set(conky_libs ${conky_libs} -lm)
|
||||
@ -197,7 +206,8 @@ if(BUILD_X11)
|
||||
if(BUILD_XFT)
|
||||
find_path(freetype_INCLUDE_PATH freetype/config/ftconfig.h ${INCLUDE_SEARCH_PATH}
|
||||
/usr/include/freetype2
|
||||
/usr/local/include/freetype2)
|
||||
/usr/local/include/freetype2
|
||||
/usr/pkg/include/freetype2)
|
||||
if(freetype_INCLUDE_PATH)
|
||||
set(freetype_FOUND true)
|
||||
set(conky_includes ${conky_includes} ${freetype_INCLUDE_PATH})
|
||||
|
@ -54,6 +54,11 @@ if(OS_FREEBSD)
|
||||
set(optional_sources ${optional_sources} ${freebsd})
|
||||
endif(OS_FREEBSD)
|
||||
|
||||
if(OS_DRAGONFLY)
|
||||
set(dragonfly dragonfly.cc bsdapm.cc)
|
||||
set(optional_sources ${optional_sources} ${dragonfly})
|
||||
endif(OS_DRAGONFLY)
|
||||
|
||||
if(OS_OPENBSD)
|
||||
set(openbsd openbsd.cc bsdapm.cc)
|
||||
set(optional_sources ${optional_sources} ${openbsd})
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <net/if.h>
|
||||
#include <netinet/in.h>
|
||||
#include <pthread.h>
|
||||
@ -55,6 +56,8 @@
|
||||
#include "linux.h"
|
||||
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
#include "freebsd.h"
|
||||
#elif defined(__DragonFly__)
|
||||
#include "dragonfly.h"
|
||||
#elif defined(__OpenBSD__)
|
||||
#include "openbsd.h"
|
||||
#endif
|
||||
@ -96,6 +99,24 @@ char *strndup(const char *s, size_t n)
|
||||
int update_uname(void)
|
||||
{
|
||||
uname(&info.uname_s);
|
||||
|
||||
#if defined(__DragonFly__)
|
||||
{
|
||||
size_t desc_n; char desc[256];
|
||||
|
||||
if (sysctlbyname("kern.version", NULL, &desc_n, NULL, 0) == -1 ||
|
||||
sysctlbyname("kern.version", desc, &desc_n, NULL, 0) == -1)
|
||||
perror("kern.version");
|
||||
else {
|
||||
char *start = desc;
|
||||
strsep(&start, " ");
|
||||
strcpy(info.uname_v, strsep(&start, " "));
|
||||
}
|
||||
|
||||
if (errno == ENOMEM) printf("desc_n %d\n", desc_n);
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -475,6 +496,14 @@ void print_sysname(struct text_object *obj, char *p, int p_max_size)
|
||||
snprintf(p, p_max_size, "%s", info.uname_s.sysname);
|
||||
}
|
||||
|
||||
#if defined(__DragonFly__)
|
||||
void print_version(struct text_object *obj, char *p, int p_max_size)
|
||||
{
|
||||
(void)obj;
|
||||
snprintf(p, p_max_size, "%s", info.uname_v);
|
||||
}
|
||||
#endif
|
||||
|
||||
void print_uptime(struct text_object *obj, char *p, int p_max_size)
|
||||
{
|
||||
(void)obj;
|
||||
|
@ -119,6 +119,11 @@ void print_nodename(struct text_object *, char *, int);
|
||||
void print_nodename_short(struct text_object *, char *, int);
|
||||
void print_sysname(struct text_object *, char *, int);
|
||||
|
||||
#if defined(__DragonFly__)
|
||||
void print_version(struct text_object *obj, char *p, int p_max_size);
|
||||
#endif
|
||||
|
||||
|
||||
void print_uptime(struct text_object *, char *, int);
|
||||
void print_uptime_short(struct text_object *, char *, int);
|
||||
|
||||
|
@ -116,6 +116,8 @@
|
||||
#include "linux.h"
|
||||
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
#include "freebsd.h"
|
||||
#elif defined(__DragonFly__)
|
||||
#include "dragonfly.h"
|
||||
#elif defined(__OpenBSD__)
|
||||
#include "openbsd.h"
|
||||
#endif
|
||||
@ -2778,7 +2780,7 @@ static void print_help(const char *prog_name) {
|
||||
|
||||
inline void reset_optind() {
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) \
|
||||
|| defined(__NetBSD__)
|
||||
|| defined(__NetBSD__) || defined(__DragonFly__)
|
||||
optind = optreset = 1;
|
||||
#else
|
||||
optind = 0;
|
||||
|
@ -173,6 +173,9 @@ struct information {
|
||||
unsigned int mask;
|
||||
|
||||
struct utsname uname_s;
|
||||
#if defined(__DragonFly__)
|
||||
char uname_v[256]; /* with git version */
|
||||
#endif
|
||||
|
||||
char freq[10];
|
||||
|
||||
|
24
src/core.cc
24
src/core.cc
@ -105,6 +105,8 @@
|
||||
#include "linux.h"
|
||||
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
#include "freebsd.h"
|
||||
#elif defined(__DragonFly__)
|
||||
#include "dragonfly.h"
|
||||
#elif defined(__OpenBSD__)
|
||||
#include "openbsd.h"
|
||||
#endif
|
||||
@ -534,7 +536,7 @@ struct text_object *construct_text_object(char *s, const char *arg,
|
||||
}
|
||||
obj->callbacks.print = get_powerbook_batt_info;
|
||||
#endif /* __linux__ */
|
||||
#if (defined(__FreeBSD__) || defined(__linux__))
|
||||
#if (defined(__FreeBSD__) || defined(__linux__) || defined(__DragonFly__))
|
||||
END OBJ_IF_ARG(if_up, 0, "if_up needs an argument")
|
||||
parse_if_up_arg(obj, arg);
|
||||
obj->callbacks.iftest = &interface_up;
|
||||
@ -921,11 +923,11 @@ struct text_object *construct_text_object(char *s, const char *arg,
|
||||
obj->data.s = strndup(arg, text_buffer_size.get(*state));
|
||||
obj->callbacks.iftest = &if_existing_iftest;
|
||||
obj->callbacks.free = &gen_free_opaque;
|
||||
#ifdef __linux__
|
||||
END OBJ_IF_ARG(if_mounted, 0, "if_mounted needs an argument")
|
||||
obj->data.s = strndup(arg, text_buffer_size.get(*state));
|
||||
obj->callbacks.iftest = &check_mount;
|
||||
obj->callbacks.free = &gen_free_opaque;
|
||||
#ifdef __linux__
|
||||
END OBJ_IF_ARG(if_running, &update_top, "if_running needs an argument")
|
||||
top_running = 1;
|
||||
obj->data.s = strndup(arg, text_buffer_size.get(*state));
|
||||
@ -944,6 +946,10 @@ struct text_object *construct_text_object(char *s, const char *arg,
|
||||
obj->callbacks.print = &print_kernel;
|
||||
END OBJ(machine, 0)
|
||||
obj->callbacks.print = &print_machine;
|
||||
#if defined(__DragonFly__)
|
||||
END OBJ(version, 0)
|
||||
obj->callbacks.print = &print_version;
|
||||
#endif
|
||||
END OBJ(mails, 0)
|
||||
parse_local_mail_args(obj, arg);
|
||||
obj->callbacks.print = &print_mails;
|
||||
@ -1202,7 +1208,11 @@ struct text_object *construct_text_object(char *s, const char *arg,
|
||||
END OBJ_ARG(pid_write, 0, "pid_write needs a pid as argument")
|
||||
extract_object_args_to_sub(obj, arg);
|
||||
obj->callbacks.print = &print_pid_write;
|
||||
#ifdef __DragonFly__
|
||||
END OBJ(processes, &update_tmp_top)
|
||||
#else
|
||||
END OBJ(processes, &update_total_processes)
|
||||
#endif
|
||||
obj->callbacks.print = &print_processes;
|
||||
#ifdef __linux__
|
||||
END OBJ(distribution, 0)
|
||||
@ -1214,9 +1224,14 @@ struct text_object *construct_text_object(char *s, const char *arg,
|
||||
obj->callbacks.print = &print_threads;
|
||||
END OBJ(running_threads, &update_stat)
|
||||
obj->callbacks.print = &print_running_threads;
|
||||
#else
|
||||
#if defined(__DragonFly__)
|
||||
END OBJ(running_processes, &update_tmp_top)
|
||||
obj->callbacks.print = &print_running_processes;
|
||||
#else
|
||||
END OBJ(running_processes, &update_running_processes)
|
||||
obj->callbacks.print = &print_running_processes;
|
||||
obj->callbacks.print = &print_running_processes;
|
||||
#endif
|
||||
#endif /* __linux__ */
|
||||
END OBJ(shadecolor, 0)
|
||||
#ifdef BUILD_X11
|
||||
@ -1338,7 +1353,8 @@ struct text_object *construct_text_object(char *s, const char *arg,
|
||||
obj->callbacks.free = &free_gateway_info;
|
||||
#endif /* !__linux__ */
|
||||
#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \
|
||||
|| defined(__OpenBSD__)) && (defined(i386) || defined(__i386__))
|
||||
|| defined(__DragonFly__) \
|
||||
|| defined(__OpenBSD__)) && (defined(i386) || defined(__i386__))
|
||||
END OBJ(apm_adapter, 0)
|
||||
obj->callbacks.print = &print_apm_adapter;
|
||||
END OBJ(apm_battery_life, 0)
|
||||
|
@ -64,7 +64,7 @@ struct diskio_stat *prepare_diskio_stat(const char *s)
|
||||
if (!s)
|
||||
return &stats;
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
if (strncmp(s, "/dev/", 5) == 0) {
|
||||
// supplied a /dev/device arg, so cut off the /dev part
|
||||
strncpy(&(device_name[0]), s + 5, text_buffer_size.get(*state));
|
||||
|
@ -37,6 +37,8 @@
|
||||
#include "linux.h"
|
||||
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
#include "freebsd.h"
|
||||
#elif defined(__DragonFly__)
|
||||
#include "dragonfly.h"
|
||||
#elif defined(__OpenBSD__)
|
||||
#include "openbsd.h"
|
||||
#endif
|
||||
|
@ -53,10 +53,13 @@
|
||||
#endif
|
||||
#if defined(__FreeBSD__)
|
||||
#include "freebsd.h"
|
||||
#elif defined(__DragonFly__)
|
||||
#include "dragonfly.h"
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(HAVE_STRUCT_STATFS_F_FSTYPENAME) && !defined (__OpenBSD__) && !defined(__FreeBSD__)
|
||||
#if !defined(HAVE_STRUCT_STATFS_F_FSTYPENAME) && \
|
||||
!defined (__OpenBSD__) && !defined(__FreeBSD__) && !defined(__DragonFly__)
|
||||
#include <mntent.h>
|
||||
#endif
|
||||
|
||||
@ -142,7 +145,8 @@ static void update_fs_stat(struct fs_stat *fs)
|
||||
void get_fs_type(const char *path, char *result)
|
||||
{
|
||||
|
||||
#if defined(HAVE_STRUCT_STATFS_F_FSTYPENAME) || defined(__FreeBSD__) || defined (__OpenBSD__)
|
||||
#if defined(HAVE_STRUCT_STATFS_F_FSTYPENAME) || \
|
||||
defined(__FreeBSD__) || defined (__OpenBSD__) || defined(__DragonFly__)
|
||||
|
||||
struct statfs64 s;
|
||||
if (statfs64(path, &s) == 0) {
|
||||
|
@ -81,7 +81,7 @@ void iconv_convert(size_t *a, char *buff_in, char *p, size_t p_max_size)
|
||||
{
|
||||
int bytes;
|
||||
size_t dummy1, dummy2;
|
||||
#ifdef __FreeBSD__
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
const char *ptr = buff_in;
|
||||
#else
|
||||
char *ptr = buff_in;
|
||||
|
Loading…
x
Reference in New Issue
Block a user