Skip to content

Instantly share code, notes, and snippets.

@nekolinuxblog
Last active October 25, 2020 13:23
Show Gist options
  • Save nekolinuxblog/6776ace1732b38cb0d142ace1a0780a2 to your computer and use it in GitHub Desktop.
Save nekolinuxblog/6776ace1732b38cb0d142ace1a0780a2 to your computer and use it in GitHub Desktop.
xmonad設定用のベースとなるファイル
--------------------------------------------------------------------------------
-- shunsk's base xmonad.hs file for custamize
-- https://ok-xmonad.blogspot.com
--------------------------------------------------------------------------------
import System.Exit
import XMonad
import XMonad.Util.Run
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.DynamicLog
import qualified XMonad.StackSet as W
import XMonad.Util.EZConfig
---------------------------------------------------------------
-- MAIN
---------------------------------------------------------------
main = do
h <- spawnPipe "xmobar"
xmonad $
docks def { terminal = "terminator"
, modMask = mod4Mask
, focusFollowsMouse = False
, workspaces = map show [1..5 ::Int]
, borderWidth  = 3
, normalBorderColor = "#cccccc"
, focusedBorderColor= "#00bbff"
, manageHook = manageHook def
, handleEventHook = handleEventHook def
, layoutHook = mylayouthook
, logHook = myLogHook h
, keys = \c -> mkKeymap c (keyMapDataList c)
}
---------------------------------------------
-- xmobarとの連携
---------------------------------------------
myLogHook h =
dynamicLogWithPP
xmobarPP { ppOutput = hPutStrLn h
, ppCurrent = xmobarColor "#FF9F1C" "#1A1B41" . pad . wrap "[" "]"
, ppTitle = xmobarColor "#1A1B41" "#C2E7DA" . shorten 50 . pad
}
---------------------------------------------
-- レイアウト
---------------------------------------------
mylayouthook =
avoidStruts mytall ||| avoidStruts mymirror ||| myfull
where mytall = Tall 1 0.03 0.5
mymirror = Mirror mytall
myfull = Full
---------------------------------------------
-- キーバインド関連
---------------------------------------------
keyMapDataList :: XConfig Layout -> [(String, X ())]
keyMapDataList conf =
[("M-S-<Return>", spawn $ XMonad.terminal conf)
,("M-p", spawn "dmenu_run")
,("M-S-c", kill)
,("M-<Space>", sendMessage NextLayout)
,("M-S-<Space>", setLayout $ XMonad.layoutHook conf)
,("M-n", refresh)
,("M-<KP_Tab>", windows W.focusDown)
,("M-S-<KP_Tab>", windows W.focusUp)
,("M-j", windows W.focusDown)
,("M-k", windows W.focusUp)
,("M-m", windows W.focusMaster)
,("M-S-j", windows W.swapDown)
,("M-S-k", windows W.swapUp)
,("M-<Return>", windows W.swapMaster)
,("M-h", sendMessage Shrink)
,("M-l", sendMessage Expand)
,("M-t", withFocused $ windows . W.sink)
,("M-,", sendMessage $ IncMasterN 1)
,("M-.", sendMessage $ IncMasterN (-1))
,("M-S-q", io (exitWith ExitSuccess))
,("M-q", spawn myRecompileCmd)
]
-- workspaceの移動等
++
[("M-" ++ m ++ show k , windows $ f i)
| (i,k) <- zip (XMonad.workspaces conf) ([1..5] :: [Int])
, (f,m) <- [(W.view, ""),(W.shift, "S-")]
]
where
myRecompileCmd =
"xmonad --recompile && (killall xmobar; xmonad --restart)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment