mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 03:20:21 -07:00
Commands.hs: haddock updates
This commit is contained in:
parent
e6dcaa15c7
commit
eef80d1841
@ -3,7 +3,7 @@
|
|||||||
-- Module : XMonad.Actions.Commands
|
-- Module : XMonad.Actions.Commands
|
||||||
-- Copyright : (c) David Glasser 2007
|
-- Copyright : (c) David Glasser 2007
|
||||||
-- License : BSD3
|
-- License : BSD3
|
||||||
--
|
--
|
||||||
-- Maintainer : glasser@mit.edu
|
-- Maintainer : glasser@mit.edu
|
||||||
-- Stability : stable
|
-- Stability : stable
|
||||||
-- Portability : portable
|
-- Portability : portable
|
||||||
@ -38,44 +38,48 @@ import Data.Maybe
|
|||||||
|
|
||||||
-- $usage
|
-- $usage
|
||||||
--
|
--
|
||||||
-- To use, modify your Config.hs to:
|
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@:
|
||||||
--
|
--
|
||||||
-- > import XMonad.Actions.Commands
|
-- > import XMonad.Actions.Commands
|
||||||
--
|
--
|
||||||
-- and add a keybinding to the runCommand action:
|
-- Then add a keybinding to the runCommand action:
|
||||||
--
|
--
|
||||||
-- > , ((modMask .|. controlMask, xK_y), runCommand commands)
|
-- > , ((modMask .|. controlMask, xK_y), runCommand commands)
|
||||||
--
|
--
|
||||||
-- and define the list commands:
|
-- and define the list of commands you want to use:
|
||||||
--
|
--
|
||||||
-- > commands :: [(String, X ())]
|
-- > commands :: [(String, X ())]
|
||||||
-- > commands = defaultCommands
|
-- > commands = defaultCommands
|
||||||
--
|
--
|
||||||
-- A popup menu of internal xmonad commands will appear. You can
|
-- Whatever key you bound to will now cause a popup menu of internal
|
||||||
-- change the commands by changing the contents of the list
|
-- xmonad commands to appear. You can change the commands by
|
||||||
-- 'commands'. (If you like it enough, you may even want to get rid
|
-- changing the contents of the list 'commands'. (If you like it
|
||||||
-- of many of your other key bindings!)
|
-- enough, you may even want to get rid of many of your other key
|
||||||
|
-- bindings!)
|
||||||
-- %def commands :: [(String, X ())]
|
--
|
||||||
-- %def commands = defaultCommands
|
-- For detailed instructions on editing your key bindings, see
|
||||||
-- %import XMonad.Actions.Commands
|
-- "XMonad.Doc.Extending#Editing_key_bindings".
|
||||||
-- %keybind , ((modMask .|. controlMask, xK_y), runCommand commands)
|
|
||||||
|
|
||||||
|
-- | Create a 'Data.Map.Map' from @String@s to xmonad actions from a
|
||||||
|
-- list of pairs.
|
||||||
commandMap :: [(String, X ())] -> M.Map String (X ())
|
commandMap :: [(String, X ())] -> M.Map String (X ())
|
||||||
commandMap c = M.fromList c
|
commandMap c = M.fromList c
|
||||||
|
|
||||||
|
-- | Generate a list of commands to switch to\/send windows to workspaces.
|
||||||
workspaceCommands :: X [(String, X ())]
|
workspaceCommands :: X [(String, X ())]
|
||||||
workspaceCommands = asks (workspaces . config) >>= \spaces -> return
|
workspaceCommands = asks (workspaces . config) >>= \spaces -> return
|
||||||
[((m ++ show i), windows $ f i)
|
[((m ++ show i), windows $ f i)
|
||||||
| i <- spaces
|
| i <- spaces
|
||||||
, (f, m) <- [(view, "view"), (shift, "shift")] ]
|
, (f, m) <- [(view, "view"), (shift, "shift")] ]
|
||||||
|
|
||||||
|
-- | Generate a list of commands dealing with multiple screens.
|
||||||
screenCommands :: [(String, X ())]
|
screenCommands :: [(String, X ())]
|
||||||
screenCommands = [((m ++ show sc), screenWorkspace (fromIntegral sc) >>= flip whenJust (windows . f))
|
screenCommands = [((m ++ show sc), screenWorkspace (fromIntegral sc) >>= flip whenJust (windows . f))
|
||||||
| sc <- [0, 1]::[Int] -- TODO: adapt to screen changes
|
| sc <- [0, 1]::[Int] -- TODO: adapt to screen changes
|
||||||
, (f, m) <- [(view, "screen"), (shift, "screen-to-")]
|
, (f, m) <- [(view, "screen"), (shift, "screen-to-")]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
-- | A nice pre-defined list of commands.
|
||||||
defaultCommands :: X [(String, X ())]
|
defaultCommands :: X [(String, X ())]
|
||||||
defaultCommands = do
|
defaultCommands = do
|
||||||
wscmds <- workspaceCommands
|
wscmds <- workspaceCommands
|
||||||
@ -102,12 +106,17 @@ defaultCommands = do
|
|||||||
, ("quit-wm" , io $ exitWith ExitSuccess )
|
, ("quit-wm" , io $ exitWith ExitSuccess )
|
||||||
]
|
]
|
||||||
|
|
||||||
|
-- | Given a list of command\/action pairs, prompt the user to choose a
|
||||||
|
-- command and return the corresponding action.
|
||||||
runCommand :: [(String, X ())] -> X ()
|
runCommand :: [(String, X ())] -> X ()
|
||||||
runCommand cl = do
|
runCommand cl = do
|
||||||
let m = commandMap cl
|
let m = commandMap cl
|
||||||
choice <- dmenu (M.keys m)
|
choice <- dmenu (M.keys m)
|
||||||
fromMaybe (return ()) (M.lookup choice m)
|
fromMaybe (return ()) (M.lookup choice m)
|
||||||
|
|
||||||
|
-- | Given the name of a command from 'defaultCommands', return the
|
||||||
|
-- corresponding action (or the null action if the command is not
|
||||||
|
-- found).
|
||||||
runCommand' :: String -> X ()
|
runCommand' :: String -> X ()
|
||||||
runCommand' c = do
|
runCommand' c = do
|
||||||
m <- fmap commandMap defaultCommands
|
m <- fmap commandMap defaultCommands
|
||||||
|
Loading…
x
Reference in New Issue
Block a user