xmonad / xmonad-contrib

Contributed modules for xmonad
https://xmonad.org
BSD 3-Clause "New" or "Revised" License
589 stars 274 forks source link

Add SPStorage to exports of XMonad.Util.DynamicScratchpads #662

Closed kentookura closed 2 years ago

kentookura commented 2 years ago

Description

Allow the user of DynamicScratchpads to access the current DynamicScratchpads state.

Checklist

TheMC47 commented 2 years ago

Even though I don't use the module, I don't really like exposing internals unless there's a very good reason that we should. Do you have an example?

kentookura commented 2 years ago

I use the module like so:

dynamicPadKeys :: [((KeyMask, KeySym), X ())]
dynamicPadKeys = map spawnSP keySyms ++ map makeSP keySyms
 where
  spawnSP x =
    ((mod4Mask .|. mod1Mask, stringToKeysym x), spawnDynamicSP x)
  makeSP x =
    ( (mod4Mask .|. mod1Mask .|. shiftMask, stringToKeysym x)
    , withFocused . makeDynamicSP $ x
    )
  keySyms = tail $ splitOn "" "abcdefghijklmnonqprstuvwxyz"

I would like to use a logHook to keep track of which keys are bound to which windows. Exposing SPStorage would allow for this functionality.

geekosaur commented 2 years ago

I was thinking along the lines of https://hackage.haskell.org/package/xmonad-contrib-0.17.0/docs/XMonad-Util-Loggers-NamedScratchpad.html modified for dynamic scratchpads; I don't think it can do so directly at present because it gets too much information from the NamedScratchpad data structure.

kentookura commented 2 years ago

I am willing to work on this. This is my first time contributing to any open source software, so I might need some guidance. Should I add this functionality to the existing logger module or should I create a new Loggers.DynamicScratchpad module?

geekosaur commented 2 years ago

I'd probably add it to the existing one by refactoring the common parts and then implementing the DynamicScratchpads part on top of SPStorage and the existing part on top of NamedScratchpad.

geekosaur commented 2 years ago

Hm. Anyone know why the failed CI run would be failing to install hlint?

slotThe commented 2 years ago

This may or may not be feature creep, but in the interest of roping you into contributing a bit more[^1], here's a thought.

I noticed that the existence of X.U.DynamicScratchpads may not be necessary at all; this could just be copied over to NamedScratchpads. Would you be interested in doing this as well? If not, that's totally okay, of course!

[^1]: Evil, I know :)

liskin commented 2 years ago

Hm. Anyone know why the failed CI run would be failing to install hlint?

https://github.com/ndmitchell/hlint/issues/1326

kentookura commented 2 years ago

Sure, I'll give it a shot

slotThe commented 2 years ago

@kentookura any updates?