summaryrefslogtreecommitdiffhomepage
path: root/src/Xmobar/Text/Swaybar.hs
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2022-02-04 05:53:48 +0000
committerjao <jao@gnu.org>2022-02-06 00:24:10 +0000
commit6e124f046b5b92dd3cdfc4a4ea337e3aca4c025d (patch)
treeca2b3dcffe2a4c2529a6bb980266aad8f0c9f504 /src/Xmobar/Text/Swaybar.hs
parentb6ab169dc7c616fed4ba0ecd542471f0157fc084 (diff)
downloadxmobar-6e124f046b5b92dd3cdfc4a4ea337e3aca4c025d.tar.gz
xmobar-6e124f046b5b92dd3cdfc4a4ea337e3aca4c025d.tar.bz2
swaybar-protocol: very basic format
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) ++ "],"