Support for (Debian) GNU/kFreeBSD
This commit is contained in:
parent
39b153fdd1
commit
e565e313f7
4
Makefile
4
Makefile
@ -12,6 +12,10 @@ CFLAGS+=-DLINUX
|
|||||||
CFLAGS+=-D_GNU_SOURCE
|
CFLAGS+=-D_GNU_SOURCE
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(shell uname),GNU/kFreeBSD)
|
||||||
|
CFLAGS+=-lbsd
|
||||||
|
endif
|
||||||
|
|
||||||
# Define this if you want i3status to spit out dzen2-compatible output on stdout
|
# Define this if you want i3status to spit out dzen2-compatible output on stdout
|
||||||
#CFLAGS+=-DDZEN
|
#CFLAGS+=-DDZEN
|
||||||
CFLAGS+=$(EXTRA_CFLAGS)
|
CFLAGS+=$(EXTRA_CFLAGS)
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
#define THERMAL_ZONE "/sys/class/thermal/thermal_zone%d/temp"
|
#define THERMAL_ZONE "/sys/class/thermal/thermal_zone%d/temp"
|
||||||
|
|
||||||
#elif defined(__FreeBSD__)
|
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||||
|
|
||||||
#define THERMAL_ZONE "hw.acpi.thermal.tz%d.temperature"
|
#define THERMAL_ZONE "hw.acpi.thermal.tz%d.temperature"
|
||||||
#define BATT_LIFE "hw.acpi.battery.life"
|
#define BATT_LIFE "hw.acpi.battery.life"
|
||||||
@ -37,6 +37,13 @@
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__FreeBSD_kernel__) && defined(__GLIBC__)
|
||||||
|
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef enum { CS_DISCHARGING, CS_CHARGING, CS_FULL } charging_status_t;
|
typedef enum { CS_DISCHARGING, CS_CHARGING, CS_FULL } charging_status_t;
|
||||||
enum { ORDER_RUN, ORDER_WLAN, ORDER_ETH, ORDER_BATTERY, ORDER_CPU_TEMPERATURE, ORDER_LOAD, ORDER_TIME, ORDER_IPV6, MAX_ORDER };
|
enum { ORDER_RUN, ORDER_WLAN, ORDER_ETH, ORDER_BATTERY, ORDER_CPU_TEMPERATURE, ORDER_LOAD, ORDER_TIME, ORDER_IPV6, MAX_ORDER };
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include "i3status.h"
|
#include "i3status.h"
|
||||||
|
|
||||||
#if defined(__FreeBSD__)
|
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#endif
|
#endif
|
||||||
@ -92,7 +92,7 @@ const char *get_battery_info(struct battery *bat) {
|
|||||||
(status == CS_DISCHARGING ? "BAT" : "FULL")),
|
(status == CS_DISCHARGING ? "BAT" : "FULL")),
|
||||||
(((float)remaining / (float)full_design) * 100));
|
(((float)remaining / (float)full_design) * 100));
|
||||||
}
|
}
|
||||||
#elif defined(__FreeBSD__)
|
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||||
int state;
|
int state;
|
||||||
int sysctl_rslt;
|
int sysctl_rslt;
|
||||||
size_t sysctl_size = sizeof(sysctl_rslt);
|
size_t sysctl_size = sizeof(sysctl_rslt);
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include "i3status.h"
|
#include "i3status.h"
|
||||||
|
|
||||||
#if defined(__FreeBSD__)
|
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
@ -31,7 +31,7 @@ const char *get_cpu_temperature_info() {
|
|||||||
(void)snprintf(buf, sizeof(buf), "T: ? C");
|
(void)snprintf(buf, sizeof(buf), "T: ? C");
|
||||||
else
|
else
|
||||||
(void)snprintf(buf, sizeof(buf), "T: %ld C", (temp/1000));
|
(void)snprintf(buf, sizeof(buf), "T: %ld C", (temp/1000));
|
||||||
#elif defined(__FreeBSD__)
|
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||||
int sysctl_rslt;
|
int sysctl_rslt;
|
||||||
size_t sysctl_size = sizeof (sysctl_rslt);
|
size_t sysctl_size = sizeof (sysctl_rslt);
|
||||||
if (sysctlbyname(thermal_zone,&sysctl_rslt,&sysctl_size,NULL,0))
|
if (sysctlbyname(thermal_zone,&sysctl_rslt,&sysctl_size,NULL,0))
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
#define PART_ETHSPEED "E: %s (%d Mbit/s)"
|
#define PART_ETHSPEED "E: %s (%d Mbit/s)"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__FreeBSD__)
|
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||||
#include <net/if_media.h>
|
#include <net/if_media.h>
|
||||||
#define IFM_TYPE_MATCH(dt, t) \
|
#define IFM_TYPE_MATCH(dt, t) \
|
||||||
(IFM_TYPE((dt)) == 0 || IFM_TYPE((dt)) == IFM_TYPE((t)))
|
(IFM_TYPE((dt)) == 0 || IFM_TYPE((dt)) == IFM_TYPE((t)))
|
||||||
@ -34,7 +34,7 @@ const char *get_eth_info() {
|
|||||||
static char part[512];
|
static char part[512];
|
||||||
#if defined(LINUX)
|
#if defined(LINUX)
|
||||||
int ethspeed=0;
|
int ethspeed=0;
|
||||||
#elif defined(__FreeBSD__)
|
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||||
char *ethspeed;
|
char *ethspeed;
|
||||||
#endif
|
#endif
|
||||||
const char *ip_address = get_ip_addr(eth_interface);
|
const char *ip_address = get_ip_addr(eth_interface);
|
||||||
@ -57,7 +57,7 @@ const char *get_eth_info() {
|
|||||||
if (ioctl(general_socket, SIOCETHTOOL, &ifr) == 0)
|
if (ioctl(general_socket, SIOCETHTOOL, &ifr) == 0)
|
||||||
ethspeed = (ecmd.speed == USHRT_MAX ? 0 : ecmd.speed);
|
ethspeed = (ecmd.speed == USHRT_MAX ? 0 : ecmd.speed);
|
||||||
else get_ethspeed = false;
|
else get_ethspeed = false;
|
||||||
#elif defined(__FreeBSD__)
|
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||||
struct ifmediareq ifm;
|
struct ifmediareq ifm;
|
||||||
(void)memset(&ifm, 0, sizeof(ifm));
|
(void)memset(&ifm, 0, sizeof(ifm));
|
||||||
(void)strncpy(ifm.ifm_name, eth_interface, sizeof(ifm.ifm_name));
|
(void)strncpy(ifm.ifm_name, eth_interface, sizeof(ifm.ifm_name));
|
||||||
|
@ -9,7 +9,7 @@ const char *get_load() {
|
|||||||
static char part[512];
|
static char part[512];
|
||||||
|
|
||||||
/* Get load */
|
/* Get load */
|
||||||
#if defined(__FreeBSD__) || 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)
|
||||||
double loadavg[3];
|
double loadavg[3];
|
||||||
if (getloadavg(loadavg, 3) == -1)
|
if (getloadavg(loadavg, 3) == -1)
|
||||||
errx(-1, "getloadavg() failed\n");
|
errx(-1, "getloadavg() failed\n");
|
||||||
|
@ -39,7 +39,7 @@ bool process_runs(const char *path) {
|
|||||||
(void)read(fd, pidbuf, sizeof(pidbuf));
|
(void)read(fd, pidbuf, sizeof(pidbuf));
|
||||||
(void)close(fd);
|
(void)close(fd);
|
||||||
|
|
||||||
#ifdef LINUX
|
#if defined(LINUX) || defined(__GNU__) || defined(__GLIBC__)
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
char procbuf[512];
|
char procbuf[512];
|
||||||
(void)snprintf(procbuf, sizeof(procbuf), "/proc/%ld", strtol(pidbuf, NULL, 10));
|
(void)snprintf(procbuf, sizeof(procbuf), "/proc/%ld", strtol(pidbuf, NULL, 10));
|
||||||
|
Loading…
Reference in New Issue
Block a user