DynamicWorkspaceOrder of a tag

Hello everyone, (I am an "awesome" convert new to xmonad and I hope this is the right place to ask this question and I am not unknowingly violating some etiquette. If so, please forgive and tell me.) I am using DynamicWorkspaceOrder and want to know the number of a workspace in this order. Basically I am looking for the number that "withNthWorkspace" would use. So given a tag, how can I get its place in the DynamicWorkspaceOrder? Alternatively how can I get a list of all the workspaces in their DynamicWorkspaceOrder? Basically I need to replace the following with something that respects DynamicWorkspaceOrder: myWorkspaces :: [WorkspaceId] myWorkspaces = ["1:main", "2:www", "3:sys"] What I am trying to achieve is to display the number of a workspace next to its name in my dmenu bar, so I know which key binding to use to get there. This would obviously be especially useful for dynamic workspaces. The key bindings are generated via (the DynamicWorkspaceOrder version of) "withNthWorkspace". An alternative might be to modify DynamicLogWithPP but I'd rather not go there if I can avoid it (and I would not know how to do it either). Thanks a lot for your help, Jonas

Hi Jonas, On Fri, Feb 08, 2013 at 10:00:04PM +0000, Jonas wrote:
Hello everyone,
(I am an "awesome" convert new to xmonad and I hope this is the right place to ask this question and I am not unknowingly violating some etiquette. If so, please forgive and tell me.)
This is the right place! Sorry for the long time with no response. The xmonad mailing list is friendly but not always the most responsive.
I am using DynamicWorkspaceOrder and want to know the number of a workspace in this order. Basically I am looking for the number that "withNthWorkspace" would use. So given a tag, how can I get its place in the DynamicWorkspaceOrder?
Alternatively how can I get a list of all the workspaces in their DynamicWorkspaceOrder?
It's useful to take a look at how withNthWorkspace is implemented: withNthWorkspace :: (String -> WindowSet -> WindowSet) -> Int -> X () withNthWorkspace job wnum = do sort <- getSortByOrder ws <- gets (map W.tag . sort . W.workspaces . windowset) case drop wnum ws of (w:_) -> windows $ job w [] -> return () The first two lines there result in a list of all the workspace tags in the order you want. First we get the appropriate sorting function, and then grab the xmonad state (with 'gets'), get the list of workspaces, sort it, and then project out the tags. Once you have this list you can easily go from tag to index using the 'findIndex' function. But given what you want to do, it may be easier to just get the sorted list of tags and then use something like 'zipWith' to combine it with index numbers. -Brent
participants (2)
-
Brent Yorgey
-
Jonas