-- XMonad configuration file by Aline Abler
import XMonad
import XMonad.Hooks.DynamicLog
import qualified Data.Map as M
import XMonad.Util.EZConfig ( additionalKeys, removeKeys )
import System.Exit

main = xmonad =<< statusBar myBar myPP toggleGapsKey myConfig  


-- main configuration for xmonad
myConfig = defaultConfig { terminal = "urxvt"
    , modMask = mod4Mask -- use super key as modifier
    , borderWidth = 1
    , normalBorderColor = "#181715"
    , focusedBorderColor = "#58C5F1"
    , focusFollowsMouse = True

    } `additionalKeys` myKeys `removeKeys` [(mod4Mask, xK_q)] 

-- override some of the default keybindings and add my own
myKeys = 
    [ ((mod4Mask .|. shiftMask, xK_w), spawn "feh --bg-fill --randomize /home/alinea/Files/wallpaper/*") -- change wallpaper
    , ((mod4Mask .|. shiftMask, xK_q), kill) -- close window with mod-shift-Q (default is mod-shift-C)
    , ((mod4Mask .|. shiftMask, xK_e), io (exitWith ExitSuccess)) -- close xmonad with mod-shift-E (default is mod-shift-Q)
    , ((mod4Mask .|. shiftMask, xK_r), spawn "if type xmonad; then xmonad --recompile && xmonad --restart; else xmessage xmonad not in \\$PATH: \"$PATH\"; fi") -- %! Recompile and restart xmonad
    , ((mod4Mask,               xK_x), spawn "scrot '%Y-%m-%d-%H%M%S.png' -b -u -e 'mv $f ~/Files/screenshots/'" ) -- take a screenshoft of the currently active window
    , ((mod4Mask .|. shiftMask, xK_x), spawn "scrot '%Y-%m-%d-%H%M%S-full.png' -b -e 'mv $f ~/Files/screenshots/'" ) -- take a screenshot (of everything)
    ]

-- use xmobar as status bar, overriding the default config file path
myBar = "xmobar /home/alinea/.xmonad/xmobarrc"

-- configuration of the status bar output generated by xmonad
myPP = xmobarPP { ppCurrent = xmobarColor "#181715" "#58C5F1" . wrap "[" "]"
                , ppTitle = xmobarColor "#14FF08" "" . shorten 120
                , ppVisible = xmobarColor "#58C5F1" "#181715" . wrap "(" ")"
                , ppUrgent = xmobarColor "#181715" "#D81816"
                , ppHidden = xmobarColor "#58C5F1" "#181715"
                , ppSep = " * "
           }

-- keybinding for toggling the gap for the statusbar
toggleGapsKey XConfig {XMonad.modMask = mod4Mask} = (mod4Mask, xK_b)
