import XMonad
import XMonad.Util.EZConfig (additionalKeysP)
import XMonad.Util.Run
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.StatusBar
import XMonad.Hooks.ManageDocks
import XMonad.Layout.Spacing
import System.IO

keybinds =
    [
     ("M-<Return>", spawn "alacritty"),
     ("M-r", spawn "rofi -show drun -config ~/.config/rofi/gruvbox.rasi"),
     ("M-S-s", spawn "flameshot gui"),
     ("M-s", kill)
    ]

cLayoutHook = avoidStruts $ spacing 5 $ layoutHook def

cXMobarPP :: PP
cXMobarPP = def
	{
		ppCurrent = xmobarColor "#83A598" "" ,
		ppHidden = xmobarColor "#EBDBB2" "",
		ppHiddenNoWindows = xmobarColor "#EBDBB2" "",
		ppTitle = xmobarColor "#EBDBB2" "" . shorten 60 . wrap "[" "]",
		ppLayout = \layout -> ""
	}

cXStatusBar = statusBarProp "xmobar" (pure cXMobarPP)

logHook = dynamicLogWithPP $ def
    { ppOutput = \s -> return (),
	ppCurrent = id,
	ppVisible = id,
	ppHidden = id,
	ppUrgent = id,
	ppTitle = id
    }

main = xmonad . withSB (statusBarProp "xmobar -f 'xft:JetBrainsMono Nerd Font-14'" (pure cXMobarPP)) $ withEasySB cXStatusBar defToggleStrutsKey $ def
	{
		modMask = mod4Mask,
		terminal = "alacritty",
		borderWidth =  2,
		normalBorderColor = "#282828",
		focusedBorderColor = "#383838",
		workspaces = map show [1..9],
		layoutHook = cLayoutHook
	}
	`additionalKeysP` keybinds
