diff --git a/cmake/Conky.cmake b/cmake/Conky.cmake index 6b528fc1..c1a169dd 100644 --- a/cmake/Conky.cmake +++ b/cmake/Conky.cmake @@ -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) diff --git a/cmake/ConkyBuildOptions.cmake b/cmake/ConkyBuildOptions.cmake index 2e5141fd..a7e512a4 100644 --- a/cmake/ConkyBuildOptions.cmake +++ b/cmake/ConkyBuildOptions.cmake @@ -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) diff --git a/cmake/ConkyPlatformChecks.cmake b/cmake/ConkyPlatformChecks.cmake index 5dd220e4..54b00f93 100644 --- a/cmake/ConkyPlatformChecks.cmake +++ b/cmake/ConkyPlatformChecks.cmake @@ -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}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c29cb079..ac9a33db 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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}) diff --git a/src/common.cc b/src/common.cc index 807408ac..36ea4a10 100644 --- a/src/common.cc +++ b/src/common.cc @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -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; diff --git a/src/common.h b/src/common.h index e4d0ee1d..217100f2 100644 --- a/src/common.h +++ b/src/common.h @@ -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); diff --git a/src/conky.cc b/src/conky.cc index c3f607ea..1240c761 100644 --- a/src/conky.cc +++ b/src/conky.cc @@ -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; diff --git a/src/conky.h b/src/conky.h index c8457e13..447e2c6f 100644 --- a/src/conky.h +++ b/src/conky.h @@ -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]; diff --git a/src/core.cc b/src/core.cc index 210c0a35..7c2b881e 100644 --- a/src/core.cc +++ b/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) diff --git a/src/diskio.cc b/src/diskio.cc index 4c81d1c0..c0899f74 100644 --- a/src/diskio.cc +++ b/src/diskio.cc @@ -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)); diff --git a/src/entropy.cc b/src/entropy.cc index 1fd68e62..0d429cd5 100644 --- a/src/entropy.cc +++ b/src/entropy.cc @@ -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 diff --git a/src/fs.cc b/src/fs.cc index 7f4c1b27..8c47743e 100644 --- a/src/fs.cc +++ b/src/fs.cc @@ -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 #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) { diff --git a/src/iconv_tools.cc b/src/iconv_tools.cc index 8253d8df..b61c0ea4 100644 --- a/src/iconv_tools.cc +++ b/src/iconv_tools.cc @@ -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;