]> git.sur5r.net Git - i3/i3status/commitdiff
Merge pull request #270 from Stunkymonkey/mem-support
authorIngo Bürk <admin@airblader.de>
Sat, 19 May 2018 20:08:42 +0000 (22:08 +0200)
committerGitHub <noreply@github.com>
Sat, 19 May 2018 20:08:42 +0000 (22:08 +0200)
initial support of memory-usage for linux

CHANGELOG
I3STATUS_VERSION
man/asciidoc.conf
man/i3status.man
src/first_network_device.c
src/print_cpu_temperature.c
src/print_ip_addr.c
src/print_wireless_info.c

index 6811cd01da389e5c0b4512945a9b700863f551b3..09e28839208361bc921cc7b1bdd9158546ae725e 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,30 @@
+2018-05-11 i3status 2.12
+
+ • fix NULL value on OpenBSD when there is no acpitz0
+ • show IP address when address has a label
+ • man: explicitly use format_up/format_down in ethernet, wireless conf
+ • man: remove SLOC comment
+ • treat zero battery capacity as "not available"
+ • add IPv6 address when IPv4 isn't available
+ • call tzset at each time print to pick up time zone changes
+ • doc: fixed minor typos
+ • be more cautious about handling invalid battery measurements.
+ • Makefile: make PKG_CONFIG overridable
+ • fix CPU unit tests
+ • use local timezone for battery %emptytime
+ • fix memory leak/use BEGINS_WITH macro
+ • _first_: add check for virtual ethernet devices
+ • add battery capacity parsing
+ • multiple CPU support for cpu_usage
+ • remove useless checks (we use char, not unsigned char) to fix compilation warnings
+ • disk: sanitize trailing slashes
+ • plug an fd leak in the OpenBSD-specific code for
+ • suppress printing :00 seconds of remaining battery lifetime, as apm(4)'s
+   estimate only has a granularity of minutes.
+ • fix the deciKelvin to Celsius conversion on FreeBSD
+ • make first_eth_interface() work on OpenBSD
+ • include sys/select.h on OpenBSD
+
 2017-01-21 i3status 2.11
 
  • re-add forgotten wakeup call from SIGUSR1 handler
index 0b08ad71ce33dce1fcb399fc5a24960fe15f11e4..19462c20006a4e314a4e0a03ff74f5aab329a1b3 100644 (file)
@@ -1 +1 @@
-2.11-non-git
+2.12-non-git
index 49935791d0a24e2b498d02b8f87115997ad20c91..459c63951751b802374dc4f3c55a84a0e562d94c 100644 (file)
@@ -7,7 +7,7 @@ template::[header-declarations]
 <refentrytitle>{mantitle}</refentrytitle>
 <manvolnum>{manvolnum}</manvolnum>
 <refmiscinfo class="source">i3status</refmiscinfo>
-<refmiscinfo class="version">v2.11</refmiscinfo>
+<refmiscinfo class="version">v2.12</refmiscinfo>
 <refmiscinfo class="manual">i3 Manual</refmiscinfo>
 </refmeta>
 <refnamediv>
index f8ce219fba6fd6fd4934debfa90fdfec93f39bd3..1d679a373742b25b6cad20920faebf5d41d0931f 100644 (file)
@@ -1,7 +1,7 @@
 i3status(1)
 ===========
 Michael Stapelberg <michael@i3wm.org>
-v2.11, January 2017
+v2.12, May 2018
 
 == NAME
 
@@ -307,7 +307,9 @@ network interface found on the system (excluding devices starting with "lo").
 
 *Example order*: +wireless wlan0+
 
-*Example format*: +W: (%quality at %essid, %bitrate / %frequency) %ip+
+*Example format_up*: +W: (%quality at %essid, %bitrate / %frequency) %ip+
+
+*Example format_down*: +W: down+
 
 === Ethernet
 
@@ -321,7 +323,9 @@ network interface found on the system (excluding devices starting with "lo").
 
 *Example order*: +ethernet eth0+
 
-*Example format*: +E: %ip (%speed)+
+*Example format_up*: +E: %ip (%speed)+
+
+*Example format_down*: +E: down+
 
 === Battery
 
index 3f34cf2ed1bc031221389278f1d9ccca62d22f4e..b930f5357a709e803c635b499132b6cd160a5cb1 100644 (file)
 
 #include "i3status.h"
 
-#ifdef __linux__
-#define LOOPBACK_DEV "lo"
-#else
+#ifdef __OpenBSD__
 #define LOOPBACK_DEV "lo0"
+#else
+#define LOOPBACK_DEV "lo"
 #endif
 
 static bool sysfs_devtype(char *dest, size_t n, const char *ifnam) {
@@ -67,24 +67,7 @@ static bool is_virtual(const char *ifname) {
 }
 
 static net_type_t iface_type(const char *ifname) {
-#ifdef __linux__
-    char devtype[32];
-
-    if (!sysfs_devtype(devtype, sizeof(devtype), ifname))
-        return NET_TYPE_OTHER;
-
-    /* Default to Ethernet when no devtype is available */
-    if (!devtype[0])
-        return NET_TYPE_ETHERNET;
-
-    if (strcmp(devtype, "wlan") == 0)
-        return NET_TYPE_WIRELESS;
-
-    if (strcmp(devtype, "wwan") == 0)
-        return NET_TYPE_OTHER;
-
-    return NET_TYPE_OTHER;
-#elif __OpenBSD__
+#ifdef __OpenBSD__
     /*
      *First determine if the device is a wireless device by trying two ioctl(2)
      * commands against it. If either succeeds we can be sure it's a wireless
@@ -127,8 +110,24 @@ static net_type_t iface_type(const char *ifname) {
         return NET_TYPE_ETHERNET;
     }
 #else
-#error Missing implementation to determine interface type.
+    char devtype[32];
+
+    if (!sysfs_devtype(devtype, sizeof(devtype), ifname))
+        return NET_TYPE_OTHER;
+
+    /* Default to Ethernet when no devtype is available */
+    if (!devtype[0])
+        return NET_TYPE_ETHERNET;
+
+    if (strcmp(devtype, "wlan") == 0)
+        return NET_TYPE_WIRELESS;
+
+    if (strcmp(devtype, "wwan") == 0)
+        return NET_TYPE_OTHER;
+
+    return NET_TYPE_OTHER;
 #endif
+    return NET_TYPE_OTHER;
 }
 
 const char *first_eth_interface(const net_type_t type) {
index 56ab62a1066079374b88fa3ce908e305a347ee03..431664ed9d0f2ccbe47535b0945ef70f3a76619e 100644 (file)
@@ -112,7 +112,7 @@ static int read_temperature(char *thermal_zone, temperature_t *temperature) {
         /* 'path' is the node within the full path (defaults to acpitz0). */
         if (BEGINS_WITH(sensordev.xname, thermal_zone)) {
             mib[3] = SENSOR_TEMP;
-            /* Limit to temo0, but should retrieve from a full path... */
+            /* Limit to temp0, but should retrieve from a full path... */
             for (numt = 0; numt < 1 /*sensordev.maxnumt[SENSOR_TEMP]*/; numt++) {
                 mib[4] = numt;
                 if (sysctl(mib, 5, &sensor, &slen, NULL, 0) == -1) {
@@ -205,7 +205,7 @@ error_netbsd1:
 
 /*
  * Reads the CPU temperature from /sys/class/thermal/thermal_zone%d/temp (or
- * the user provided path) and returns the temperature in degree celcius.
+ * the user provided path) and returns the temperature in degree celsius.
  *
  */
 void print_cpu_temperature_info(yajl_gen json_gen, char *buffer, int zone, const char *path, const char *format, const char *format_above_threshold, int max_threshold) {
@@ -216,6 +216,8 @@ void print_cpu_temperature_info(yajl_gen json_gen, char *buffer, int zone, const
     bool colorful_output = false;
     char *thermal_zone;
     temperature_t temperature;
+    temperature.raw_value = 0;
+    sprintf(temperature.formatted_value, "%.2f", 0.0);
 
     if (path == NULL)
         asprintf(&thermal_zone, THERMAL_ZONE, zone);
index f9cd1f48bd1535949abb66f8d45658217543f39c..c955c1cea0cfa84a0671148e10bca046c4d26a65 100644 (file)
@@ -29,6 +29,7 @@ const char *get_ip_addr(const char *interface, int family) {
 
     struct ifaddrs *ifaddr, *addrp;
     bool found = false;
+    int interface_len = strlen(interface);
 
     getifaddrs(&ifaddr);
 
@@ -39,13 +40,13 @@ const char *get_ip_addr(const char *interface, int family) {
     for (addrp = ifaddr;
 
          (addrp != NULL &&
-          (strcmp(addrp->ifa_name, interface) != 0 ||
+          (strncmp(addrp->ifa_name, interface, interface_len) != 0 ||
            addrp->ifa_addr == NULL ||
            addrp->ifa_addr->sa_family != family));
 
          addrp = addrp->ifa_next) {
         /* Check if the interface is down */
-        if (strcmp(addrp->ifa_name, interface) != 0)
+        if (strncmp(addrp->ifa_name, interface, interface_len) != 0)
             continue;
         found = true;
         if ((addrp->ifa_flags & IFF_RUNNING) == 0) {
index c3b52708f743a61f1ba218bc62b2e7bd7a0b0eac..efdd59b777907953403d1418fe49d1ebcd59bc9b 100644 (file)
@@ -16,6 +16,7 @@
 #endif
 
 #ifdef __APPLE__
+#include <sys/socket.h>
 #define IW_ESSID_MAX_SIZE 32
 #endif