Skip to content

Instantly share code, notes, and snippets.

@nsmaciej
Last active July 13, 2016 16:29
Show Gist options
  • Save nsmaciej/8776955 to your computer and use it in GitHub Desktop.
Save nsmaciej/8776955 to your computer and use it in GitHub Desktop.
My first try at Xmonad. It's awesome!
xsetroot -cursor_name left_ptr
xrdb ~/.Xdefaults
xmodmap ~/.Xmodmap
xcompmgr -c -l -8 -t -8 -o .50 -r 6 &
sleep 2 && (~/Dotfiles/Bin/8bitday.sh >> /tmp/8bitday.log 3>&1 &)
xrandr --output VGA1 --auto --above LVDS1
exec /home/mgoszcz2/.cabal/bin/xmonad
-- Bare bones
import XMonad
-- Exiting XMonad
import System.Exit
-- Switching workspaces
import qualified XMonad.StackSet as Xss (greedyView, shift)
-- Adding keys
import XMonad.Util.EZConfig (additionalKeysP, additionalKeys)
-- Nice spaces
import XMonad.Layout.Spacing (spacing)
-- Volume control
import XMonad.Actions.Volume (toggleMute, lowerVolume, raiseVolume)
-- Multi keys
import Graphics.X11.ExtraTypes.XF86
-- Global DRY
cmodmask = mod4Mask
wss = map show [0..9]
wsskeys = [xK_0..xK_9]
spacedist = 10
prefterm = "urxvt"
-- I have to override default workspace keys to allow workspace No. 0
genkeys cwss = std ++ [((mask .|. cmodmask, key), windows $ sf name)
| (name, key) <- zip cwss wsskeys
-- with shift with shift key otheriwse just switch
, (sf, mask) <- [(Xss.greedyView, 0), (Xss.shift, shiftMask)]]
where reloadcmd = "if type xmonad; then xmonad --recompile && xmonad --restart; else xmessage xmonad not in \\$PATH: \"$PATH\"; fi"
std = -- How am I supposed to acess the WWW
[ ((cmodmask, xK_w), spawn "google-chrome-beta")
-- No freaking shift every time to start terminal
, ((cmodmask, xK_Return), spawn $ prefterm ++ " -e tmux attach")
, ((cmodmask, xK_t), spawn prefterm)
-- Same goes for killing programs
, ((cmodmask, xK_q), kill)
-- Also M-z almost feals like a hardware feature
, ((cmodmask, xK_z), spawn "dmenu")
-- Quikcly diming the screen with '`'
, ((cmodmask, xK_grave), spawn "xset dpms force off")
-- Use M-r for reloading not q (this means Quit, WTF Xmonad)
, ((cmodmask .|. shiftMask, xK_r), io $ exitWith ExitSuccess) -- %! Quit xmonad
, ((cmodmask, xK_r), spawn reloadcmd) -- %! Restart xmonad
-- Misc. Volume controls
, ((0, xF86XK_AudioLowerVolume), lowerVolume 4 >> return ())
, ((0, xF86XK_AudioRaiseVolume), raiseVolume 4 >> return ())
, ((0, xF86XK_AudioMute), toggleMute >> return ())
]
layout = tiled ||| Mirror tiled ||| Full
where -- One master pane takes half and resize by 3/100
tiled = spacing spacedist $ Tall 1 (3/100) (1/2)
-- Mirrored version of tiled (no need to space)
mirrored = Mirror tiled
-- Full screen version (spacing doesn't work)
full = Full
main = xmonad $ defaultConfig
-- I use urxvt, why don't you?!
{ terminal = prefterm
-- I have 10 number keys for a reason
, workspaces = wss
-- Some stuff uses alt
, modMask = cmodmask
-- Tiny things are cute
, borderWidth = 3
-- Solarized base03 - Background
, normalBorderColor = "#002b36"
-- Solarized base02 - Highlights
, focusedBorderColor = "#073642"
-- Add some spacing to windows
, layoutHook = layout --Tall 1 (3/100) (1/2)
} `additionalKeys` (genkeys wss)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment