From: Scott Tincman Date: Wed, 14 Nov 2012 01:29:55 +0000 (-0500) Subject: DragonFlyBSD support added X-Git-Tag: 2.7~19 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=0eeded8bc013857a5e8a2efbc20002a22502897e;p=i3%2Fi3status DragonFlyBSD support added --- diff --git a/Makefile b/Makefile index af56a19..eb7da6e 100644 --- a/Makefile +++ b/Makefile @@ -39,6 +39,13 @@ LDFLAGS+=-L/usr/local/lib/ LIBS+=-lossaudio endif +# This probably applies for any pkgsrc based system +ifeq ($(shell uname),DragonFly) +CFLAGS+=-I/usr/pkg/include/ +LDFLAGS+=-L/usr/pkg/lib/ +endif + + CFLAGS+=$(EXTRA_CFLAGS) # Fallback for libyajl 1 which did not include yajl_version.h. We need diff --git a/include/i3status.h b/include/i3status.h index 559df9e..09394bd 100644 --- a/include/i3status.h +++ b/include/i3status.h @@ -18,10 +18,14 @@ enum { O_DZEN2, O_XMOBAR, O_I3BAR, O_NONE } output_format; #define THERMAL_ZONE "/sys/class/thermal/thermal_zone%d/temp" -#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) /* this needs the coretemp module to be loaded */ +#if defined(__DragonFly__) +#define THERMAL_ZONE "hw.sensors.cpu%d.temp0" +#else #define THERMAL_ZONE "dev.cpu.%d.temperature" +#endif #define BATT_LIFE "hw.acpi.battery.life" #define BATT_TIME "hw.acpi.battery.time" #define BATT_STATE "hw.acpi.battery.state" diff --git a/src/print_battery_info.c b/src/print_battery_info.c index ae11348..1545609 100644 --- a/src/print_battery_info.c +++ b/src/print_battery_info.c @@ -9,7 +9,7 @@ #include "i3status.h" -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) #include #include #endif @@ -186,7 +186,7 @@ void print_battery_info(yajl_gen json_gen, char *buffer, int number, const char } } } -#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) int state; int sysctl_rslt; size_t sysctl_size = sizeof(sysctl_rslt); diff --git a/src/print_cpu_temperature.c b/src/print_cpu_temperature.c index e3340f6..96fa4b7 100644 --- a/src/print_cpu_temperature.c +++ b/src/print_cpu_temperature.c @@ -8,7 +8,7 @@ #include "i3status.h" -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) #include #include #include @@ -72,7 +72,7 @@ void print_cpu_temperature_info(yajl_gen json_gen, char *buffer, int zone, const if (colorful_output) END_COLOR; } -#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) int sysctl_rslt; size_t sysctl_size = sizeof(sysctl_rslt); if (sysctlbyname(path, &sysctl_rslt, &sysctl_size, NULL, 0)) diff --git a/src/print_cpu_usage.c b/src/print_cpu_usage.c index ed17db3..ecc81a2 100644 --- a/src/print_cpu_usage.c +++ b/src/print_cpu_usage.c @@ -13,6 +13,13 @@ #include #endif +#if defined(__DragonFly__) +#include +#include +#include +#include +#endif + #include "i3status.h" static int prev_total = 0; @@ -43,9 +50,9 @@ void print_cpu_usage(yajl_gen json_gen, char *buffer, const char *format) { diff_usage = (diff_total ? (1000 * (diff_total - diff_idle)/diff_total + 5)/10 : 0); prev_total = curr_total; prev_idle = curr_idle; -#elif defined(__FreeBSD__) || defined(__OpenBSD__) +#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || defined(__DragonFly__) size_t size; long cp_time[CPUSTATES]; size = sizeof cp_time; diff --git a/src/print_disk_info.c b/src/print_disk_info.c index b577d23..f49fe66 100644 --- a/src/print_disk_info.c +++ b/src/print_disk_info.c @@ -6,7 +6,7 @@ #include #include #include -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || (__OpenBSD__) +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || (__OpenBSD__) || defined(__DragonFly__) #include #include #endif @@ -49,7 +49,7 @@ void print_disk_info(yajl_gen json_gen, char *buffer, const char *path, const ch INSTANCE(path); -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) || defined(__DragonFly__) struct statfs buf; if (statfs(path, &buf) == -1) diff --git a/src/print_eth_info.c b/src/print_eth_info.c index d09873e..8af0dec 100644 --- a/src/print_eth_info.c +++ b/src/print_eth_info.c @@ -19,7 +19,7 @@ #define PART_ETHSPEED "E: %s (%d Mbit/s)" #endif -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) #include #define IFM_TYPE_MATCH(dt, t) \ (IFM_TYPE((dt)) == 0 || IFM_TYPE((dt)) == IFM_TYPE((t))) @@ -47,7 +47,7 @@ static int print_eth_speed(char *outwalk, const char *interface) { ethspeed = (ecmd.speed == USHRT_MAX ? 0 : ecmd.speed); return sprintf(outwalk, "%d Mbit/s", ethspeed); } else return sprintf(outwalk, "?"); -#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) char *ethspeed; struct ifmediareq ifm; (void)memset(&ifm, 0, sizeof(ifm)); diff --git a/src/print_load.c b/src/print_load.c index 7fd54ca..5281472 100644 --- a/src/print_load.c +++ b/src/print_load.c @@ -10,7 +10,7 @@ void print_load(yajl_gen json_gen, char *buffer, const char *format) { char *outwalk = buffer; /* Get load */ -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(linux) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__) || defined(sun) +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(linux) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__) || defined(sun) || defined(__DragonFly__) double loadavg[3]; const char *walk; diff --git a/src/print_volume.c b/src/print_volume.c index 9c69d08..080dea2 100644 --- a/src/print_volume.c +++ b/src/print_volume.c @@ -11,7 +11,7 @@ #include #endif -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__DragonFly__) #include #include #include @@ -174,7 +174,7 @@ void print_volume(yajl_gen json_gen, char *buffer, const char *fmt, const char * } } #endif -#if defined(__FreeBSD__) || defined(__OpenBSD__) +#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) char mixerpath[] = "/dev/mixer"; int mixfd, vol, devmask = 0; diff --git a/src/print_wireless_info.c b/src/print_wireless_info.c index 1eddd96..9ab9c2f 100644 --- a/src/print_wireless_info.c +++ b/src/print_wireless_info.c @@ -25,6 +25,19 @@ #define IW_ESSID_MAX_SIZE IEEE80211_NWID_LEN #endif +#ifdef __DragonFly__ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#define IW_ESSID_MAX_SIZE IEEE80211_NWID_LEN +#endif + #ifdef __OpenBSD__ #include #include @@ -170,7 +183,7 @@ static int get_wireless_info(const char *interface, wireless_info_t *info) { close(skfd); return 1; #endif -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__DragonFly__) int s, len, inwid; uint8_t buf[24 * 1024], *cp; struct ieee80211req na;