diff --git a/src/QBar/Core.hs b/src/QBar/Core.hs index aa497946dee574bc5f1c18132b4ae87bc5e7c726..cdb41bcf6bfc2267199905fd28566dd4b3603519 100644 --- a/src/QBar/Core.hs +++ b/src/QBar/Core.hs @@ -250,7 +250,7 @@ newCache'' = do -- |Creates a cache from a push block. cachePushBlock :: PushBlock -> BlockCache -cachePushBlock pushBlock = newCache $ () <$ (pushBlock >-> updateBarP >-> fixBlockName >-> PP.map (\a -> [a])) +cachePushBlock pushBlock = newCache $ () <$ (pushBlock >-> updateBarP >-> addBlockName >-> PP.map (\a -> [a])) where updateBarP :: Pipe BlockUpdate BlockState BarIO r updateBarP = forever $ do @@ -259,15 +259,12 @@ cachePushBlock pushBlock = newCache $ () <$ (pushBlock >-> updateBarP >-> fixBlo updateBar reason -- |Sets 'blockName' to a random (but static) identifier if an event handler is set but the 'blockName' is not set. - fixBlockName :: Pipe BlockState BlockState BarIO r - fixBlockName = do + addBlockName :: Pipe BlockState BlockState BarIO r + addBlockName = do defaultBlockName <- randomIdentifier forever $ do state <- await - yield $ if hasEventHandler state - then (_Just . _1 . blockName) %~ (Just . fromMaybe defaultBlockName) $ state - else state - + yield $ (_Just . _1 . blockName) %~ (Just . fromMaybe defaultBlockName) $ state modify :: (BlockOutput -> BlockOutput) -> Pipe BlockUpdate BlockUpdate BarIO r @@ -295,7 +292,6 @@ autoPadding = autoPadding' 0 0 padShortText :: Int64 -> BlockOutput -> BlockOutput padShortText len = over (shortText._Just) $ \s -> padString (len - printedLength s) <> s - addBlock :: IsCachable a => a -> BarIO () addBlock block = do newBlockChan' <- newBlockChan <$> askBar