Personal tools

Xmonad/Config archive/Gwern's xmonad.hs

From HaskellWiki

< Xmonad | Config archive(Difference between revisions)
Jump to: navigation, search
(upload .5 version)
(update)
Line 1: Line 1:
 
<haskell>
 
<haskell>
import XMonad (XConfig(layoutHook, keys, modMask, focusedBorderColor,
+
{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
normalBorderColor, terminal, defaultGaps, XConfig),
+
module Main where
Layout(..))
+
import XMonad.StackSet as W (W.focusUp, W.focusDown)
+
import Data.Bits (Bits((.|.)))
  +
import Data.Map as M (M.fromList, M.union, Map())
 
import Graphics.X11
 
import Graphics.X11
  +
import XMonad (XConfig(layoutHook, keys, modMask, focusedBorderColor, normalBorderColor,
  +
terminal, defaultGaps, XConfig), X())
  +
import XMonad.Actions.Search (google, wayback, wikipedia, selectSearch, promptSearch)
 
import XMonad.Config (defaultConfig)
 
import XMonad.Config (defaultConfig)
import XMonad.Core (xmonad)
+
import XMonad.Layout (Full(..), Mirror(..), Tall(..), (|||))
import XMonad.Layouts (Full(..), Mirror(..), Tall(..), (|||))
 
import XMonad.Operations (kill, windows, sendMessage)
 
 
import XMonad.Layout.NoBorders (smartBorders)
 
import XMonad.Layout.NoBorders (smartBorders)
import XMonad.Layout.Tabbed (tabbed, defaultTConf, shrinkText)
+
import XMonad.Main (xmonad)
import XMonad.Layout.WindowNavigation (Navigate(Go), Direction(..))
+
import XMonad.Operations (kill, windows)
import XMonad.Prompt (XPPosition(Top),
+
import XMonad.Prompt (XPPosition(Top), XPConfig(historySize, height, position,
XPConfig(historySize, height, position, promptBorderWidth, fgColor, bgColor, font),
+
promptBorderWidth, fgColor, bgColor, font), defaultXPConfig)
defaultXPConfig)
 
 
import XMonad.Prompt.Shell (shellPrompt, prompt, safePrompt)
 
import XMonad.Prompt.Shell (shellPrompt, prompt, safePrompt)
  +
import XMonad.StackSet as W (W.focusUp, W.focusDown)
 
import XMonad.Util.Run (safeSpawn, unsafeSpawn, runInTerm)
 
import XMonad.Util.Run (safeSpawn, unsafeSpawn, runInTerm)
 
import XMonad.Util.XSelection (safePromptSelection)
 
import XMonad.Util.XSelection (safePromptSelection)
import Data.Map as M (M.fromList, M.union)
+
import XMonad.Actions.WindowGo (className, title, runOrRaise, raiseMaybe, (=?))
import Data.Bits (Bits((.|.)))
 
   
 
main :: IO ()
 
main :: IO ()
main = xmonad $ gwernConfig
+
main = xmonad myConfig
   
gwernConfig :: XConfig
+
{- Begin custom bindings.
gwernConfig = defaultConfig
+
these add a need for: urxvt, Firefox, and Emacs -}
{ defaultGaps = [(0,0,0,0)]
 
, terminal = "urxvtc"
 
, normalBorderColor = "#dddddd"
 
, focusedBorderColor = "#ff0000"
 
, modMask = mod4Mask
 
, keys = \c -> mykeys c `M.union` keys defaultConfig c
 
, layoutHook = Layout (smartBorders (tiled ||| Mirror tiled ||| Full ||| tabbed shrinkText defaultTConf)) }
 
where
 
tiled = Tall 1 0.03 0.5
 
   
greenXPConfig :: XPConfig
+
-- config :: XConfig (XMonad.Layout.LayoutModifier.ModifiedLayout XMonad.Layout.NoBorders.SmartBorder
greenXPConfig = defaultXPConfig { font = "9x15bold,xft:Bitstream Vera Sans Mono"
+
-- (XMonad.Layout.Choose Full (XMonad.Layout.Choose Tall (Mirror Tall))))
  +
myConfig = defaultConfig
  +
{ defaultGaps = [(0,0,0,0)]
  +
, terminal = "urxvtc"
  +
, normalBorderColor = "grey"
  +
, focusedBorderColor = "red"
  +
, modMask = mod4Mask
  +
, keys = \c -> myKeys c `M.union` keys defaultConfig c
  +
, layoutHook = smartBorders (Full ||| tiled ||| Mirror tiled)
  +
}
  +
  +
tiled :: Tall a
  +
tiled = Tall 1 0.03 0.5
  +
  +
greenXPConfig :: XPConfig
  +
greenXPConfig = defaultXPConfig { font = "9x15bold,xft:Bitstream Vera Sans Mono"
 
, bgColor = "black"
 
, bgColor = "black"
 
, fgColor = "green"
 
, fgColor = "green"
Line 32: Line 36:
 
, historySize = 256 }
 
, historySize = 256 }
   
mykeys (XConfig {modMask = modm}) = M.fromList $
 
[ ((modm .|. shiftMask, xK_p ), shellPrompt greenXPConfig)
 
, ((modm, xK_k ), kill ) -- %! Move focus to the previous WindowSet
 
, ((modm, xK_n ), windows W.focusUp)
 
, ((modm, xK_p ), windows W.focusDown)
 
   
, ((modm .|. shiftMask, xK_b ), safePromptSelection "firefox")
+
myKeys :: XConfig t -> M.Map (KeyMask, KeySym) (X ())
, ((modm .|. shiftMask, xK_c ), prompt ((terminal gwernConfig) ++ " -e") greenXPConfig)
+
myKeys (XConfig {modMask = modm}) =
, ((modm .|. shiftMask, xK_d ), runInTerm "elinks")
+
M.fromList $
, ((modm .|. shiftMask, xK_e ), prompt "emacsclient -a emacs" greenXPConfig)
+
[ ((modm .|. shiftMask, xK_p ), shellPrompt greenXPConfig)
, ((modm .|. shiftMask, xK_g ), safePromptSelection "google")
+
, ((modm, xK_k ), kill ) -- %! Move focus to the previous WindowSet
, ((modm .|. shiftMask, xK_t ), safePromptSelection "wikipedia")
+
, ((modm, xK_n ), windows W.focusUp)
, ((modm .|. shiftMask, xK_y ), safePromptSelection "wayback")
+
, ((modm, xK_p ), windows W.focusDown)
, ((modm, xK_Print ), unsafeSpawn "import -quality 90 -window root png:$HOME/xwd-$(date +%s)$$.png")
+
, ((modm, xK_b ), safePrompt "firefox" greenXPConfig)
+
, ((modm .|. shiftMask, xK_b ), safePromptSelection ff)
, ((modm, xK_c ), unsafeSpawn (terminal gwernConfig))
+
, ((modm .|. shiftMask, xK_c ), prompt (term ++ " -e") greenXPConfig)
, ((modm, xK_d ), safeSpawn "firefox" "")
+
, ((modm .|. shiftMask, xK_d ), runInTerm "" "elinks")
, ((modm, xK_e ), unsafeSpawn "emacs")
+
, ((modm .|. shiftMask, xK_e ), prompt "emacsclient -a emacs" greenXPConfig)
, ((modm, xK_g ), safePrompt "google" greenXPConfig)
+
, ((modm .|. shiftMask, xK_g ), selectSearch ff google)
, ((modm, xK_t ), safePrompt "wikipedia" greenXPConfig)
+
, ((modm .|. shiftMask, xK_t ), selectSearch ff wikipedia)
, ((modm, xK_y ), safePrompt "wayback" greenXPConfig)
+
, ((modm .|. shiftMask, xK_y ), selectSearch ff wayback)
, ((modm, xK_i ), runInTerm "sh -c 'screen -r irssi'")
+
, ((modm, xK_Print ), unsafeSpawn "import -quality 90 -window root png:$HOME/xwd-$(date +%s)$$.png")
, ((modm, xK_m ), runInTerm "sh -c 'mutt'")
+
, ((modm, xK_b ), safePrompt ff greenXPConfig)
, ((modm, xK_r ), runInTerm "sh -c 'screen -r rtorrent'")
+
, ((modm, xK_c ), unsafeSpawn term)
  +
, ((modm, xK_d ), safeSpawn ff "")
  +
, ((modm, xK_e ), unsafeSpawn "emacs")
  +
, ((modm, xK_g ), promptSearch greenXPConfig ff google)
  +
, ((modm, xK_t ), promptSearch greenXPConfig ff wikipedia)
  +
, ((modm, xK_y ), promptSearch greenXPConfig ff wayback)
  +
, ((modm, xK_i ), raiseMaybe (runInTerm "-title irssi" "sh -c 'screen -r irssi'") (title =? "irssi"))
  +
, ((modm, xK_m ), raiseMaybe (runInTerm "-title mutt" "sh -c 'mutt'") (title =? "mutt"))
  +
, ((modm, xK_r ), raiseMaybe (runInTerm "-title rtorrent" "sh -c 'screen -r rtorrent'") (title =? "rtorrent"))
  +
, ((modm, xK_a ), runOrRaise "firefox" (className =? "Firefox-bin"))
  +
-- Extension-provided key bindings
  +
]
   
-- Extension-provided key bindings
+
ff, term :: String
, ((modm, xK_Right), sendMessage $ Go R)
+
ff = "firefox"
, ((modm, xK_Left), sendMessage $ Go L)
+
term = "urxvtc"
, ((modm, xK_Up), sendMessage $ Go U)
 
, ((modm, xK_Down), sendMessage $ Go D)
 
]
 
 
</haskell>
 
</haskell>
[[Category: XMonad configuration]]
 

Revision as of 05:30, 7 February 2008

{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
module Main where
 
import Data.Bits (Bits((.|.)))
import Data.Map as M (M.fromList, M.union, Map())
import Graphics.X11
import XMonad (XConfig(layoutHook, keys, modMask, focusedBorderColor, normalBorderColor,
                                 terminal, defaultGaps, XConfig), X())
import XMonad.Actions.Search (google, wayback, wikipedia, selectSearch, promptSearch)
import XMonad.Config (defaultConfig)
import XMonad.Layout (Full(..), Mirror(..), Tall(..), (|||))
import XMonad.Layout.NoBorders (smartBorders)
import XMonad.Main (xmonad)
import XMonad.Operations (kill, windows)
import XMonad.Prompt (XPPosition(Top), XPConfig(historySize, height, position,
                      promptBorderWidth, fgColor, bgColor, font), defaultXPConfig)
import XMonad.Prompt.Shell (shellPrompt, prompt, safePrompt)
import XMonad.StackSet as W (W.focusUp, W.focusDown)
import XMonad.Util.Run (safeSpawn, unsafeSpawn, runInTerm)
import XMonad.Util.XSelection (safePromptSelection)
import XMonad.Actions.WindowGo (className, title, runOrRaise, raiseMaybe, (=?))
 
main :: IO ()
main = xmonad myConfig
 
{- Begin custom bindings.
    these add a need for: urxvt, Firefox, and Emacs -}
 
-- config :: XConfig (XMonad.Layout.LayoutModifier.ModifiedLayout XMonad.Layout.NoBorders.SmartBorder
--                                           (XMonad.Layout.Choose Full (XMonad.Layout.Choose Tall (Mirror Tall))))
myConfig = defaultConfig
    { defaultGaps = [(0,0,0,0)]
    , terminal = "urxvtc"
    , normalBorderColor  = "grey"
    , focusedBorderColor = "red"
    , modMask = mod4Mask
    , keys = \c -> myKeys c `M.union` keys defaultConfig c
    , layoutHook = smartBorders (Full ||| tiled ||| Mirror tiled)
    }
 
tiled :: Tall a
tiled = Tall 1 0.03 0.5
 
greenXPConfig :: XPConfig
greenXPConfig = defaultXPConfig { font        = "9x15bold,xft:Bitstream Vera Sans Mono"
                                    , bgColor     = "black"
                                    , fgColor     = "green"
                                    , promptBorderWidth = 0
                                    , position    = Top
                                    , height      = 16
                                    , historySize = 256 }
 
 
myKeys :: XConfig t -> M.Map (KeyMask, KeySym) (X ())
myKeys (XConfig {modMask = modm}) =
    M.fromList $
          [ ((modm .|. shiftMask, xK_p     ), shellPrompt greenXPConfig)
          , ((modm,               xK_k     ), kill  ) -- %! Move focus to the previous WindowSet
          , ((modm,               xK_n     ), windows W.focusUp)
          , ((modm,               xK_p     ), windows W.focusDown)
 
          , ((modm .|. shiftMask, xK_b     ), safePromptSelection ff)
          , ((modm .|. shiftMask, xK_c     ), prompt (term ++ " -e") greenXPConfig)
          , ((modm .|. shiftMask, xK_d     ), runInTerm "" "elinks")
          , ((modm .|. shiftMask, xK_e     ), prompt "emacsclient -a emacs" greenXPConfig)
          , ((modm .|. shiftMask, xK_g     ), selectSearch ff google)
          , ((modm .|. shiftMask, xK_t     ), selectSearch ff wikipedia)
          , ((modm .|. shiftMask, xK_y     ), selectSearch ff wayback)
          , ((modm,               xK_Print ), unsafeSpawn "import -quality 90 -window root png:$HOME/xwd-$(date +%s)$$.png")
          , ((modm,               xK_b     ), safePrompt ff greenXPConfig)
          , ((modm,               xK_c     ), unsafeSpawn term)
          , ((modm,               xK_d     ), safeSpawn ff "")
          , ((modm,               xK_e     ), unsafeSpawn  "emacs")
          , ((modm,               xK_g     ), promptSearch greenXPConfig ff google)
          , ((modm,               xK_t     ), promptSearch greenXPConfig ff wikipedia)
          , ((modm,               xK_y     ), promptSearch greenXPConfig ff wayback)
          , ((modm, xK_i                   ), raiseMaybe (runInTerm "-title irssi" "sh -c 'screen -r irssi'") (title =? "irssi"))
          , ((modm, xK_m                   ), raiseMaybe (runInTerm "-title mutt"  "sh -c 'mutt'") (title =? "mutt"))
          , ((modm, xK_r                   ), raiseMaybe (runInTerm "-title rtorrent" "sh -c 'screen -r rtorrent'") (title =? "rtorrent"))
          , ((modm, xK_a                   ), runOrRaise "firefox" (className =? "Firefox-bin"))
          -- Extension-provided key bindings
          ]
 
ff, term :: String
ff = "firefox"
term = "urxvtc"