summaryrefslogtreecommitdiffhomepage
path: root/src/Xmobar/Text/Swaybar.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Xmobar/Text/Swaybar.hs')
-rw-r--r--src/Xmobar/Text/Swaybar.hs39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/Xmobar/Text/Swaybar.hs b/src/Xmobar/Text/Swaybar.hs
new file mode 100644
index 0000000..a4ee306
--- /dev/null
+++ b/src/Xmobar/Text/Swaybar.hs
@@ -0,0 +1,39 @@
+------------------------------------------------------------------------------
+-- |
+-- Module: Xmobar.Text.Swaybar
+-- Copyright: (c) 2022 Jose Antonio Ortega Ruiz
+-- License: BSD3-style (see LICENSE)
+--
+-- Maintainer: jao@gnu.org
+-- Stability: unstable
+-- Portability: portable
+-- Created: Fri Feb 4, 2022 03:58
+--
+--
+-- Segment codification using swaybar-protocol JSON strings
+--
+------------------------------------------------------------------------------
+
+module Xmobar.Text.Swaybar (preamble, formatSwaybar) where
+
+import Data.List (intercalate)
+
+import Xmobar.Config.Types (Config)
+
+import Xmobar.Run.Parsers ( Segment
+ , Widget(..)
+ -- , tColorsString
+ -- , colorComponents
+ )
+
+preamble :: String
+preamble = "{\"version\": 1, \"click_events\": true}\x0A["
+
+formatSwaybar' :: Config -> Segment -> String
+formatSwaybar' _conf (Text txt, _, _, _) =
+ "{\"full_text\":\"" ++ txt ++ "\"}"
+formatSwaybar' _ _ = ""
+
+formatSwaybar :: Config -> [Segment] -> String
+formatSwaybar conf segs =
+ "[" ++ intercalate "," (map (formatSwaybar' conf) segs) ++ "],"