[xmonad] X.A.GridSelect spawnSelected colorized
Platon Pronko
platon7pronko at gmail.com
Mon Aug 10 13:01:21 UTC 2020
Hi!
You mean you want to reuse your `myColorizer` for spawnSelected, correct? Then you'll need to rewrite colorRangeFromClassName a bit, because that one expects Window and you have a String. Something like this may work (haven't compiled it, just copied&tweaked the source for colorRangeFromClassName):
colorRangeFromString :: (Word8, Word8, Word8) -- ^ Beginning of the color range
-> (Word8, Word8, Word8) -- ^ End of the color range
-> (Word8, Word8, Word8) -- ^ Background of the active window
-> (Word8, Word8, Word8) -- ^ Inactive text color
-> (Word8, Word8, Word8) -- ^ Active text color
-> Window -> Bool -> X (String, String)
colorRangeFromString startC endC activeC inactiveT activeT str active =
if active
then (rgbToHex activeC, rgbToHex activeT)
else (rgbToHex $ mix startC endC
$ stringToRatio str, rgbToHex inactiveT)
where rgbToHex :: (Word8, Word8, Word8) -> String
rgbToHex (r, g, b) = '#':twodigitHex r
++twodigitHex g++twodigitHex b
stringColorizer :: String -> Bool -> X (String, String)
stringColorizer = colorRangeFromString
(0x31,0x2e,0x39) -- lowest inactive bg
(0x31,0x2e,0x39) -- highest inactive bg
(0x78,0x3e,0x57) -- active bg
(0xc0,0xa7,0x9a) -- inactive fg
(0xff,0xff,0xff) -- active fg
windowColorizer :: Window -> Bool -> X (String, String)
windowColorizer w active = runQuery className w >>= flip stringColorizer active
Best regards,
Platon Pronko
On 2020-08-10 15:13, Dave Macias wrote:
> Thank you for the reply.
> That helped me to figure it out.
> But I had to create a separate *Colorizer*. (see below)
> Is there a way to use the same colorizer as goToSelected?
> Thanks!
>
> myGSFont = "xft:Noto Sans CJK KR:bold:pixelsize=10"
> myColorizer :: Window -> Bool -> X (String, String)
> myColorizer = colorRangeFromClassName
> (0x31,0x2e,0x39) -- lowest inactive bg
> (0x31,0x2e,0x39) -- highest inactive bg
> (0x78,0x3e,0x57) -- active bg
> (0xc0,0xa7,0x9a) -- inactive fg
> (0xff,0xff,0xff) -- active fg
>
> *gridColorizer :: a -> Bool -> X (String, String)
> gridColorizer _ True = return ("#00aa00", "black")
> gridColorizer _ False = return ("#333333", "#cccccc")*
>
> myGSConfig :: t -> GSConfig Window
> myGSConfig colorizer = (buildDefaultGSConfig myColorizer)
> { gs_cellheight = 30
> , gs_cellwidth = 200
> , gs_cellpadding = 6
> , gs_originFractX = 0.5
> , gs_originFractY = 0.5
> , gs_colorizer = myColorizer
> , gs_font = myGSFont
> }
>
> -- spawnSelected Redefine
> spawnSelected' :: [(String, String)] -> X ()
> spawnSelected' lst = gridselect conf lst >>= flip whenJust spawn
> where conf = def
> { gs_cellheight = 30
> , gs_cellwidth = 200
> , gs_cellpadding = 6
> , gs_originFractX = 0.5
> , gs_originFractY = 0.5
> * , gs_colorizer = gridColorizer
> * , gs_font = myGSFont
> }
>
>
> , ((mod4Mask, xK_g), goToSelected $ myGSConfig myColorizer)
> * , ((mod4Mask, xK_y), spawnSelected' myAppGrid)
> * , ((mod4Mask, xK_u), runSelectedAction (buildDefaultGSConfig gridColorizer)
> [ ("Chromium", spawnHere "chromium")
> , ("Hexchat", spawnHere "hexchat")
>
> On Sat, Aug 8, 2020 at 8:46 AM Platon Pronko <platon7pronko at gmail.com <mailto:platon7pronko at gmail.com>> wrote:
>
> Hi!
>
> Your spawnSelected' has one argument [(String, String)], but you try to invoke it with two - myAppGrid and winconfig. I'd remove winconfig argument and instead stick it into gs_colorizer field in your GSConfig constructor.
>
> Best regards,
> Platon Pronko
>
> On 2020-08-07 17:13, Dave Macias wrote:
> > Hello,
> >
> > Apologies for the repost....i had posted here: https://www.reddit.com/r/xmonad/comments/hvaug9/xagridselect_spawnselected_colorized/ but no response for some time now. So I want to try here.
> >
> > Basically, I am trying to custom colorize spawnSelected grid apps.
> > I was able to do this with goToSelected and I really like the color scheme.
> >
> > Was hoping to use the same color scheme that i use for goToSelected applied to spawnSelected.
> >
> > Any input is much appreciated!
> >
> > Stay safe.
> >
> > -Dave
> >
> > _______________________________________________
> > xmonad mailing list
> > xmonad at haskell.org <mailto:xmonad at haskell.org>
> > http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad
> >
> _______________________________________________
> xmonad mailing list
> xmonad at haskell.org <mailto:xmonad at haskell.org>
> http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad
>
More information about the xmonad
mailing list