From d35516a3540d440441d64c9d2f6cf949ba22d6a3 Mon Sep 17 00:00:00 2001 From: Lucien Cartier-Tilet Date: Fri, 18 Jun 2021 19:26:16 +0200 Subject: [PATCH] Better Windows support for partition detection with duf --- README.org | 11 ++++++++--- eshell-info-banner.el | 9 ++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/README.org b/README.org index aa21a33..25e1c75 100644 --- a/README.org +++ b/README.org @@ -21,6 +21,7 @@ macOS. PR are welcome if you want to fix that! - [[#installation][Installation]] - [[#customizing][Customizing]] - [[#my-computer-doesnt-have-a-battery-will-this-still-work][My computer doesn’t have a battery, will this still work?]] +- [[#advice-for-windows-users][Advice for Windows users]] - [[#contributing][Contributing]] - [[#license][License]] @@ -100,9 +101,7 @@ A couple of variables can be edited by the user in order to configure better replacement for ~df~ and should be more platform-agnostic than the latter. I also suspect this implementation will be faster than the one with ~df~, since there is very few string manipulation with - ~duf~ compared to the implementations with ~df~. However, due to - ~shell-command-to-string~, Windows users might want to turn it off by - default. + ~duf~ compared to the implementations with ~df~. Default value: ~t~ if ~duf~ is found on the system, ~nil~ otherwise - ~eshell-info-banner-duf-executable~ :: Path to your ~duf~ executable. If @@ -135,6 +134,12 @@ detect whether you have a battery or not/ and will only display this line if you have one. If you don’t have a battery, the only difference is you will have one less line than laptop users. +* Advice for Windows users +Currently, the partitions detection is done only with the ~duf~ +command-line utility. If you want a list of your partitions, I +strongly encourage you to install it on your system. See +[[https://github.com/muesli/duf#windows]]. + * Contributing See [[file:CONTRIBUTING.org]]. diff --git a/eshell-info-banner.el b/eshell-info-banner.el index 82393d9..c8844c2 100644 --- a/eshell-info-banner.el +++ b/eshell-info-banner.el @@ -256,11 +256,10 @@ neither of these, an error will be thrown by the function." Return detected partitions as a list of structs. See `eshell-info-banner-partition-prefixes' to see how partitions are -chosen. Relies on the `duf' command. - -FIXME: filter first partitions, then get other information." - (let* ((partitions (json-read-from-string (shell-command-to-string (concat eshell-info-banner-duf-executable - " -json")))) +chosen. Relies on the `duf' command." + (let* ((partitions (json-read-from-string (with-temp-buffer + (call-process "duf" nil t nil "-json") + (buffer-string)))) (partitions (cl-remove-if-not (lambda (partition) (let ((device (format "%s" (cdr (assoc 'device partition))))) (seq-some (lambda (prefix)