Skip to content

Instantly share code, notes, and snippets.

@ghorn
Created March 27, 2014 00:01
Show Gist options
  • Save ghorn/9796721 to your computer and use it in GitHub Desktop.
Save ghorn/9796721 to your computer and use it in GitHub Desktop.
ghorn@adler:~$ cat .xmonad/xmonad.hs
{-# OPTIONS_GHC -Wall #-}
module Main ( main ) where
import XMonad
import qualified XMonad.StackSet as SS
import XMonad.Util.EZConfig ( additionalKeys )
import XMonad.Prompt.Shell ( shellPrompt )
import XMonad.Prompt ( defaultXPConfig )
import qualified XMonad.Actions.Volume as Vol
import XMonad.Util.Dzen ( (>=>), dzenConfig, onCurr, font, addArgs, center )
import XMonad.Hooks.DynamicLog ( xmobar )
import XMonad.Actions.PhysicalScreens ( viewScreen, sendToScreen )
main :: IO ()
main = xmonad =<< xmobar myConfig
myConfig :: XConfig (Choose Tall (Choose (Mirror Tall) Full))
myConfig =
defaultConfig { modMask = mod4Mask
, terminal = "urxvt"
, workspaces = wsNames
} `additionalKeys` myKeys
myKeys :: [((ButtonMask, KeySym), X ())]
myKeys = [ ((mod1Mask, xK_space), shellPrompt defaultXPConfig) -- alt-space launcher
, ((mod4Mask, xK_Page_Down), raiseVol)
, ((mod4Mask, xK_Page_Up), lowerVol)
, ((mod4Mask .|. shiftMask, xK_Page_Down), toggleMute)
--take a screenshot of entire display
, ((mod4Mask , xK_Print ), spawn "scrot screen_%Y-%m-%d-%H-%M-%S.png -d 1")
--take a screenshot of focused window
, ((mod4Mask .|. controlMask, xK_Print ), spawn "scrot window_%Y-%m-%d-%H-%M-%S.png -d 1-u")
] ++ wsKeys ++ multiScreenKeys
where
raiseVol :: X ()
raiseVol = Vol.setMute False >> Vol.lowerVolume 2 >>= alertD
lowerVol :: X ()
lowerVol = Vol.setMute False >> Vol.raiseVolume 2 >>= alertD
toggleMute :: X ()
toggleMute = Vol.toggleMute >>= alertMute
where
alertMute True = dzenConfig centered "(0)"
alertMute False = Vol.getVolume >>= alertD
alertD :: Double -> X ()
alertD = dzenConfig centered . show . (round :: Double -> Int)
centered :: (Int, [String]) -> X (Int, [String])
centered =
onCurr (center 150 66)
>=> font "-*-helvetica-*-r-*-*-64-*-*-*-*-*-*-*"
>=> addArgs ["-fg", "#80c0ff"]
>=> addArgs ["-bg", "#000040"]
multiScreenKeys :: [((KeyMask, KeySym), X ())]
multiScreenKeys =
[((mod4Mask .|. mask, key), f sc)
| (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
, (f, mask) <- [(viewScreen, 0), (sendToScreen, shiftMask)]]
wsKeys :: [((KeyMask, KeySym), X ())]
wsNames :: [String]
(wsKeys, wsNames) = (concatMap addDesk newWs, map snd newWs)
where
newWs :: [(KeySym, String)]
newWs = keyWs ++ fkeyWs ++ chatMailWs
addDesk :: (t, WorkspaceId) -> [((KeyMask, t), X ())]
addDesk (fkey, name) =
[ ((mod4Mask, fkey), windows $ SS.greedyView name)
, ((mod4Mask .|. shiftMask, fkey), windows $ SS.shift name)
]
keyWs :: [(KeySym, String)]
keyWs = zip [xK_1,xK_2,xK_3,xK_4,xK_5,xK_6,xK_7,xK_8,xK_9,xK_0] $ map show [(1::Int)..]
fkeyWs :: [(KeySym, String)]
fkeyWs = zip [xK_F1,xK_F2,xK_F3,xK_F4,xK_F5,xK_F6,xK_F7,xK_F8,xK_F9,xK_F10,xK_F11,xK_F12] $
map (('F':) . show) [(1::Int)..]
chatMailWs :: [(KeySym, String)]
chatMailWs = [ (xK_minus, "chat")
, (xK_equal, "irc")
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment