mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -07:00
Essentially, whenever the tutorial actually has decent material on the subject matter. The replacement is roughly done as follows: - logHook → tutorial - keybindings → tutorial, as this is thoroughly covered - manageHook → tutorial + X.D.Extending, as the manageHook stuff the tutorial talks about is a little bit of an afterthought. - X.D.Extending (on its own) → tutorial + X.D.Extending - layoutHook → tutorial + X.D.Extending, as the tutorial, while talking about layouts, doesn't necessarily have a huge focus there. - mouse bindings → leave this alone, as the tutorial does not at all talk about them.
50 lines
1.8 KiB
Haskell
50 lines
1.8 KiB
Haskell
-----------------------------------------------------------------------------
|
|
-- |
|
|
-- Module : XMonad.Actions.PerWorkspaceKeys
|
|
-- Description : Define key-bindings on per-workspace basis.
|
|
-- Copyright : (c) Roman Cheplyaka, 2008
|
|
-- License : BSD3-style (see LICENSE)
|
|
--
|
|
-- Maintainer : Roman Cheplyaka <roma@ro-che.info>
|
|
-- Stability : unstable
|
|
-- Portability : unportable
|
|
--
|
|
-- Define key-bindings on per-workspace basis.
|
|
--
|
|
-----------------------------------------------------------------------------
|
|
|
|
module XMonad.Actions.PerWorkspaceKeys (
|
|
-- * Usage
|
|
-- $usage
|
|
chooseAction,
|
|
bindOn
|
|
) where
|
|
|
|
import XMonad
|
|
import XMonad.StackSet as S
|
|
|
|
-- $usage
|
|
--
|
|
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@:
|
|
--
|
|
-- > import XMonad.Actions.PerWorkspaceKeys
|
|
--
|
|
-- > ,((0, xK_F2), bindOn [("1", spawn "rxvt"), ("2", spawn "xeyes"), ("", spawn "xmessage hello")])
|
|
--
|
|
-- For detailed instructions on editing your key bindings, see
|
|
-- <https://xmonad.org/TUTORIAL.html#customizing-xmonad the tutorial>.
|
|
|
|
-- | Uses supplied function to decide which action to run depending on current workspace name.
|
|
chooseAction :: (String->X()) -> X()
|
|
chooseAction f = withWindowSet (f . S.currentTag)
|
|
|
|
-- | If current workspace is listed, run appropriate action (only the first match counts!)
|
|
-- If it isn't listed, then run default action (marked with empty string, \"\"), or do nothing if default isn't supplied.
|
|
bindOn :: [(String, X())] -> X()
|
|
bindOn bindings = chooseAction chooser where
|
|
chooser ws = case lookup ws bindings of
|
|
Just action -> action
|
|
Nothing -> case lookup "" bindings of
|
|
Just action -> action
|
|
Nothing -> return ()
|