Welcome to our New Forums!

Our forums have been upgraded and expanded!

Hands on with Xmonad.

serpentwalker666

Well-known member
Joined
Oct 24, 2017
Messages
1,322
Here I would like to share some of what I've found helpful with Linux and BSD Systems, the choice of window managers and how this can create a more efficient workflow. I have learned and used Xmonad for year or two, and while it is the best for me so far, it can be fairly complex and not clear to some people.

I am going to be very quick and not dive into a whole lot here, I want this to just be a bit of an introduction to this, but also an interesting post.


Fortunately some other "sane" options exist for window management, like openbox, i3, or awesome window manager.

With many window managers you will have to write and config it in the language the developers have given the configuration file, and then oftentimes this is recompiled and the window manager is restarted.

The beauty of window managers is they can be as feature rich, complex, or as down to earth simple as you want, truly making your computer and system your own.

Here is some of my Xmonad Configuration, so a general idea is given to what I mean, it is written in Haskell and can be hard to follow at first, but I've made it very minimal to where programs and background applications are launched fairly clean, and everything functions without needing constant tinkering or things becoming too verbose.

At the start of an Xmonad.hs file, and many config files for window managers, you have the headers which import the functions of the library and needed extensions:

import XMonad import XMonad.Hooks.DynamicLog import XMonad.Hooks.ManageDocks import XMonad.Hooks.ManageHelpers import XMonad.Layout.NoBorders import XMonad.Layout.Gaps import XMonad.Layout.ThreeColumns import XMonad.Util.Run(spawnPipe) import XMonad.Util.SpawnOnce import XMonad.Util.EZConfig(additionalKeysP) import XMonad.Hooks.EwmhDesktops import XMonad.Layout.Spacing import qualified XMonad.StackSet as W import System.IO


From here the main block I will show as an example:

main = do xmproc <- spawnPipe "xmobar ~/.xmobarrc" xmonad $ ewmh def { modMask = mod1Mask, startupHook = myStartupHook, focusedBorderColor = myFocusedBorderColor, terminal = "urxvt", manageHook = manageDocks <+> manageHook def, layoutHook = avoidStruts $ myLayout, logHook = dynamicLogWithPP $ xmobarPP { ppOutput = hPutStrLn xmproc, ppCurrent = xmobarColor "#690fad" "" . wrap "[" "]", ppVisible = xmobarColor "#46a8c3" "" . wrap "" "", ppHidden = xmobarColor "#890fad" "" . wrap "" "", ppHiddenNoWindows = xmobarColor "#2f343f" "", ppOrder = \(ws:l:t:ex) -> [ws,l]++ex++[t], ppTitle = xmobarColor "#690fad" "" . shorten 50 } } -- `additionalKeysP` myKeys


And finally, I will show the startup hooks and spawn pipes for the background applications, the workspace layout and window configuration options:

myLayout = tiled ||| Mirror tiled ||| Full ||| threeCol where threeCol = ThreeColMid nmaster delta ratio tiled = Tall nmaster delta ratio nmaster = 1 -- Default number of windows in the master pane ratio = 1/2 -- Default proportion of screen occupied by master pane delta = 3/100 -- Percent of screen to increment by when resizing panes myWorkspaces = ["1", "2", "3", "4", "5", "6", "7", "8", "9"] myFocusedBorderColor = "#690fad" myStartupHook :: X () myStartupHook = do spawnOnce "xmobar ~/.xmobarrc" spawnOnce "nitrogen --restore &" spawnOnce "picom --config ~/.config/picom/picom.conf" spawnOnce " nm-applet --sm-disable& " spawnOnce "blueman-applet &" spawnOnce "trayer --edge top --align right --SetDockType true \ \--SetPartialStrut true --expand true --width 4 \ \--transparent false --tint 0x000000 --height 16"

Feel free to use the snippets of code here to assemble your own Xmonad configuration if you choose, and if you want to look into this further here are some links.




Some good window managers for beginners I will list here:



 
IMPORTANT NOTE: I'd like to add that unfortunately wrapping this haskell code and pasting it, caused the spacing and pasting of the configuration file snippets to be very smashed together, I deeply apologize, and here is the complete configuration file with my personal keybinds for applications excluded:

import XMonad
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.ManageHelpers
import XMonad.Layout.NoBorders
import XMonad.Layout.Gaps
import XMonad.Layout.ThreeColumns
import XMonad.Util.Run(spawnPipe)
import XMonad.Util.SpawnOnce
import XMonad.Util.EZConfig(additionalKeysP)
import XMonad.Hooks.EwmhDesktops
import XMonad.Layout.Spacing
import qualified XMonad.StackSet as W
import System.IO

myWorkspaces = ["1", "2", "3", "4", "5", "6", "7", "8", "9"]

myFocusedBorderColor = "#690fad"


myLayout = tiled ||| Mirror tiled ||| Full ||| threeCol
where
threeCol = ThreeColMid nmaster delta ratio
tiled = Tall nmaster delta ratio
nmaster = 1 -- Default number of windows in the master pane
ratio = 1/2 -- Default proportion of screen occupied by master pane
delta = 3/100 -- Percent of screen to increment by when resizing panes


myStartupHook :: X ()
myStartupHook = do
spawnOnce "xmobar ~/.xmobarrc"
spawnOnce "nitrogen --restore &"
spawnOnce "picom --config ~/.config/picom/picom.conf"
spawnOnce " nm-applet --sm-disable& "
spawnOnce "blueman-applet &"
spawnOnce "trayer --edge top --align right --SetDockType true \
\--SetPartialStrut true --expand true --width 4 \
\--transparent false --tint 0x000000 --height 16"


main = do
xmproc <- spawnPipe "xmobar ~/.xmobarrc"
xmonad $ ewmh def
{ modMask = mod1Mask,
startupHook = myStartupHook,
focusedBorderColor = myFocusedBorderColor,
terminal = "urxvt",
manageHook = manageDocks <+> manageHook def,
layoutHook = avoidStruts $ myLayout,
logHook = dynamicLogWithPP $ xmobarPP
{ ppOutput = hPutStrLn xmproc,
ppCurrent = xmobarColor "#690fad" "" . wrap "[" "]",
ppVisible = xmobarColor "#46a8c3" "" . wrap "" "",
ppHidden = xmobarColor "#890fad" "" . wrap "" "",
ppHiddenNoWindows = xmobarColor "#2f343f" "",
ppOrder = \(ws:l:t:ex) -> [ws,l]++ex++[t],
ppTitle = xmobarColor "#690fad" "" . shorten 50
}
}
--`additionalKeysP` myKeys
 

Al Jilwah: Chapter IV

"It is my desire that all my followers unite in a bond of unity, lest those who are without prevail against them." - Satan

Back
Top