Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Imported libraries
- import XMonad
- import XMonad.Core
- import XMonad.Layout
- import XMonad.Layout.Gaps
- import XMonad.Layout.Grid
- import XMonad.Layout.Circle
- import XMonad.Layout.NoBorders
- import XMonad.Layout.ResizableTile
- import XMonad.Layout.MultiToggle
- import XMonad.Layout.MultiToggle.Instances
- import XMonad.Hooks.DynamicLog
- import XMonad.Hooks.ManageDocks
- import XMonad.Hooks.ManageHelpers
- import XMonad.Hooks.UrgencyHook
- import XMonad.Util.Run (spawnPipe)
- import XMonad.Actions.CycleWS (nextWS,prevWS)
- import Data.Monoid
- import Graphics.X11.Xlib
- import System.Exit
- import System.IO (Handle, hPutStrLn)
- import qualified XMonad.StackSet as W
- import qualified Data.Map as M
- import qualified XMonad.Actions.FlexibleResize as Flex
- -- Main
- main :: IO ()
- main = do
- workspaceBar <- spawnPipe myWorkspaceBar
- trayerBar <- spawnPipe myTrayerBar
- topStatusBar <- spawnPipe myTopStatusBar
- xmonad $ withUrgencyHook NoUrgencyHook defaultConfig
- { terminal = myTerminal
- , modMask = myModMask
- , focusFollowsMouse = myFocusFollowsMouse
- , borderWidth = myBorderWidth
- , normalBorderColor = myNormalBorderColor
- , focusedBorderColor = myFocusedBorderColor
- , layoutHook = myLayoutHook
- , workspaces = myWorkspaces
- , manageHook = manageDocks <+> manageHook defaultConfig <+> myManageHook
- , logHook = dynamicLogWithPP $ myDzenPP workspaceBar
- , keys = myKeys
- , mouseBindings = myMouseBindings
- }
- -- StatusBars
- myWorkspaceBar, myTrayerBar, myTopStatusBar :: String
- myWorkspaceBar = "dzen2 -x '0' -y '784' -h '16' -w '1080' -ta 'l' -fg '#ffffff' -bg '#000000' -fn 'snap:pixelsize=10' -p -e ''"
- myTrayerBar = "/home/nnoell/.scripts/trayerbar.sh"
- myTopStatusBar = "/home/nnoell/.scripts/topstatusbar.zsh"
- -- Terminal
- myTerminal :: String
- myTerminal = "urxvtc -e tmux"
- -- ModMask
- myModMask :: KeyMask
- myModMask = mod4Mask
- -- Focus follow mouse
- myFocusFollowsMouse :: Bool
- myFocusFollowsMouse = True
- -- Border width
- myBorderWidth :: Dimension
- myBorderWidth = 1
- -- Border colors
- myNormalBorderColor, myFocusedBorderColor :: String
- myNormalBorderColor = "#000000" --black
- myFocusedBorderColor = "#60a0c0" --blue
- --myFocusedBorderColor = "#a488d9" --purple
- --myFocusedBorderColor = "#82ca42" --green
- --myFocusedBorderColor = "#0085cc" --cyan
- -- Layout hook
- myLayoutHook = gaps [(U,16), (D,16), (L,0), (R,0)]
- $ avoidStruts
- $ mkToggle1 NBFULL
- $ smartBorders (tiled ||| Mirror tiled ||| Circle ||| Grid ||| Full)
- where
- tiled = ResizableTall nmaster delta ratio []
- nmaster = 1
- ratio = 1/2
- delta = 3/100
- -- Workspaces
- myWorkspaces :: [WorkspaceId]
- myWorkspaces = clickable $
- [" ^i(/home/nnoell/.icons/subtlexbm/terminal.xbm) term " --0
- ," ^i(/home/nnoell/.icons/subtlexbm/fox.xbm) web " --1
- ," ^i(/home/nnoell/.icons/subtlexbm/binder.xbm) code " --2
- ," ^i(/home/nnoell/.icons/subtlexbm/mouse.xbm) gfx " --3
- ," ^i(/home/nnoell/.icons/subtlexbm/balloon.xbm) chat " --4
- ," ^i(/home/nnoell/.icons/subtlexbm/note1.xbm) music " --5
- ," ^i(/home/nnoell/.icons/subtlexbm/movie.xbm) video " --6
- ," ^i(/home/nnoell/.icons/subtlexbm/shroom.xbm) other " --7
- ]
- where clickable l = [ "^ca(1,xdotool key super+" ++ show (n) ++ ")" ++ ws ++ "^ca()" |
- (i,ws) <- zip [1..] l,
- let n = if i == 10 then 0 else i ]
- -- Manage hook
- myManageHook :: ManageHook
- myManageHook = (composeAll . concat $
- [ [resource =? r --> doIgnore | r <- myIgnores] --ignore desktop
- , [className =? c --> doShift (myWorkspaces !! 1) | c <- myWebS ] --move myWebS windows to workspace 1 by classname
- , [className =? c --> doShift (myWorkspaces !! 4) | c <- myChatS ] --move myChatS windows to workspace 4 by classname
- , [className =? c --> doShift (myWorkspaces !! 3) | c <- myGfxS ] --move myGfxS windows to workspace 4 by classname
- , [className =? c --> doShift (myWorkspaces !! 5) | c <- myMusicS ] --move myMusiS windows to workspace 5 by classname
- , [className =? c --> doFloat | c <- myFloatFC] --float geometry by classname
- , [className =? c --> doCenterFloat | c <- myFloatCC] --float center geometry by classname
- , [name =? n --> doCenterFloat | n <- myFloatCN] --float center geometry by name
- , [name =? n --> doSideFloat NW | n <- myFloatSN] --float side NW geometry by name
- , [composeOne [ isFullscreen -?> doFullFloat ]]
- ])
- where
- role = stringProperty "WM_WINDOW_ROLE"
- name = stringProperty "WM_NAME"
- myIgnores = ["desktop","desktop_window"]
- myWebS = ["Chromium","Namoroka"]
- myGfxS = ["Gimp"]
- myChatS = ["Pidgin", "Xchat"]
- myMusicS = ["Clementine"]
- myFloatFC = ["Gimp", "Oblogout"]
- myFloatCC = ["File-roller", "zsnes", "Gmrun", "Gcalctool", "Gnome-power-preferences"]
- myFloatCN = ["ePSXe - Enhanced PSX emulator", "Seleccione Archivo", "Config Video", "Testing plugin", "Config Sound", "Config Cdrom", "Config Bios", "Config Netplay", "Config Memcards", "About ePSXe", "Config Controller", "Config Gamepads", "Select one or more files to open", "Add media", "Choose a file", "Open Image", "File Operation Progress", "Chromium Preferences", "Namoroka Preferences", "Preferences", "Search Engines", "Set up sync", "Passwords and Exceptions", "Autofill Options"]
- myFloatSN = ["gimp-toolbox-color-dialog", "Event Tester"]
- -- myWorkspaceBar config
- myDzenPP h = defaultPP
- { ppOutput = hPutStrLn h
- , ppSep = ""
- , ppWsSep = ""
- , ppCurrent = wrap "^fg(#ffffff)^bg(#60a0c0)" "^fg()^bg()"
- , ppUrgent = wrap "^fg(#ffffff)^bg(#aff73e)" "^fg()^bg()"
- , ppVisible = wrap "^fg(#b8bcb8)^bg(#484848)" "^fg()^bg()"
- , ppHidden = wrap "^fg(#b8bcb8)^bg(#484848)" "^fg()^bg()"
- , ppHiddenNoWindows = wrap "^fg(#484848)^bg(#000000)" "^fg()^bg()"
- , ppTitle = wrap "^fg(#9d9d9d)^bg(#000000)" "^fg()^bg()" . wrap "" " ^fg(#a488d9)>^fg(#60a0c0)>^fg(#444444)>"
- , ppLayout = wrap "^fg(#60a0c0)^bg(#000000)" "^fg()^bg()" .
- (\x -> case x of
- "ResizableTall" -> " ^i(/home/nnoell/.icons/xbm8x8/tall.xbm) "
- "Mirror ResizableTall" -> " ^i(/home/nnoell/.icons/xbm8x8/mtall.xbm) "
- "Circle" -> " ^i(/home/nnoell/.icons/xbm8x8/circle.xbm) "
- "Grid" -> " ^i(/home/nnoell/.icons/xbm8x8/grid.xbm) "
- "Full" -> " ^i(/home/nnoell/.icons/xbm8x8/full2.xbm) "
- )
- }
- -- Key bindings
- myKeys :: XConfig Layout -> M.Map (KeyMask, KeySym) (X ())
- myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
- [ ((modMask .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf) --Launch a terminal
- , ((mod1Mask , xK_F2), spawn "gmrun") --Launch gmrun
- , ((modMask , xK_o), spawn "sudo oblogout") --Launch oblogout
- , ((mod1Mask , xK_F3), spawn "chromium") --Launch chromium
- , ((modMask, xK_c), kill) --Close focused window
- , ((mod1Mask, xK_F4), kill)
- , ((modMask, xK_space), sendMessage NextLayout) --Rotate through the available layout algorithms
- , ((modMask .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf) --Reset the layouts on the current workspace to default
- , ((modMask, xK_n), refresh) --Resize viewed windows to the correct size
- , ((mod1Mask, xK_Tab), windows W.focusDown) --Move focus to the next window
- , ((modMask, xK_Tab), windows W.focusDown)
- , ((modMask, xK_j), windows W.focusDown)
- , ((modMask, xK_k), windows W.focusUp ) --Move focus to the previous window
- , ((modMask, xK_m), windows W.focusMaster ) --Move focus to the master window
- , ((modMask, xK_Return), windows W.swapMaster) --Swap the focused window and the master window
- , ((modMask .|. shiftMask, xK_j), windows W.swapDown ) --Swap the focused window with the next window
- , ((modMask .|. shiftMask, xK_k), windows W.swapUp ) --Swap the focused window with the previous window
- , ((modMask, xK_h), sendMessage Shrink) --Shrink the master area
- , ((modMask .|. shiftMask, xK_Left), sendMessage Shrink)
- , ((modMask, xK_l), sendMessage Expand) --Expand the master area
- , ((modMask .|. shiftMask, xK_Right), sendMessage Expand)
- , ((modMask .|. shiftMask, xK_h), sendMessage MirrorShrink) --MirrorShrink the master area
- , ((modMask .|. shiftMask, xK_Down), sendMessage MirrorShrink)
- , ((modMask .|. shiftMask, xK_l), sendMessage MirrorExpand) --MirrorExpand the master area
- , ((modMask .|. shiftMask, xK_Up), sendMessage MirrorExpand)
- , ((modMask, xK_t), withFocused $ windows . W.sink) --Push window back into tiling
- , ((modMask, xK_f), sendMessage $ Toggle NBFULL) --Push layout into full
- , ((modMask .|. shiftMask, xK_f), fullFloatFocused) --Push window into full screen
- , ((modMask, xK_comma), sendMessage (IncMasterN 1)) --Increment the number of windows in the master area
- , ((modMask, xK_period), sendMessage (IncMasterN (-1))) --Deincrement the number of windows in the master area
- , ((modMask , xK_d), spawn "killall dzen2 trayer") --Kill dzen2 and trayer
- , ((modMask , xK_s), spawn "xscreensaver-command -lock") --Lock screen
- , ((modMask .|. shiftMask, xK_q), io (exitWith ExitSuccess)) --Quit xmonad
- , ((modMask, xK_q), restart "xmonad" True) --Restart xmonad
- , ((mod1Mask .|. controlMask, xK_Left), prevWS) --Move to previous Workspace
- , ((modMask, xK_Left), prevWS)
- , ((modMask, xK_Right), nextWS) --Move to next Workspace
- , ((mod1Mask .|. controlMask, xK_Right), nextWS)
- ]
- ++
- [((m .|. modMask, k), windows $ f i) --Switch to n workspaces and send client to n workspaces
- | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
- , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
- ++
- [((m .|. modMask, key), screenWorkspace sc >>= flip whenJust (windows . f)) --Switch to n screens and send client to n screens
- | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
- , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
- where
- fullFloatFocused = withFocused $ \f -> windows =<< appEndo `fmap` runQuery doFullFloat f
- -- Mouse bindings
- myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $
- [ ((modMask, button1), (\w -> focus w >> mouseMoveWindow w >> windows W.shiftMaster)) -- set the window to floating mode and move by dragging
- , ((modMask, button2), (\w -> focus w >> windows W.shiftMaster)) -- raise the window to the top of the stack
- , ((modMask, button3), (\w -> focus w >> Flex.mouseResizeWindow w)) -- set the window to floating mode and resize by dragging
- , ((modMask, button4), (\_ -> prevWS)) -- switch to previous workspace
- , ((modMask, button5), (\_ -> nextWS)) -- switch to next workspace
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement