Merge pull request #414 from srid/patch-1

Loggers: don't hardcode /usr/bin
This commit is contained in:
Tomáš Janoušek
2020-11-29 11:55:45 +00:00
committed by GitHub
2 changed files with 7 additions and 4 deletions

View File

@@ -248,6 +248,9 @@
* `XMonad.Util.EZConfig` * `XMonad.Util.EZConfig`
- Added support for XF86Bluetooth. - Added support for XF86Bluetooth.
* `XMonad.Util.Loggers`
- Make `battery` and `loadAvg` distro-independent.
* `XMonad.Hooks.DynamicLog` * `XMonad.Hooks.DynamicLog`
- Added `xmobarBorder` function to create borders around strings. - Added `xmobarBorder` function to create borders around strings.

View File

@@ -115,9 +115,9 @@ aumixVolume = logCmd "aumix -vq"
-- | Get the battery status (percent charge and charging\/discharging -- | Get the battery status (percent charge and charging\/discharging
-- status). This is an ugly hack and may not work for some people. -- 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 -- 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 :: 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 -- | Get the current date and time, and format them via the
-- given format string. The format used is the same as that used -- 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 return . Just $ formatCalendarTime defaultTimeLocale fmt cal
-- | Get the load average. This assumes that you have a -- | 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 -- installed; these are fairly common on GNU\/Linux systems but it
-- would be nice to make this more general. -- would be nice to make this more general.
loadAvg :: Logger 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. -- | Create a 'Logger' from an arbitrary shell command.
logCmd :: String -> Logger logCmd :: String -> Logger