diff options
| author | Andrew <saintruler@gmail.com> | 2020-11-30 20:01:31 +0400 |
|---|---|---|
| committer | Andrew <saintruler@gmail.com> | 2020-11-30 20:01:31 +0400 |
| commit | 2ffe1d22e9ab40f205f0cfa70ebb0712bb36c115 (patch) | |
| tree | 53e54f1f6bf6b5f5caffac3c23948a6d496ce3f8 /.config/xmonad/xmonad.hs | |
| parent | 00d1c84188d72fb84b9bf31857a8ec1caf242593 (diff) | |
Added xmonad configuration
Diffstat (limited to '.config/xmonad/xmonad.hs')
| -rw-r--r-- | .config/xmonad/xmonad.hs | 299 |
1 files changed, 299 insertions, 0 deletions
diff --git a/.config/xmonad/xmonad.hs b/.config/xmonad/xmonad.hs new file mode 100644 index 0000000..95b685c --- /dev/null +++ b/.config/xmonad/xmonad.hs @@ -0,0 +1,299 @@ +-- +-- xmonad example config file. +-- +-- A template showing all available configuration hooks, +-- and how to override the defaults in your own xmonad.hs conf file. +-- +-- Normally, you'd only override those defaults you care about. +-- + +-- Base +import XMonad +-- import System.IO (hPutStrLn) +import Data.Monoid +import System.Exit + +import qualified XMonad.StackSet as W +import qualified Data.Map as M + +-- Hooks +import XMonad.Hooks.ManageDocks +import XMonad.Hooks.ManageHelpers +import XMonad.Hooks.DynamicLog (statusBar, dynamicLogWithPP, wrap, xmobarPP, xmobarColor, shorten, PP(..)) +import XMonad.Hooks.EwmhDesktops + +-- Layout +import XMonad.Layout.NoBorders + +-- Utils +import XMonad.Util.Run -- (runProcessWithInput, safeSpawn, spawnPipe) +import XMonad.Util.SpawnOnce +import Graphics.X11.ExtraTypes.XF86 + +-- The preferred terminal program, which is used in a binding below and by +-- certain contrib modules. +-- +myTerminal = "st" + +-- Whether focus follows the mouse pointer. +myFocusFollowsMouse :: Bool +myFocusFollowsMouse = False + +-- Whether clicking on a window to focus also passes the click to the window +myClickJustFocuses :: Bool +myClickJustFocuses = False + +-- Width of the window border in pixels. +-- +myBorderWidth = 3 + +-- modMask lets you specify which modkey you want to use. The default +-- is mod1Mask ("left alt"). You may also consider using mod3Mask +-- ("right alt"), which does not conflict with emacs keybindings. The +-- "windows key" is usually mod4Mask. +-- +myModMask = mod4Mask + +-- The default number of workspaces (virtual screens) and their names. +-- By default we use numeric strings, but any string may be used as a +-- workspace name. The number of workspaces is determined by the length +-- of this list. +-- +-- A tagging example: +-- +-- > workspaces = ["web", "irc", "code" ] ++ map show [4..9] +-- +myWorkspaces = ["1","2","3","4","5","6","7","8","9"] + +-- Border colors for unfocused and focused windows, respectively. +-- +myNormalBorderColor = "#444444" +myFocusedBorderColor = "#005577" + +------------------------------------------------------------------------ +-- Key bindings. Add, modify or remove key bindings here. +-- +myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $ + + -- launch a terminal + [ ((modm, xK_Return), spawn $ XMonad.terminal conf) + + -- launch dmenu + , ((modm, xK_p ), spawn "dmenu_run") + + -- launch gmrun + , ((modm .|. shiftMask, xK_p ), spawn "gmrun") + + -- close focused window + , ((modm, xK_q ), kill) + + -- Rotate through the available layout algorithms + , ((modm, xK_space ), sendMessage NextLayout) + + -- Reset the layouts on the current workspace to default + , ((modm .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf) + + -- Resize viewed windows to the correct size + , ((modm, xK_n ), refresh) + + -- Move focus to the next window + , ((modm, xK_j ), windows W.focusDown) + + -- Move focus to the previous window + , ((modm, xK_k ), windows W.focusUp ) + + -- Move focus to the master window + , ((modm, xK_m ), windows W.focusMaster ) + + -- Swap the focused window and the master window + , ((modm .|. shiftMask, xK_Return), windows W.swapMaster) + + -- Swap the focused window with the next window + , ((modm .|. shiftMask, xK_j ), windows W.swapDown ) + + -- Swap the focused window with the previous window + , ((modm .|. shiftMask, xK_k ), windows W.swapUp ) + + -- Shrink the master area + , ((modm, xK_h ), sendMessage Shrink) + + -- Expand the master area + , ((modm, xK_l ), sendMessage Expand) + + -- Push window back into tiling + , ((modm, xK_t ), withFocused $ windows . W.sink) + + -- Increment the number of windows in the master area + , ((modm , xK_comma ), sendMessage (IncMasterN 1)) + + -- Deincrement the number of windows in the master area + , ((modm , xK_period), sendMessage (IncMasterN (-1))) + + -- Quit xmonad + , ((modm .|. shiftMask, xK_e ), io (exitWith ExitSuccess)) + + -- Restart xmonad + , ((modm , xK_r ), spawn "xmonad --recompile; xmonad --restart") + ] + ++ + + -- + -- mod-[1..9], Switch to workspace N + -- mod-shift-[1..9], Move client to workspace N + -- + [((m .|. modm, k), windows $ f i) + | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9] + , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]] + ++ + + -- Custom applications bindings + [ ((modm, xK_w), spawn "$BROWSER") + , ((modm, xK_b), spawn "nemo") + , ((modm, xK_Tab), spawn "$TERMINAL -e htop") + , ((modm .|. shiftMask, xK_b), spawn "bluecontrol") + , ((modm .|. shiftMask, xK_t), spawn "$TERMINAL -e tremc") + ] + ++ + + -- Volume control + [ ((0, xF86XK_AudioMute), spawn "pamixer -t") + , ((0, xF86XK_AudioLowerVolume), spawn "pamixer --allow-boost -d 5") + , ((0, xF86XK_AudioRaiseVolume), spawn "pamixer --allow-boost -i 5") + ] + ++ + + -- Brightness control + [ ((0, xF86XK_MonBrightnessUp), spawn "brightnessctl set 10%+") + , ((0, xF86XK_MonBrightnessDown), spawn "brightnessctl set 10%-") + ] + ++ + + -- Touchpad notifications + [ ((0, xF86XK_TouchpadOff), spawn "notify-send 'Touchpad turned off'") + , ((0, xF86XK_TouchpadOn), spawn "notify-send 'Touchpad turned on'") + ] + ++ + + -- Screenshot of chosen area + [ ((0, xK_Print), spawn "screenshot area to clip") + , ((0 .|. shiftMask, xK_Print), spawn "screenshot area to file") + ] + ++ + + -- Screenshot of active window + [ ((0 .|. controlMask, xK_Print), spawn "screenshot window to clip") + , ((0 .|. controlMask .|. shiftMask, xK_Print), spawn "screenshot window to file") + ] + ++ + + -- Screenshot of full screen + [ ((modm, xK_Print), spawn "screenshot screen to clip") + , ((modm .|. shiftMask, xK_Print), spawn "screenshot screen to file") + ] + +------------------------------------------------------------------------ +-- Mouse bindings: default actions bound to mouse events +-- +myMouseBindings (XConfig {XMonad.modMask = modm}) = M.fromList $ + + -- mod-button1, Set the window to floating mode and move by dragging + [ ((modm, button1), (\w -> focus w >> mouseMoveWindow w + >> windows W.shiftMaster)) + + -- mod-button2, Raise the window to the top of the stack + , ((modm, button2), (\w -> focus w >> windows W.shiftMaster)) + + -- mod-button3, Set the window to floating mode and resize by dragging + , ((modm, button3), (\w -> focus w >> mouseResizeWindow w + >> windows W.shiftMaster)) + + -- you may also bind events to the mouse scroll wheel (button4 and button5) + ] + +------------------------------------------------------------------------ +-- Layouts: + +-- You can specify and transform your layouts by modifying these values. +-- If you change layout bindings be sure to use 'mod-shift-space' after +-- restarting (with 'mod-q') to reset your layout state to the new +-- defaults, as xmonad preserves your old layout settings by default. +-- +-- The available layouts. Note that each layout is separated by |||, +-- which denotes layout choice. +-- +myLayout = tiled ||| Mirror tiled ||| Full + where + -- default tiling algorithm partitions the screen into two panes + tiled = Tall nmaster delta ratio + + -- The default number of windows in the master pane + nmaster = 1 + + -- Default proportion of screen occupied by master pane + ratio = 1/2 + + -- Percent of screen to increment by when resizing panes + delta = 3/100 + +------------------------------------------------------------------------ +-- Window rules: + +-- Execute arbitrary actions and WindowSet manipulations when managing +-- a new window. You can use this to, for example, always float a +-- particular program, or have a client always appear on a particular +-- workspace. +-- +-- To find the property name associated with a program, use +-- > xprop | grep WM_CLASS +-- and click on the client you're interested in. +-- +-- To match on the WM_NAME, you can use 'title' in the same way that +-- 'className' and 'resource' are used below. +-- +myManageHook = composeAll + [ className =? "Nemo" --> doFloat + , className =? "MPlayer" --> doFloat + , className =? "Gimp" --> doFloat + , resource =? "desktop_window" --> doIgnore + , resource =? "kdesktop" --> doIgnore ] + +------------------------------------------------------------------------ +-- Startup hook + +-- Perform an arbitrary action each time xmonad starts or is restarted +-- with mod-q. Used by, e.g., XMonad.Layout.PerWorkspace to initialize +-- per-workspace layout choices. +-- +-- By default, do nothing. +myStartupHook = return () + +------------------------------------------------------------------------ +-- Run xmonad +main = do + xmobarproc <- spawnPipe "xmobar $XDG_CONFIG_HOME/xmonad/xmobarrc" + xmonad $ ewmh defaultConfig { + -- simple stuff + terminal = myTerminal, + focusFollowsMouse = myFocusFollowsMouse, + clickJustFocuses = myClickJustFocuses, + borderWidth = myBorderWidth, + modMask = myModMask, + workspaces = myWorkspaces, + normalBorderColor = myNormalBorderColor, + focusedBorderColor = myFocusedBorderColor, + + -- key bindings + keys = myKeys, + mouseBindings = myMouseBindings, + + -- hooks, layouts + layoutHook = smartBorders . avoidStruts $ myLayout, + -- manageHook = myManageHook <+> manageDocks, + manageHook = ( isFullscreen --> doFullFloat ) <+> myManageHook <+> manageDocks, + handleEventHook = fullscreenEventHook <+> docksEventHook, + logHook = dynamicLogWithPP + $ def { ppOutput = hPutStrLn xmobarproc + , ppCurrent = xmobarColor "#00ff00" "" . wrap "[" "]" + , ppHidden = xmobarColor "#bbbbbb" "" . wrap "|" "|" + , ppHiddenNoWindows = xmobarColor "#bbbbbb" "" }, + startupHook = myStartupHook } |