[xmonad] Beginner problem with XMonad and appending to a list rather than prefixing
Trey Blancher
trey at blancher.net
Thu May 7 12:23:41 UTC 2015
XMonad Community,
After all this time, I'm still just a beginner with XMonad. I only know Haskell
through XMonad, and I wouldn't say I know it well. I learn just enough to get
my XMonad configuration to work, then don't return to it for a while.
I'm trying to make a minor change to my XMonad file, where a new
workspace is appended to the list rather than prefixed like I have now,
but I can't seem to figure out the code to do it. Here's the relevant
details of what I have:
import XMonad.Actions.DynamicWorkspaces as DW
import qualified XMonad.Util.ExtensibleState as XS
import Control.Applicative
filterWorkspaces :: [WorkspaceId] -> [WindowSpace] -> [WindowSpace]
filterWorkspaces ws = filter (\(W.Workspace tag _ _) -> tag `elem` ws)
-- xScreen are the type classes which hold the workspace name lists
newtype LeftScreen = LeftScreen {getLeftScreen :: [WorkspaceId]} deriving (Typeable,Read,Show)
instance ExtensionClass LeftScreen where
initialValue = LeftScreen []
extensionType = PersistentExtension
newtype RightScreen = RightScreen {getRightScreen :: [WorkspaceId]} deriving (Typeable,Read,Show)
instance ExtensionClass RightScreen where
initialValue = RightScreen []
extensionType = PersistentExtension
-- snip --
main = do
dbus <- D.connectSession
getWellKnownName dbus;
xmonad $ xfceConfig {
workspaces = ["sh","sb","of","wc","ws","wb","cht"]
, terminal = "urxvtc"
-- Goodbye, my sweet, sweet, sloppy focus
, focusFollowsMouse = False
, manageHook = manageDocks <+> myManageHook -- <+> manageHook defaultConfig
, layoutHook = avoidStruts $ onWorkspace "gimp" gimp $ layoutH
, logHook = dynamicLogWithPP (ppL dbus)
>> dynamicLogWithPP (ppR dbus)
>> fadeHook
, borderWidth = 1
, normalBorderColor = "#333333"
, focusedBorderColor = "#CCCC00"
, modMask = winKey
, startupHook = setWMName "LG3D"
} `additionalKeys` myKeys
myKeys = [
-- snip
-- Here's what I want to change
, ((winKey , xK_m) ,DW.withWorkspace myXPConfigNew $ \wk -> do
sc <- screenBy 0
if sc == 0
then XS.modifyf $ LeftScreen . (wk :) . getLeftScreen -- prefix left list with new workspace
--then XS.modify $ LeftScreen . getLeftScreen ++[wk] -- My first attempt at appending the workspace
else XS.modify $ RightScreen . (wk :) . getRightScreen -- prefix right list with new workspace
--else XS.modify $ RightScreen . (wk ++) . getRightScreen -- another attempt
windows $ W.view wk)
Normally I'd ask on #xmonad at irc.freenode.net, but I haven't had time to get on
there. I'm sure this demonstrates my lack of knowledge of XMonad and Haskell in
general, hopefully you can help.
Thanks in advance,
Trey Blancher
trey at blancher.net
More information about the xmonad
mailing list