From 95f68e2ca384f445981956cf6cbba016ef5c527b Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Fri, 27 Nov 2020 21:54:07 +0000 Subject: [PATCH 1/2] Loggers: don't hardcode /usr/bin Some Linux distros, like NixOS, don't put these binaries under /usr/bin. --- XMonad/Util/Loggers.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/XMonad/Util/Loggers.hs b/XMonad/Util/Loggers.hs index d627b937..6ae1fd5d 100644 --- a/XMonad/Util/Loggers.hs +++ b/XMonad/Util/Loggers.hs @@ -115,9 +115,9 @@ aumixVolume = logCmd "aumix -vq" -- | Get the battery status (percent charge and charging\/discharging -- status). This is an ugly hack and may not work for some people. -- At some point it would be nice to make this more general\/have --- fewer dependencies (assumes @\/usr\/bin\/acpi@ and @sed@ are installed.) +-- fewer dependencies (assumes @acpi@ and @sed@ are installed.) battery :: Logger -battery = logCmd "/usr/bin/acpi | sed -r 's/.*?: (.*%).*/\\1/; s/[dD]ischarging, ([0-9]+%)/\\1-/; s/[cC]harging, ([0-9]+%)/\\1+/; s/[cC]harged, //'" +battery = logCmd "acpi | sed -r 's/.*?: (.*%).*/\\1/; s/[dD]ischarging, ([0-9]+%)/\\1-/; s/[cC]harging, ([0-9]+%)/\\1+/; s/[cC]harged, //'" -- | Get the current date and time, and format them via the -- given format string. The format used is the same as that used @@ -130,11 +130,11 @@ date fmt = io $ do cal <- (getClockTime >>= toCalendarTime) return . Just $ formatCalendarTime defaultTimeLocale fmt cal -- | Get the load average. This assumes that you have a --- utility called @\/usr\/bin\/uptime@ and that you have @sed@ +-- utility called @uptime@ and that you have @sed@ -- installed; these are fairly common on GNU\/Linux systems but it -- would be nice to make this more general. loadAvg :: Logger -loadAvg = logCmd "/usr/bin/uptime | sed 's/.*: //; s/,//g'" +loadAvg = logCmd "uptime | sed 's/.*: //; s/,//g'" -- | Create a 'Logger' from an arbitrary shell command. logCmd :: String -> Logger From e52c20f70c5da578a486bf760aa123cb9f825692 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Fri, 27 Nov 2020 21:56:13 +0000 Subject: [PATCH 2/2] Update CHANGES.md --- CHANGES.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index edf425db..d7e4b7de 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -248,6 +248,9 @@ * `XMonad.Util.EZConfig` - Added support for XF86Bluetooth. + + * `XMonad.Util.Loggers` + - Make `battery` and `loadAvg` distro-independent. * `XMonad.Hooks.DynamicLog` - Added `xmobarBorder` function to create borders around strings.