mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -07:00
Merge pull request #490 from liskin/pr/hacks-trayer
X.U.Hacks: Add "Stacking trays (trayer) above panels (xmobar)"
This commit is contained in:
commit
cd24f84774
15
CHANGES.md
15
CHANGES.md
@ -81,11 +81,16 @@
|
|||||||
|
|
||||||
* `XMonad.Util.Hacks`
|
* `XMonad.Util.Hacks`
|
||||||
|
|
||||||
Serves as a collection of hacks and fixes that should be easily acessible to users.
|
A collection of hacks and fixes that should be easily acessible to users:
|
||||||
The first element of this module is windowedFullscreenFix, which fixes fullscreen behaviour
|
|
||||||
of chromium based applications when using windowed fullscreen.
|
- `windowedFullscreenFix` fixes fullscreen behaviour of chromium based
|
||||||
A second entry is `javaHack`, which helps when dealing with Java applications that might
|
applications when using windowed fullscreen.
|
||||||
not work well with xmonad.
|
|
||||||
|
- `javaHack` helps when dealing with Java applications that might not work
|
||||||
|
well with xmonad.
|
||||||
|
|
||||||
|
- `trayerAboveXmobarEventHook` reliably stacks trayer on top of xmobar and
|
||||||
|
below other windows
|
||||||
|
|
||||||
* `XMonad.Util.ActionCycle`
|
* `XMonad.Util.ActionCycle`
|
||||||
|
|
||||||
|
@ -1160,7 +1160,8 @@ A non complete list with a brief description:
|
|||||||
Core fonts and Xft.
|
Core fonts and Xft.
|
||||||
|
|
||||||
* "XMonad.Util.Hacks":
|
* "XMonad.Util.Hacks":
|
||||||
A collection of small fixes and utilities with possibly hacky implementations.
|
A collection of small fixes and utilities with possibly hacky
|
||||||
|
implementations and/or not deserving own modules.
|
||||||
|
|
||||||
* "XMonad.Util.Image":
|
* "XMonad.Util.Image":
|
||||||
Utilities for manipulating [[Bool]] as images.
|
Utilities for manipulating [[Bool]] as images.
|
||||||
|
@ -9,7 +9,8 @@
|
|||||||
-- Portability : unportable
|
-- Portability : unportable
|
||||||
--
|
--
|
||||||
-- This module is a collection of random fixes, workarounds and other functions
|
-- This module is a collection of random fixes, workarounds and other functions
|
||||||
-- that rely on somewhat hacky implementations which may have unwanted side effects.
|
-- that rely on somewhat hacky implementations which may have unwanted side effects
|
||||||
|
-- and/or are small enough to not warrant a separate module.
|
||||||
--
|
--
|
||||||
-- Import this module as qualified like so:
|
-- Import this module as qualified like so:
|
||||||
--
|
--
|
||||||
@ -19,19 +20,25 @@
|
|||||||
--
|
--
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
module XMonad.Util.Hacks
|
module XMonad.Util.Hacks (
|
||||||
( -- * Windowed fullscreen
|
-- * Windowed fullscreen
|
||||||
-- $windowedFullscreenFix
|
-- $windowedFullscreenFix
|
||||||
windowedFullscreenFixEventHook
|
windowedFullscreenFixEventHook,
|
||||||
-- * Java Hack
|
|
||||||
-- $java
|
-- * Java Hack
|
||||||
, javaHack
|
-- $java
|
||||||
|
javaHack,
|
||||||
|
|
||||||
|
-- * Stacking trays (trayer) above panels (xmobar)
|
||||||
|
-- $raiseTrayer
|
||||||
|
trayerAboveXmobarEventHook,
|
||||||
|
trayAbovePanelEventHook,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
|
||||||
import XMonad
|
import XMonad
|
||||||
import Data.Monoid (All(All))
|
import Data.Monoid (All(All))
|
||||||
import Control.Monad (when)
|
import Control.Monad (when, filterM)
|
||||||
import System.Posix.Env (putEnv)
|
import System.Posix.Env (putEnv)
|
||||||
|
|
||||||
|
|
||||||
@ -79,7 +86,7 @@ windowedFullscreenFixEventHook _ = return $ All True
|
|||||||
|
|
||||||
|
|
||||||
-- $java
|
-- $java
|
||||||
-- | Some java Applications might not work with xmonad. A common workaround would be to set the environment
|
-- Some java Applications might not work with xmonad. A common workaround would be to set the environment
|
||||||
-- variable @_JAVA_AWT_WM_NONREPARENTING@ to 1. The function 'javaHack' does exactly that.
|
-- variable @_JAVA_AWT_WM_NONREPARENTING@ to 1. The function 'javaHack' does exactly that.
|
||||||
-- Example usage:
|
-- Example usage:
|
||||||
--
|
--
|
||||||
@ -92,3 +99,49 @@ javaHack conf = conf
|
|||||||
{ startupHook = startupHook conf
|
{ startupHook = startupHook conf
|
||||||
*> io (putEnv "_JAVA_AWT_WM_NONREPARENTING=1")
|
*> io (putEnv "_JAVA_AWT_WM_NONREPARENTING=1")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
-- $raiseTrayer
|
||||||
|
-- Placing @trayer@ on top of @xmobar@ is somewhat tricky:
|
||||||
|
--
|
||||||
|
-- - they both should be lowered to the bottom of the stacking order to avoid
|
||||||
|
-- overlapping fullscreen windows
|
||||||
|
--
|
||||||
|
-- - the tray needs to be stacked on top of the panel regardless of which
|
||||||
|
-- happens to start first
|
||||||
|
--
|
||||||
|
-- 'trayerAboveXmobarEventHook' (and the more generic
|
||||||
|
-- 'trayAbovePanelEventHook') is an event hook that ensures the latter:
|
||||||
|
-- whenever the tray lowers itself to the bottom of the stack, it checks
|
||||||
|
-- whether there are any panels above it and lowers these again.
|
||||||
|
--
|
||||||
|
-- To ensure the former, that is having both @trayer@ and @xmobar@ lower
|
||||||
|
-- themselves, which is a necessary prerequisite for this event hook to
|
||||||
|
-- trigger:
|
||||||
|
--
|
||||||
|
-- - set @lowerOnStart = True@ and @overrideRedirect = True@ in @~/.xmobarrc@
|
||||||
|
-- - pass @-l@ to @trayer@
|
||||||
|
--
|
||||||
|
-- Usage:
|
||||||
|
--
|
||||||
|
-- > handleEventHook = … <> Hacks.trayerAboveXmobarEventHook
|
||||||
|
|
||||||
|
-- | 'trayAbovePanelEventHook' for trayer/xmobar
|
||||||
|
trayerAboveXmobarEventHook :: Event -> X All
|
||||||
|
trayerAboveXmobarEventHook = trayAbovePanelEventHook (className =? "trayer") (appName =? "xmobar")
|
||||||
|
|
||||||
|
-- | Whenever a tray window lowers itself to the bottom of the stack, look for
|
||||||
|
-- any panels above it and lower these.
|
||||||
|
trayAbovePanelEventHook
|
||||||
|
:: Query Bool -- ^ tray
|
||||||
|
-> Query Bool -- ^ panel
|
||||||
|
-> (Event -> X All) -- ^ event hook
|
||||||
|
trayAbovePanelEventHook trayQ panelQ ConfigureEvent{ev_window = w, ev_above = a} | a == none = do
|
||||||
|
whenX (runQuery trayQ w) $ withDisplay $ \dpy -> do
|
||||||
|
rootw <- asks theRoot
|
||||||
|
(_, _, ws) <- io $ queryTree dpy rootw
|
||||||
|
let aboveTrayWs = dropWhile (w /=) ws
|
||||||
|
panelWs <- filterM (runQuery panelQ) aboveTrayWs
|
||||||
|
mapM_ (io . lowerWindow dpy) panelWs
|
||||||
|
mempty
|
||||||
|
trayAbovePanelEventHook _ _ _ = mempty
|
||||||
|
Loading…
x
Reference in New Issue
Block a user