packages feed

hi3status 0.1.0.0 → 0.1.1.0

raw patch · 3 files changed

+46/−2 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Hi3Status.Blocks.Command: CommandBlock :: String -> String -> Maybe Int -> CommandBlock
+ Hi3Status.Blocks.Command: [cmd] :: CommandBlock -> String
+ Hi3Status.Blocks.Command: [format] :: CommandBlock -> String
+ Hi3Status.Blocks.Command: [refresh] :: CommandBlock -> Maybe Int
+ Hi3Status.Blocks.Command: data CommandBlock
+ Hi3Status.Blocks.Command: instance Hi3Status.Block.Block Hi3Status.Blocks.Command.CommandBlock

Files

hi3status.cabal view
@@ -1,5 +1,5 @@ name:                hi3status-version:             0.1.0.0+version:             0.1.1.0 synopsis:            Status line for i3bar. description:         Hi3status is a compact, lightweight, responsive and highly configurable status line for i3bar. license:             MIT@@ -31,6 +31,7 @@                        Hi3Status.Blocks.Window                        Hi3Status.Blocks.Weather                        Hi3Status.Blocks.Music+                       Hi3Status.Blocks.Command   other-modules:       Hi3Status.Block.Internal                        Hi3Status.StatusLine   build-depends:       base >=4.8 && <4.9, vector, text, aeson, dbus, transformers, bytestring, process, time, regex-pcre-builtin, dyre, prefix-units, network, binary
+ lib-src/Hi3Status/Blocks/Command.hs view
@@ -0,0 +1,43 @@+{-|+Module      : Hi3Status.Blocks.Command+License     : MIT+Maintainer  : Josh Kirklin (jjvk2@cam.ac.uk)+Stability   : experimental+-}+module Hi3Status.Blocks.Command (+    CommandBlock (..)+    ) where++import Hi3Status.Block+import Hi3Status.Block.Util++import qualified Data.Text as T+import System.Process+import GHC.IO.Handle+import Control.Monad.IO.Class++-- | A block that executes an arbitrary shell command and displays the output.+data CommandBlock = CommandBlock {+    -- | The command to execute.+    cmd :: String, +    -- | The format of the displayed text.+    --+    -- *@{stdout}@ = stdout.+    -- *@{stderr}@ = stderr.+    format :: String,+    -- | An optional refresh period in microseconds.+    refresh :: Maybe Int +    }++instance Block CommandBlock where+    runBlock b = case refresh b of+        Nothing -> onUpdate go+        Just n -> periodic n go+      where+        go = do+            (_, mhout, mherr, _) <- liftIO $ createProcess $ (shell (cmd b)) { std_out = CreatePipe, std_err = CreatePipe }+            out <- maybe (return "") (liftIO . hGetContents) mhout+            err <- maybe (return "") (liftIO . hGetContents) mherr+            pushBlockDescription $ emptyBlockDescription +                { full_text = formatText [("stdout", concat . take 1 . lines $ out),("stderr", concat . take 1 . lines $ err)] (format b) }+
lib-src/Hi3Status/Blocks/Weather.hs view
@@ -19,7 +19,7 @@  data Conditions = ClearDay | ClearNight | Rain | Cloudy --- | A simple block that displays a piece of static text. Requires @weather@ and @sunwait@.+-- | A block to display the weather. Requires @weather@ and @sunwait@. data WeatherBlock = WeatherBlock  {     -- | The weather format.     --