]> git.sur5r.net Git - i3/i3status/commitdiff
Merge pull request #7 from Watcom/master
authorMichael Stapelberg <stapelberg@users.noreply.github.com>
Fri, 3 Apr 2015 21:45:40 +0000 (14:45 -0700)
committerMichael Stapelberg <stapelberg@users.noreply.github.com>
Fri, 3 Apr 2015 21:45:40 +0000 (14:45 -0700)
PulseAudio support for volume input

i3status.c
include/i3status.h
man/i3status.man
src/print_cpu_usage.c
src/print_path_exists.c
src/print_run_watch.c

index a0beb3e8307df9b9211ae31ffbea5c492b4be3d8..a4c12bfc25619a2e96cb036e82c25b7edfba97e9 100644 (file)
@@ -290,6 +290,7 @@ int main(int argc, char *argv[]) {
     cfg_opt_t run_watch_opts[] = {
         CFG_STR("pidfile", NULL, CFGF_NONE),
         CFG_STR("format", "%title: %status", CFGF_NONE),
+        CFG_STR("format_down", NULL, CFGF_NONE),
         CFG_CUSTOM_ALIGN_OPT,
         CFG_CUSTOM_COLOR_OPTS,
         CFG_CUSTOM_MIN_WIDTH_OPT,
@@ -298,6 +299,7 @@ int main(int argc, char *argv[]) {
     cfg_opt_t path_exists_opts[] = {
         CFG_STR("path", NULL, CFGF_NONE),
         CFG_STR("format", "%title: %status", CFGF_NONE),
+        CFG_STR("format_down", NULL, CFGF_NONE),
         CFG_CUSTOM_ALIGN_OPT,
         CFG_CUSTOM_COLOR_OPTS,
         CFG_CUSTOM_MIN_WIDTH_OPT,
@@ -607,13 +609,13 @@ int main(int argc, char *argv[]) {
 
             CASE_SEC_TITLE("run_watch") {
                 SEC_OPEN_MAP("run_watch");
-                print_run_watch(json_gen, buffer, title, cfg_getstr(sec, "pidfile"), cfg_getstr(sec, "format"));
+                print_run_watch(json_gen, buffer, title, cfg_getstr(sec, "pidfile"), cfg_getstr(sec, "format"), cfg_getstr(sec, "format_down"));
                 SEC_CLOSE_MAP;
             }
 
             CASE_SEC_TITLE("path_exists") {
                 SEC_OPEN_MAP("path_exists");
-                print_path_exists(json_gen, buffer, title, cfg_getstr(sec, "path"), cfg_getstr(sec, "format"));
+                print_path_exists(json_gen, buffer, title, cfg_getstr(sec, "path"), cfg_getstr(sec, "format"), cfg_getstr(sec, "format_down"));
                 SEC_CLOSE_MAP;
             }
 
index f2a262c035fae8b1e193e76e452e64df18fd1f25..8fb1b7970a168738e04ade72f87886cafb58870e 100644 (file)
@@ -189,10 +189,10 @@ void print_disk_info(yajl_gen json_gen, char *buffer, const char *path, const ch
 void print_battery_info(yajl_gen json_gen, char *buffer, int number, const char *path, const char *format, const char *format_down, const char *status_chr, const char *status_bat, const char *status_full, int low_threshold, char *threshold_type, bool last_full_capacity, bool integer_battery_capacity, bool hide_seconds);
 void print_time(yajl_gen json_gen, char *buffer, const char *title, const char *format, const char *tz, time_t t);
 void print_ddate(yajl_gen json_gen, char *buffer, const char *format, time_t t);
-const char *get_ip_addr();
+const char *get_ip_addr(const char *interface);
 void print_wireless_info(yajl_gen json_gen, char *buffer, const char *interface, const char *format_up, const char *format_down);
-void print_run_watch(yajl_gen json_gen, char *buffer, const char *title, const char *pidfile, const char *format);
-void print_path_exists(yajl_gen json_gen, char *buffer, const char *title, const char *path, const char *format);
+void print_run_watch(yajl_gen json_gen, char *buffer, const char *title, const char *pidfile, const char *format, const char *format_down);
+void print_path_exists(yajl_gen json_gen, char *buffer, const char *title, const char *path, const char *format, const char *format_down);
 void print_cpu_temperature_info(yajl_gen json_gen, char *buffer, int zone, const char *path, const char *format, int);
 void print_cpu_usage(yajl_gen json_gen, char *buffer, const char *format);
 void print_eth_info(yajl_gen json_gen, char *buffer, const char *interface, const char *format_up, const char *format_down);
index 502f391ea29538f30f1dd30c7715a32062391719..a3a8c60e97d4dc58ebe458f84d860862bca87088 100644 (file)
@@ -239,7 +239,7 @@ implies no coloring at all.
 
 You can define a different format with the option "format_not_mounted"
 which is used if the path is not a mount point. So you can just empty
-the output for the given path with adding »format_not_mounted=""«
+the output for the given path with adding +format_not_mounted=""+
 to the config section.
 
 *Example order*: +disk /mnt/usbstick+
@@ -259,6 +259,8 @@ to the config section.
 Expands the given path to a pidfile and checks if the process ID found inside
 is valid (that is, if the process is running). You can use this to check if
 a specific application, such as a VPN client or your DHCP client is running.
+There also is an option "format_down". You can hide the output with
++format_down=""+.
 
 *Example order*: +run_watch DHCP+
 
@@ -268,6 +270,8 @@ a specific application, such as a VPN client or your DHCP client is running.
 
 Checks if the given path exists in the filesystem. You can use this to check if
 something is active, like for example a VPN tunnel managed by NetworkManager.
+There also is an option "format_down". You can hide the output with
++format_down=""+.
 
 *Example order*: +path_exists VPN+
 
@@ -446,6 +450,7 @@ or OSS (FreeBSD/OpenBSD).
 *Example order*: +volume master+
 
 *Example format*: +♪: %volume+
+
 *Example format_muted*: +♪: 0%%+
 
 *Example configuration*:
index 2c59f69277ffc0452f62f2498cda0c7c093efa22..927e763891eb78408d295d933db69ba07421603e 100644 (file)
 #include <sys/param.h>
 #include <sys/types.h>
 #include <sys/sysctl.h>
+#if defined(__OpenBSD__)
+#include <sys/sched.h>
+#else
 #include <sys/dkstat.h>
 #endif
+#endif
 
 #if defined(__DragonFly__)
 #include <sys/param.h>
index 1b231e6f78ef6afa140852bfa1c5cde23718ce1e..65bc9c85028a35aa7283f9bea31afd90c0b98d85 100644 (file)
@@ -6,17 +6,23 @@
 #include <sys/stat.h>
 #include "i3status.h"
 
-void print_path_exists(yajl_gen json_gen, char *buffer, const char *title, const char *path, const char *format) {
+void print_path_exists(yajl_gen json_gen, char *buffer, const char *title, const char *path, const char *format, const char *format_down) {
     const char *walk;
     char *outwalk = buffer;
     struct stat st;
     const bool exists = (stat(path, &st) == 0);
 
+    if (exists || format_down == NULL) {
+        walk = format;
+    } else {
+        walk = format_down;
+    }
+
     INSTANCE(path);
 
     START_COLOR((exists ? "color_good" : "color_bad"));
 
-    for (walk = format; *walk != '\0'; walk++) {
+    for (; *walk != '\0'; walk++) {
         if (*walk != '%') {
             *(outwalk++) = *walk;
             continue;
index 3d1ec3fa4922a62248ecf83e1c6782fb84acc09d..b108f8fef85b728ac2d388b6055744c6c13bd400 100644 (file)
@@ -5,16 +5,22 @@
 #include <yajl/yajl_version.h>
 #include "i3status.h"
 
-void print_run_watch(yajl_gen json_gen, char *buffer, const char *title, const char *pidfile, const char *format) {
+void print_run_watch(yajl_gen json_gen, char *buffer, const char *title, const char *pidfile, const char *format, const char *format_down) {
     bool running = process_runs(pidfile);
     const char *walk;
     char *outwalk = buffer;
 
+    if (running || format_down == NULL) {
+        walk = format;
+    } else {
+        walk = format_down;
+    }
+
     INSTANCE(pidfile);
 
     START_COLOR((running ? "color_good" : "color_bad"));
 
-    for (walk = format; *walk != '\0'; walk++) {
+    for (; *walk != '\0'; walk++) {
         if (*walk != '%') {
             *(outwalk++) = *walk;
             continue;