Guest User

Untitled

a guest
Apr 20th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import XMonad
  2. import Monad
  3. import qualified XMonad.StackSet as W
  4. import XMonad.Hooks.ManageHelpers
  5. import XMonad.Hooks.ManageDocks
  6. import XMonad.Config.Xfce
  7. import XMonad.Util.EZConfig
  8. import XMonad.Layout.NoBorders        
  9. import XMonad.Config.Desktop
  10. import XMonad.Layout.Tabbed
  11. import Data.Monoid (All (All), mappend)
  12.  
  13.  
  14. myTerminal = "xfce4-terminal"
  15.  
  16. -- layoutHook = smartBorders
  17.  
  18. main = xmonad $ xfceConfig
  19.         { terminal = myTerminal
  20.         , layoutHook =  smartBorders (layoutHook desktopConfig)
  21.         , manageHook = newManageHook
  22.         , handleEventHook = fullscreenEventHook `mappend` handleEventHook xfceConfig
  23.         }
  24.         `additionalKeys`
  25.         [ ((mod1Mask, xK_p        ), spawn "exe=`dmenu_path | dmenu` && eval \"exec $exe\"")
  26.         ]
  27.  
  28. newManageHook = myManageHook <+> manageHook desktopConfig
  29.  
  30. -- myManageHook = composeAll
  31. --                 [ isFullscreen --> (doF W.focusDown <+> doFullFloat)
  32. --                 ]
  33.  
  34. myManageHook = composeOne [
  35.   transience,
  36.   isFullscreen -?> doFullFloat,
  37.   resource =? "stalonetray" -?> doIgnore
  38.   ]
  39.  
  40.  
  41. -- Helper functions to fullscreen the window
  42. fullFloat, tileWin :: Window -> X ()
  43. fullFloat w = windows $ W.float w r
  44.     where r = W.RationalRect 0 0 1 1
  45. tileWin w = windows $ W.sink w
  46.  
  47.  
  48.  
  49. fullscreenEventHook :: Event -> X All
  50. fullscreenEventHook (ClientMessageEvent _ _ _ dpy win typ dat) = do
  51.   state <- getAtom "_NET_WM_STATE"
  52.   fullsc <- getAtom "_NET_WM_STATE_FULLSCREEN"
  53.   isFull <- runQuery isFullscreen win
  54.  
  55.  
  56.   -- Constants for the _NET_WM_STATE protocol
  57.   let remove = 0
  58.       add = 1
  59.       toggle = 2
  60.  
  61.  
  62.       -- The ATOM property type for changeProperty
  63.       ptype = 4
  64.  
  65.  
  66.       action = head dat
  67.  
  68.  
  69.   when (typ == state && (fromIntegral fullsc) `elem` tail dat) $ do
  70.     when (action == add || (action == toggle && not isFull)) $ do
  71.       io $ changeProperty32 dpy win state ptype propModeReplace [fromIntegral fullsc]
  72.       fullFloat win
  73.     when (head dat == remove || (action == toggle && isFull)) $ do
  74.       io $ changeProperty32 dpy win state ptype propModeReplace []
  75.       tileWin win
  76.  
  77.  
  78.   return $ All True
  79.  
  80.  
  81. fullscreenEventHook _ = return $ All True
Add Comment
Please, Sign In to add comment