Skip to content

Instantly share code, notes, and snippets.

@aplaice
Last active June 2, 2016 17:25
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aplaice/51137da641abdbe33139 to your computer and use it in GitHub Desktop.
Save aplaice/51137da641abdbe33139 to your computer and use it in GitHub Desktop.
Enable firefox fullscreen within tile
-- BSD
module MyEventHook (fullscreenEventHook') where
import Data.List
import Data.Maybe
import Data.Monoid
import XMonad
import Control.Monad
import XMonad.Util.XUtils (fi)
import XMonad.Util.WindowProperties (getProp32)
-- heavily based on
-- XMonad.Hooks.EwmhDesktops
fullscreenEventHook' :: Event -> X All
fullscreenEventHook' (ClientMessageEvent _ _ _ dpy win typ (action:dats)) = do
wmstate <- getAtom "_NET_WM_STATE"
fullsc <- getAtom "_NET_WM_STATE_FULLSCREEN"
wstate <- fromMaybe [] `fmap` getProp32 wmstate win
let isFull = fromIntegral fullsc `elem` wstate
-- Constants for the _NET_WM_STATE protocol:
remove = 0
add = 1
toggle = 2
ptype = 4 -- The atom property type for changeProperty
chWstate f = io $ changeProperty32 dpy win wmstate ptype propModeReplace (f wstate)
when (typ == wmstate && fi fullsc `elem` dats) $ do
when (action == add || (action == toggle && not isFull)) $ do
chWstate (fi fullsc:)
when (action == remove || (action == toggle && isFull)) $ do
chWstate $ filter (/= (fi fullsc )) -- have to delete all instances, as firefox adds additional "_NET_WM_STATE_FULLSCREEN" atoms every time you switch workspaces
return $ All True
fullscreenEventHook' _ = return $ All True
@aplaice
Copy link
Author

aplaice commented Dec 28, 2015

Enables firefox fullscreen within tile (i.e. upon pressing , the URL bar and tabs hide, but firefox stays within its tile and does not go into the floating layer or take up the entire screen). The code is not firefox-specific, but simply tries to route around firefox's bug #1189622. As far as I'm aware it does not cause issues with other applications.

Snippet heavily based on fullScreenEventHook from XMonad.Hooks.EwmhDesktops — only two lines were removed from the function definition and one was changed.

To use:

  1. either save file in ~/.xmonad/lib/ and add import MyEventHook to you xmonad.hs OR copy-paste the code (without the module... line) directly into your xmonad.hs
  2. add fullscreenEventHook' to your handleEventHook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment