-- Dä ä kefft. xmonad.hs
--
-- imports
import XMonad
import XMonad.Hooks.DynamicLog
import Data.Monoid
import XMonad.Util.EZConfig
import XMonad.Util.Cursor
import XMonad.Hooks.SetWMName
import XMonad.Actions.FloatSnap
--import XMonad.Actions.FloatKeys
import XMonad.Actions.FlexibleManipulate as Flex
import XMonad.Layout.ResizableTile
import XMonad.Layout.Spacing
import XMonad.Layout.Renamed
import XMonad.Layout.NoBorders
import XMonad.Layout.MultiToggle
import XMonad.Layout.MultiToggle.Instances
import System.Exit
import qualified XMonad.StackSet as W
import qualified Data.Map as M
-- Mina
import XMonad.Actions.GridSelect
-- preferred applications
-- shortcuts
myTerm = "mate-terminal"
myTmux = "~/bin/tmuxcmd"
myBrowser = "firefox"
myMail = "mimeo http://mail.google.com"
myWpChgr = "~/bin/wpchgr.pl"
myRandWp = "wpfl=$(find ~/img/wallpapers/ -type f|sort -R|head -1);feh --bg-scale --no-fehbg $wpfl;echo $wpfl > /tmp/.randwp"
mySkype = "/usr/bin/skype"
myPentaFlashOut = "~/bin/pentadactyt fpo"
myPentaFlashIn = "~/bin/pentadactyt fpi"
myLock = "xautolock -locknow"
myScreenFull = "scrot /tmp/screenshot_%H%M%S_%Y%m%d.png"
myScrShot = "sleep 0.2; scrot -s -b /tmp/screen%H%M%S.png"
myMPDPlay="mpc toggle"
myMPDNext="mpc next"
myMPDPrev="mpc prev"
myVolMute="ponymix toggle"
myVolUp="ponymix increase 5"
myVolDown="ponymix decrease 5"
myVolChange="ponymix list-profiles|grep active|grep iec && ponymix set-profile output:analog-surround-71+input:analog-stereo || ponymix set-profile output:iec958-stereo+input:analog-stereo"
myDmenu="~/bin/dmenu_ru"
myRecomp="xmonad --recompile; xmonad --restart; notify-send 'xmonad recompiled'"
myRest="/usr/bin/xmonad --restart; notify-send 'xmonad restarted'"
-- myStream="mpg123 http://ladybug:8000"
-- get focus on mouse
myFocusFollowsMouse :: Bool
myFocusFollowsMouse = True
-- border
myBorderWidth = 3
-- my metas
myModMask = mod1Mask
-- my workspaces
myWorkspaces = ["web","code","im","media","work","vm","7","8","9"]
-- border colors
--myNormalBorderColor = "#707070"
myNormalBorderColor = "#1c1d1f"
myFocusedBorderColor = "#8787af"
myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
[ ((mod1Mask , xK_Return ), spawn $ XMonad.terminal conf)
, ((mod1Mask .|. shiftMask, xK_c ), kill)
, ((mod1Mask , xK_space ), sendMessage NextLayout)
, ((mod1Mask .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf)
, ((modMask , xK_n ), refresh)
, ((mod1Mask , xK_Tab ), windows W.focusDown)
, ((mod1Mask , xK_j ), windows W.focusDown)
, ((mod1Mask , xK_k ), windows W.focusUp)
, ((mod1Mask , xK_m ), windows W.focusMaster)
, ((mod1Mask .|. shiftMask, xK_Return ), windows W.swapMaster)
, ((mod1Mask .|. shiftMask, xK_j ), windows W.swapDown)
, ((mod1Mask .|. shiftMask, xK_k ), windows W.swapUp)
, ((mod1Mask , xK_g ), goToSelected defaultGSConfig)
, ((mod1Mask , xK_h ), sendMessage Shrink)
, ((mod1Mask , xK_l ), sendMessage Expand)
, ((mod1Mask .|. shiftMask, xK_h ), sendMessage MirrorShrink)
, ((mod1Mask .|. shiftMask, xK_l ), sendMessage MirrorExpand)
, ((mod1Mask , xK_t ), withFocused $ windows . W.sink)
, ((mod1Mask , xK_i ), sendMessage (IncMasterN 1))
, ((mod1Mask , xK_d ), sendMessage (IncMasterN (-1)))
, ((mod1Mask .|. shiftMask, xK_q ), io (exitWith ExitSuccess))
, ((mod1Mask , xK_p ), spawn "dmenu_ru")
, ((mod1Mask , xK_q ), spawn "xmonad --recompile; xmonad --restart")
, ((mod4Mask , xK_p ), spawn "ncmpcpp toggle")
, ((mod4Mask , xK_Up ), spawn "amixer -q set Master 100dB+")
, ((mod4Mask , xK_Down ), spawn "amixer -q set Master toggle")
, ((mod4Mask , xK_Left ), spawn "ncmpcpp prev")
, ((mod4Mask , xK_Right ), spawn "ncmpcpp next")
, ((mod4Mask , xK_x ), spawn "urxvtc -e tmux attach")
, ((mod1Mask , xK_Print ), spawn "scrot -e 'mv $f ~/scrots'")
]
++
[((m .|. mod1Mask, k), windows $ f i)
| (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
, (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
++
[((m .|. mod1Mask, key), screenWorkspace sc >>= flip whenJust (windows . f))
| (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
, (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $
[ ((mod1Mask, button1), (\w -> focus w >> mouseMoveWindow w
>> windows W.shiftMaster))
, ((mod1Mask, button2), (\w -> focus w >> windows W.shiftMaster))
, ((mod1Mask, button3), (\w -> focus w >> mouseResizeWindow w
>> windows W.shiftMaster))
]
--layouts
myLayout = smartBorders
$ fulltoggle
$ tile ||| mtile ||| full
where
-- tiling profiles
rt = spacing 1 $ ResizableTall nmaster delta ratio []
tile = renamed [Replace " TILE "] $ smartBorders rt
mtile = renamed [Replace " MTILE "] $ smartBorders $ Mirror rt
full = renamed [Replace " FULL "] $ noBorders Full
fulltoggle = mkToggle (NOBORDERS ?? FULL ?? EOT)
-- default #windows in master
nmaster = 1
-- proportion size of master
ratio = 6/10
-- incrementation on resizing
delta = 2/100
--rules
myManageHook = composeAll
[ className =? "MPlayer" --> doShift "media"
, className =? "MPlayer" --> doFloat
, className =? "Gimp" --> doShift "media"
-- trying gimp without floating
, className =? "Gimp" --> doFloat
, className =? "VirtualBox" --> doShift "vm"
, className =? "VirtualBox" --> doFloat
-- , className =? "Skype" --> doFloat
, className =? "Skype" --> doShift "im"
, className =? "Xfce4-notifyd" --> doIgnore
, className =? "Steam" --> doShift "media"
-- , className =? "Steam" --> doFloat
, className =? "hl2_linux" --> doShift "media"
, className =? "hl2_linux" --> doFloat
, className =? "stalonetray" --> doIgnore
, resource =? "desktop_window" --> doIgnore
, resource =? "kdesktop" --> doIgnore ]
-- event handling
myEventHook = mempty
-- statusbar / logging
myLogHook = return ()
-- startup
myStartupHook = do
setWMName "LG3D"
setDefaultCursor xC_left_ptr
-- launch xmobar
myBar = "/usr/bin/xmobar"
-- get icon function
getIcon s = "<icon="++icondir++s++".xbm"++"/> "
where icondir = "/home/simon/.icons/st/"
--custom PP
myPP = xmobarPP {
ppCurrent = \d -> xmobarColor "#87afd7" "" . pad $ (getIcon d) ++ d
, ppHidden = \d -> xmobarColor "#808080" "" . pad $ (getIcon d) ++ d
-- , ppHiddenNoWindows = xmobarColor "#707070" ""
, ppVisible = \d -> xmobarColor "#808080" "" . pad $ (getIcon d) ++ d
, ppUrgent = \d -> xmobarColor "#1c1d1f" "#1793d0" . pad $ (getIcon d) ++ d
, ppLayout = xmobarColor "#d75f5f" ""
, ppSep = " \t\t "
, ppWsSep = xmobarColor "#505050" "" " "
, ppTitle = xmobarColor "#d7d7d7" "" . shorten 50
}
-- key bind
toggleStrutsKey XConfig {XMonad.modMask = modMask} = (modMask, xK_b)
-- main function
main = xmonad =<< statusBar myBar myPP toggleStrutsKey myConf
-- my config
myConf = defaultConfig {
-- simple stuff
terminal = myTerm,
focusFollowsMouse = myFocusFollowsMouse,
borderWidth = myBorderWidth,
modMask = myModMask,
workspaces = myWorkspaces,
normalBorderColor = myNormalBorderColor,
focusedBorderColor = myFocusedBorderColor,
-- key bindings
keys = myKeys,
mouseBindings = myMouseBindings,
-- hooks, layouts
layoutHook = myLayout,
manageHook = myManageHook,
handleEventHook = myEventHook,
logHook = myLogHook,
startupHook = myStartupHook
}
-- additional keys ...
`additionalKeysP`
[ ("M1-C-l", spawn myLock)
, ("M4-<Esc>", spawn myVolChange)
, ("M4-<F1>", spawn myBrowser)
, ("M4-<F2>", spawn myMail)
, ("M4-<F3>", spawn myTmux)
, ("M4-<F4>", spawn myPentaFlashOut)
, ("M4-S-<F4>", spawn myPentaFlashIn)
, ("M4-<F5>", spawn myWpChgr)
, ("M4-<F6>", spawn myRandWp)
, ("M4-<F7>", spawn mySkype)
, ("S-<Print>", spawn myScrShot)
, ("<Print>", spawn myScreenFull)
, ("M4-<F10>", spawn myMPDPlay)
, ("M4-<F11>", spawn myMPDNext)
, ("M4-<F9>", spawn myMPDPrev)
, ("M4-<F8>", spawn myStream)
, ("M4-<F12>", spawn myVolMute)
, ("M4-<Page_Down>", spawn myVolDown)
, ("M4-<Page_Up>", spawn myVolUp)]
-- , ("<XF86AudioPlay>", spawn myMPDPlay)
-- , ("<XF86AudioNext>", spawn myMPDNext)
-- , ("<XF86AudioPrev>", spawn myMPDPrev)
-- , ("<XF86AudioMute>", spawn myVolMute)
-- , ("<XF86AudioLowerVolume>", spawn myVolDown)
-- , ("<XF86AudioRaiseVolume>", spawn myVolUp)]