Skip to content

Instantly share code, notes, and snippets.

@manzyuk
Created December 23, 2010 20:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manzyuk/753487 to your computer and use it in GitHub Desktop.
Save manzyuk/753487 to your computer and use it in GitHub Desktop.
xmonad+GNOME setup
import XMonad
import XMonad.Config.Gnome
import XMonad.Layout.NoBorders
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.ManageHelpers
import Monad
import qualified XMonad.StackSet as W
import Data.Monoid (All (All), mappend)
main = xmonad $ gnomeConfig
{ focusFollowsMouse = False
, borderWidth = 2
, modMask = mod4Mask
, layoutHook = avoidStruts $ smartBorders $ layoutHook gnomeConfig
, manageHook = manageDocks <+> manageFloats <+> manageHook gnomeConfig
, handleEventHook = fullscreenEventHook `mappend` handleEventHook gnomeConfig
}
where
manageFloats = composeOne [ isFullscreen -?> doFullFloat
, isDialog -?> doCenterFloat
]
-- Support for toggling Totem movie player fullscreen, see:
-- http://code.google.com/p/xmonad/issues/detail?id=339
-- Helper functions to fullscreen the window
fullFloat, tileWin :: Window -> X ()
fullFloat w = windows $ W.float w r
where r = W.RationalRect 0 0 1 1
tileWin w = windows $ W.sink w
fullscreenEventHook :: Event -> X All
fullscreenEventHook (ClientMessageEvent _ _ _ dpy win typ dat) = do
state <- getAtom "_NET_WM_STATE"
fullsc <- getAtom "_NET_WM_STATE_FULLSCREEN"
isFull <- runQuery isFullscreen win
-- Constants for the _NET_WM_STATE protocol
let remove = 0
add = 1
toggle = 2
-- The ATOM property type for changeProperty
ptype = 4
action = head dat
when (typ == state && (fromIntegral fullsc) `elem` tail dat) $ do
when (action == add || (action == toggle && not isFull)) $ do
io $ changeProperty32 dpy win state ptype propModeReplace [fromIntegral fullsc]
fullFloat win
when (head dat == remove || (action == toggle && isFull)) $ do
io $ changeProperty32 dpy win state ptype propModeReplace []
tileWin win
return $ All True
fullscreenEventHook _ = return $ All True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment