Using the BatteryP monitor plugin's -a option causes waitForProcess error in XMobar

69 Views Asked by At

Given this ~/.config/xmonad/xmonad.hs

import XMonad
import XMonad.Hooks.EwmhDesktops
import XMonad.Hooks.StatusBar
import XMonad.Hooks.StatusBar.PP

--spawn "xset dpms 0 0 0" >> -- Screensaver

main :: IO ()
main = xmonad
     . ewmhFullscreen
     . ewmh
     . withEasySB (statusBarProp (unwords ["xmobar", xmobarhs]) (pure def)) toggleStrutsKey
     $ myConfig
     where
       toggleStrutsKey XConfig { modMask = m } = (m, xK_b)
       xmobarhs = "~/.config/xmobar/xmobar.hs"

myConfig = def
    { terminal = "urxvt"
    , modMask = mod4Mask
    }

and this ~/.config/xmobar/xmobar.hs (not xmobarrc!)

import Xmobar

main :: IO ()
main = xmobar defaultConfig {
       overrideRedirect = False
       , bgColor  = "#1f222d"
       , fgColor  = "#f8f8f2"
       , position = BottomSize L 100{- reduce this to put system tray -} 25
       , commands = [ Run $ BatteryP ["BAT0"]
                                     ["--template", "<acstatus><left>(<timeleft>)",
                                     "--", "-P",
                                     "-a", "date > ~/battery.out",{-¹-}
                                     "-A", "100"] 50 -- the "100" is to make the notification come up a few seconds after I've unplugged the power on a 100% charged battery
                    ]
       , sepChar  = "%"
       , alignSep = "}{"
       , template = "%battery%"
       }

when the battery goes below 100% (well, this is just so I can repro easily without waiting for the battery to go low), the status bar shows this error

error: waitForProcess: does not exist (No child processes)

However, the file battery.out is created, and with the expected content!


(¹) My intention is to change that line to

"-a", "notify-send -u critical 'Battery running out!!'",

but apparently notify-send is not itself part of the problem.


This is the same error that I'm getting in the (seemingly) unrelated scenario of trying to make workspaces clickable (see here for more details) therefore I'm starting to think that there's something not quite right in my using xmobar.hs instead of xmobarrc. But I haven't understood yet what.

0

There are 0 best solutions below