summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngo Bürk <ingo.buerk@tngtech.com>2015-05-29 08:41:11 +0200
committerIngo Bürk <ingo.buerk@tngtech.com>2015-05-29 08:43:29 +0200
commit75a835742e60311f7f27bf44af862caad67e3a23 (patch)
tree3a13223bb57c97ae0b429143508ba2910146d717
parentd1aa135d2801d361f2eccc5efab08a6385ecb440 (diff)
Use format_not_mounted if the directory for a disk_info block does not exist.
This is useful for dynamically mounted devices like thumb drives that get mounted into a directory such as '/media/$UID/$NAME'. fixes #33
-rw-r--r--man/i3status.man2
-rw-r--r--src/print_disk_info.c9
2 files changed, 6 insertions, 5 deletions
diff --git a/man/i3status.man b/man/i3status.man
index a3a8c60..b7eddb7 100644
--- a/man/i3status.man
+++ b/man/i3status.man
@@ -238,7 +238,7 @@ is assumed to be "percentage_avail" and low_threshold to be set to 0, which
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
+which is used if the path does not exist or is not a mount point. So you can just empty
the output for the given path with adding +format_not_mounted=""+
to the config section.
diff --git a/src/print_disk_info.c b/src/print_disk_info.c
index 69d7b8c..7fd47b9 100644
--- a/src/print_disk_info.c
+++ b/src/print_disk_info.c
@@ -124,10 +124,11 @@ void print_disk_info(yajl_gen json_gen, char *buffer, const char *path, const ch
#else
struct statvfs buf;
- if (statvfs(path, &buf) == -1)
- return;
-
- if (format_not_mounted != NULL) {
+ if (statvfs(path, &buf) == -1) {
+ /* If statvfs errors, e.g., due to the path not existing,
+ * we use the format for a not mounted device. */
+ format = format_not_mounted;
+ } else if (format_not_mounted != NULL) {
FILE *mntentfile = setmntent("/etc/mtab", "r");
struct mntent *m;
bool found = false;