Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

User state in Xmonad

Tags:

xmonad

Is it possible to have a user state in Xmonad?

I'm using global variables right now, but I wonder if there's a proper way to do it within Xmonad. (Eg: in parsec, there's a user state, so you would use Parser TYPE ... where TYPE is the type of the user state and is queryable with getState, putState, and modifyState.)

like image 824
Rahul Manne Avatar asked Jan 27 '26 13:01

Rahul Manne


1 Answers

Layout states in Xmonad can be specified/modified in the config.hs module, but Xmonad has also got extensible states that you can implement. I would recommend you look at both. The docs on the Haskell Extensible States lists the module as 'unstable' but i think it's a fair while since that documentation was updated (about three years?)

The [sample] code looks something like this:

 {-# LANGUAGE DeriveDataTypeable #-}
import qualified XMonad.Util.ExtensibleState as XS

data ListStorage = ListStorage [Integer] deriving Typeable
instance ExtensionClass ListStorage where
initialValue = ListStorage []

.. XS.put (ListStorage [23,42])

 (e.g.)  put :: ExtensionClass a => a -> X ()
like image 154
Rachel Gallen Avatar answered Jan 30 '26 02:01

Rachel Gallen