blob: a4ee3061ac5b1c3e196393cf5d2d26f276154768 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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) ++ "],"
|