From c75f31c0887b12c1e9fd63a05a494d703c43576a Mon Sep 17 00:00:00 2001 From: jao Date: Mon, 7 Feb 2022 03:58:14 +0000 Subject: swaybar-protocol: additionalFonts via pango markup --- src/Xmobar/Text/Pango.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/Xmobar/Text/Pango.hs') diff --git a/src/Xmobar/Text/Pango.hs b/src/Xmobar/Text/Pango.hs index b8205ef..38d1b5b 100644 --- a/src/Xmobar/Text/Pango.hs +++ b/src/Xmobar/Text/Pango.hs @@ -15,9 +15,10 @@ -- ------------------------------------------------------------------------------ -module Xmobar.Text.Pango (withPangoColor) where +module Xmobar.Text.Pango (withPangoColor, withPangoFont) where import Text.Printf (printf) +import Data.List (isPrefixOf) replaceAll :: (Eq a) => a -> [a] -> [a] -> [a] replaceAll c s = concatMap (\x -> if x == c then s else [x]) @@ -33,3 +34,8 @@ withPangoColor :: (String, String) -> String -> String withPangoColor (fg, bg) s = printf fmt (xmlEscape fg) (xmlEscape bg) (xmlEscape s) where fmt = "%s" + +withPangoFont :: String -> String -> String +withPangoFont font txt = printf fmt pfn (xmlEscape txt) + where fmt = "%s" + pfn = if "xft:" `isPrefixOf` font then drop 4 font else font -- cgit v1.2.3