From 2a2cd827a35f3a945a272fcdf3a84495bb5f531c Mon Sep 17 00:00:00 2001 From: Jens Nolte <jens@nightmarestudio.de> Date: Tue, 25 Feb 2020 23:46:33 +0100 Subject: [PATCH] Move blocks that require external scripts from default- to legacy config --- src/QBar/Cli.hs | 11 +++++++++-- src/QBar/DefaultConfig.hs | 22 +++++++++++++++++++--- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/QBar/Cli.hs b/src/QBar/Cli.hs index e8c6d50..6384006 100644 --- a/src/QBar/Cli.hs +++ b/src/QBar/Cli.hs @@ -67,7 +67,14 @@ barConfigurationParser = do l -> sequence_ l blockParser :: Parser (BarIO ()) -blockParser = hsubparser ( - command "default" (info (pure defaultBarConfig) (progDesc "Load default set of blocks.")) <> +blockParser = subparser ( + commandGroup "Available blocks:" <> command "date" (info (pure $ addBlock dateBlock) (progDesc "Load the date and time block.")) ) + <|> + subparser ( + hidden <> + commandGroup "Available presets:" <> + command "default" (info (pure defaultBarConfig) (progDesc "Load default set of blocks.")) <> + command "legacy" (info (pure legacyBarConfig) (progDesc "Load the legacy configuration. Requires some custom block scripts.")) + ) diff --git a/src/QBar/DefaultConfig.hs b/src/QBar/DefaultConfig.hs index ee42174..7fc58cd 100644 --- a/src/QBar/DefaultConfig.hs +++ b/src/QBar/DefaultConfig.hs @@ -8,13 +8,26 @@ import Pipes import Control.Lens -blockLocation :: String -> FilePath -blockLocation name = "~/.config/qbar/blocks/" <> name - defaultBarConfig :: BarIO () defaultBarConfig = do systemInfoInterval <- sharedInterval 10 + let battery = systemInfoInterval $ batteryBlock >-> modify (blockName ?~ "battery") + let cpuUsage = systemInfoInterval $ cpuUsageBlock 1 >-> modify ((blockName ?~ "cpuUsage") . addIcon "💻\xFE0E") + + -- TODO: commented-out blocks should be added as soon as they are implemented in qbar + addBlock dateBlock + addBlock battery + --addBlock volumeBlock + addBlock cpuUsage + --addBlock ramUsageBlock + --addBlock cpuTemperatureBlock + --addBlock networkBlock + +legacyBarConfig :: BarIO () +legacyBarConfig = do + systemInfoInterval <- sharedInterval 10 + let todo = systemInfoInterval (blockScript $ blockLocation "todo") let wifi = systemInfoInterval $ (blockScript $ blockLocation "wifi2") >-> modify (addIcon "📡\xFE0E") let networkEnvironment = systemInfoInterval (blockScript $ blockLocation "network-environment") @@ -33,3 +46,6 @@ defaultBarConfig = do addBlock networkEnvironment addBlock wifi addBlock todo + where + blockLocation :: String -> FilePath + blockLocation name = "~/.config/qbar/blocks/" <> name -- GitLab