Layout switching (rather than cycling)

Hi, How can I bind certain layouts to key combinations? So rather than cycle thorugh layouts with Mod Space, I'd like Mod F1 to give me layout 1, Mod F2 to give me layout 2, etc... I've been googling for a bit, but can't find an answer. Thanks. anze phone: +1 (510) 495 2488, mobile: +1 (510) 289 9395, fax: +1 (510) 486 7149 -- "Neprijavljen student na Praktikumu je namrec nezgresljiv znak za kosmatinca, ki je prisel k nam le prezimit." [Marko Mikuz]

On Fri, Mar 28, 2008 at 2:45 PM, Anze Slosar
Hi,
How can I bind certain layouts to key combinations? So rather than cycle thorugh layouts with Mod Space, I'd like Mod F1 to give me layout 1, Mod F2 to give me layout 2, etc... I've been googling for a bit, but can't find an answer.
Thanks.
anze
Hi Anze, You can do this using the JumpToLayout message from the XMonad.Layout.LayoutCombinators extension module. For example: import XMonad hiding ( (|||) ) -- don't use the normal ||| operator import XMonad.Layout.LayoutCombinators -- use the one from LayoutCombinators instead import XMonad.Util.EZConfig -- add keybindings easily main = xmonad myConfig myConfig = defaultConfig { ... layoutHook = tall ||| Mirror tall ||| Full ... } `additionalKeysP` [ ("M-<F1>", sendMessage $ JumpToLayout "Tall") , ("M-<F2>", sendMessage $ JumpToLayout "Mirror Tall") , ("M-<F3>", sendMessage $ JumpToLayout "Full") ] tall = Tall 1 (3/100) (1/2) Untested, but that's the basic idea, hopefully that will get you going on the right track. Let us know if you've got more questions. -Brent

byorgey:
On Fri, Mar 28, 2008 at 2:45 PM, Anze Slosar <[1]anze@berkeley.edu> wrote:
Hi,
How can I bind certain layouts to key combinations? So rather than cycle thorugh layouts with Mod Space, I'd like Mod F1 to give me layout 1, Mod F2 to give me layout 2, etc... I've been googling for a bit, but can't find an answer.
Thanks.
anze
Hi Anze,
You can do this using the JumpToLayout message from the XMonad.Layout.LayoutCombinators extension module. For example:
import XMonad hiding ( (|||) ) -- don't use the normal ||| operator import XMonad.Layout.LayoutCombinators -- use the one from LayoutCombinators instead import XMonad.Util.EZConfig -- add keybindings easily
main = xmonad myConfig
myConfig = defaultConfig { ... layoutHook = tall ||| Mirror tall ||| Full ... } `additionalKeysP` [ ("M-<F1>", sendMessage $ JumpToLayout "Tall") , ("M-<F2>", sendMessage $ JumpToLayout "Mirror Tall") , ("M-<F3>", sendMessage $ JumpToLayout "Full") ]
tall = Tall 1 (3/100) (1/2)
Untested, but that's the basic idea, hopefully that will get you going on the right track. Let us know if you've got more questions.
-Brent
Thanks Brent, I added this solution to the wiki: http://haskell.org/haskellwiki/Xmonad/General_xmonad.hs_config_tips#Binding_... -- Don

Brent, Works like magic, thanks! I love xmonad! anze phone: +1 (510) 495 2488, mobile: +1 (510) 289 9395, fax: +1 (510) 486 7149 -- "Of course any comparisons between the two men are absurd. One's a bearded, long-winded Communist dictator who tolerates no dissent; the other one speaks Spanish." [/. on difference between RMS and Castro] On Fri, 28 Mar 2008, Brent Yorgey wrote:
On Fri, Mar 28, 2008 at 2:45 PM, Anze Slosar
wrote: Hi,
How can I bind certain layouts to key combinations? So rather than cycle thorugh layouts with Mod Space, I'd like Mod F1 to give me layout 1, Mod F2 to give me layout 2, etc... I've been googling for a bit, but can't find an answer.
Thanks.
anze
Hi Anze,
You can do this using the JumpToLayout message from the XMonad.Layout.LayoutCombinators extension module. For example:
import XMonad hiding ( (|||) ) -- don't use the normal ||| operator import XMonad.Layout.LayoutCombinators -- use the one from LayoutCombinators instead import XMonad.Util.EZConfig -- add keybindings easily
main = xmonad myConfig
myConfig = defaultConfig { ... layoutHook = tall ||| Mirror tall ||| Full ... } `additionalKeysP` [ ("M-<F1>", sendMessage $ JumpToLayout "Tall") , ("M-<F2>", sendMessage $ JumpToLayout "Mirror Tall") , ("M-<F3>", sendMessage $ JumpToLayout "Full") ]
tall = Tall 1 (3/100) (1/2)
Untested, but that's the basic idea, hopefully that will get you going on the right track. Let us know if you've got more questions.
-Brent
participants (3)
-
Anze Slosar
-
Brent Yorgey
-
Don Stewart