Re: [xmonad] Strange workspace switching bug in my config

Leo Alekseyev [2012.05.15 1049 -0400]:
On Tue, May 15, 2012 at 7:20 AM, Norbert Zeh
wrote: wagnerdm@seas.upenn.edu [2012.05.14 2219 -0400]:
Quoting Leo Alekseyev
: On Sun, May 13, 2012 at 8:45 AM, Norbert Zeh
wrote: myWorkspaces = ["1:terminals", "2:emacs", "3:web", "4", "5", "6", "7","8","9","0"] ++ map (\x -> show x ++ "SCR") ([1..9]++[0]) .....
zeroSub 0 = 10 zeroSub x = x
jumpToMain = gets windowset >>= \W.StackSet { W.current = W.Screen { W.workspace = w } } -> withNthWorkspace W.greedyView (-1+(zeroSub $ read [head(W.tag w)])) jumpToScratch = gets windowset >>= \W.StackSet { W.current = W.Screen { W.workspace = w } } -> withNthWorkspace W.greedyView (9+(zeroSub $ read [head(W.tag w)]))
The math here looks all wrong, and I'm surprised that it worked at all before.
The math looks fine to me, and in fact your suggestion:
What you want, I think, is the following:
jumpToMain = gets (W.tag . W.workspace . W.current . windowset) >>= W.greedyView . toMain where toMain ws = [head ws]
jumpToScratch = gets (W.tag . W.workspace . W.current . windowset) >>= W.greedyView . toScratch where toScratch ws | length ws == 1 = ws ++ "SCR" | otherwise = ws
is the one that looks dodgy to me. Notice that his main workspace names are things like "3:web", but the SCR-version is just "3SCR"! In fact, I would humbly suggest that this paragraph:
Oops. I overlooked that the primary workspaces were not just numbered. My bad. I still don't get the math in the original code snippet. zeroSub has an effect only when its argument is 0. So, for any starting workspace except "0" or "0SCR", say its number is x, the above code goes to workspace x-1 or x+9. It should, however, go to workspace x-10 or x+10 and that conditionally on whether the main/scratch workspace is already visible. What is it I don't understand here?
My original understanding was this: I have an array of workspaces like so: [1, 2, ...9, 0, 1SCR, 2SCR, ... 0SCR]
When I want to go from e.g. 2 to 2SCR, I want element 11 in this 0-indexed array. So, I get the head of the tag, I assume /read/ converts it to an integer, and I add 9 to it, and hope that withNthWorkspace on the 11th array element will do the right thing. By that logic, to go from 2SCR back to 2, I need to subtract 11 to get element 1 of the array. However, when I originally wrote that code, this didn't work right, and I put in random numbers until for some reason putting in 1 worked. (Yes, programming by coincidence and all.)
Oh man, sleep deprivation is really taking its toll it seems. Of course you're right and the math now looks perfectly fine to me. Now I'm just as stumped as you that this does not work. Cheers, Norbert
participants (1)
-
Norbert Zeh