diff options
| author | Léana 江 <leana.jiang+git@icloud.com> | 2026-06-22 17:18:41 +0200 |
|---|---|---|
| committer | jao <mail@jao.io> | 2026-06-23 21:41:59 +0200 |
| commit | dcfbeabc8c6c3a775c946fb83628889d254aba48 (patch) | |
| tree | 4c9196514e92b59cad292a493653e6d5f68d2178 /src/Xmobar | |
| parent | 7e04e1156205d9ca4fcfccc12957b2a6abdc8b86 (diff) | |
| download | xmobar-dcfbeabc8c6c3a775c946fb83628889d254aba48.tar.gz xmobar-dcfbeabc8c6c3a775c946fb83628889d254aba48.tar.bz2 | |
pass remaining battery percentage to low battery command
Diffstat (limited to 'src/Xmobar')
| -rw-r--r-- | src/Xmobar/Plugins/Monitors/Batt/Common.hs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/Xmobar/Plugins/Monitors/Batt/Common.hs b/src/Xmobar/Plugins/Monitors/Batt/Common.hs index ddb2b8c..d74f080 100644 --- a/src/Xmobar/Plugins/Monitors/Batt/Common.hs +++ b/src/Xmobar/Plugins/Monitors/Batt/Common.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE TypeApplications #-} ----------------------------------------------------------------------------- -- | -- Module : Plugins.Monitors.Batt.Common @@ -18,7 +19,8 @@ module Xmobar.Plugins.Monitors.Batt.Common (BattOpts(..) , Status(..) , maybeAlert) where -import System.Process (spawnCommand, waitForProcess) +import System.Environment +import System.Process (waitForProcess, createProcess_, shell, CreateProcess(env)) import Control.Monad (unless, void) import Xmobar.Plugins.Monitors.Common @@ -54,4 +56,12 @@ maybeAlert opts left = case onLowAction opts of Nothing -> return () Just x -> unless (isNaN left || actionThreshold opts < 100 * left) - $ void $ spawnCommand (x ++ " &") >>= waitForProcess + $ runCmd =<< mkShellCmd x + where + mkShellCmd command = do + selfEnv <- getEnvironment + pure (shell command) { env = Just $ [("XMOBAR_BATT_LEFT", show @Integer $ round $ 100 * left)] ++ selfEnv + } + runCmd c = do + (_,_,_,p) <- createProcess_ "maybeAlert" c + void $ waitForProcess p |
