Created
March 6, 2012 19:45
-
-
Save hallettj/1988598 to your computer and use it in GitHub Desktop.
XMonad configuration for a left-handed Tall layout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-} | |
-- FlexibleInstances and MultiParamTypeClasses are necessary for the | |
-- LayoutClass instance declaration of Flip. | |
-- I use two monitors. The default tiled layout in XMonad, Tall, puts | |
-- the master window on the left side of the screen. That feels right | |
-- for my right screen. But for my left screen I would prefer the | |
-- master window to be on the right side of the screen because that side | |
-- of the screen feels more prominent. This is a minimal example | |
-- configuration for setting up a left-handed Tall layout for your left | |
-- screen. | |
-- | |
-- One weird thing about the left-handed layout is that the controls for | |
-- changing the size of the master window seem backwards. As with the | |
-- default layout, M-h makes the master window smaller and M-l makes it | |
-- larger. But if you think of those controls as moving the edge of the | |
-- window left or right then the directions will be reversed in | |
-- left-handed mode. | |
-- | |
-- A feature that I am interested in adding is to have the tiled layout | |
-- automatically select right- or left-handed mode depending on which | |
-- screen it appears on. I would like my layout cycling command to just | |
-- switch between Tall and Full, without having to cycle through both | |
-- the left- and right-handed versions of Tall. | |
import XMonad | |
import XMonad.Config.Gnome | |
import XMonad.Layout.Gaps | |
import XMonad.Layout.NoBorders | |
import Control.Arrow ((***), second) | |
import qualified XMonad.StackSet as W | |
------------------------------------------------------------------------ | |
-- 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. | |
-- | |
-- * NOTE: XMonad.Hooks.EwmhDesktops users must remove the obsolete | |
-- ewmhDesktopsLayout modifier from layoutHook. It no longer exists. | |
-- Instead use the 'ewmh' function from that module to modify your | |
-- defaultConfig as a whole. (See also logHook, handleEventHook, and | |
-- startupHook ewmh notes.) | |
-- | |
-- The available layouts. Note that each layout is separated by |||, | |
-- which denotes layout choice. | |
-- | |
myLayouts = smartBorders $ gaps [(U, 24)] $ tiled ||| leftTiled ||| Full | |
where | |
-- default tiling algorithm partitions the screen into two panes | |
tiled = Tall nmaster delta ratio | |
-- like tiled, but puts the master window on the right | |
leftTiled = Flip tiled | |
-- 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 | |
-- | Flip a layout, compute its 180 degree rotated form. | |
newtype Flip l a = Flip (l a) deriving (Show, Read) | |
instance LayoutClass l a => LayoutClass (Flip l) a where | |
runLayout (W.Workspace i (Flip l) ms) r = (map (second flipRect) *** fmap Flip) | |
`fmap` runLayout (W.Workspace i l ms) (flipRect r) | |
where screenWidth = fromIntegral $ rect_width r | |
flipRect (Rectangle rx ry rw rh) = Rectangle (screenWidth - rx - (fromIntegral rw)) ry rw rh | |
handleMessage (Flip l) = fmap (fmap Flip) . handleMessage l | |
description (Flip l) = "Flip "++ description l | |
------------------------------------------------------------------------ | |
-- Putting it all together | |
main = xmonad $ gnomeConfig { layoutHook = myLayouts } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment