diff options
author | Justin Bogner <mail@justinbogner.com> | 2008-05-23 22:58:38 +0200 |
---|---|---|
committer | Justin Bogner <mail@justinbogner.com> | 2008-05-23 22:58:38 +0200 |
commit | 403cc1a7e117ed52d751b382995e4b1cdb2f6589 (patch) | |
tree | 10aa2325821ff05c2c6b5bb2f6f1895fa77968ee /XMonad/Hooks | |
parent | c8b8684dc73616d341a6f94cedea5adde0de8072 (diff) | |
download | XMonadContrib-403cc1a7e117ed52d751b382995e4b1cdb2f6589.tar.gz XMonadContrib-403cc1a7e117ed52d751b382995e4b1cdb2f6589.tar.xz XMonadContrib-403cc1a7e117ed52d751b382995e4b1cdb2f6589.zip |
add FadeInactive to fade out inactive windows using xcompmgr
darcs-hash:20080523205838-18f27-7839527e8dc201d7b47e93d70b14ec6c2a6077c7.gz
Diffstat (limited to 'XMonad/Hooks')
-rw-r--r-- | XMonad/Hooks/FadeInactive.hs | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/XMonad/Hooks/FadeInactive.hs b/XMonad/Hooks/FadeInactive.hs new file mode 100644 index 0000000..c7fc75e --- /dev/null +++ b/XMonad/Hooks/FadeInactive.hs @@ -0,0 +1,73 @@ +----------------------------------------------------------------------------- +-- | +-- Module : XMonad.Hooks.FadeInactive +-- Copyright : (c) 2008 Justin Bogner <mail@justinbogner.com> +-- License : BSD +-- +-- Maintainer : Justin Bogner <mail@justinbogner.com> +-- Stability : unstable +-- Portability : unportable +-- +-- Makes XMonad set the _NET_WM_WINDOW_OPACITY atom for inactive windows, +-- which causes those windows to become slightly translucent if something +-- like xcompmgr is running +----------------------------------------------------------------------------- +module XMonad.Hooks.FadeInactive ( + -- * Usage + -- $usage + fadeInactiveLogHook + ) where + +import XMonad +import qualified XMonad.StackSet as W +import Control.Monad (forM_) + +-- $usage +-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@: +-- +-- > import XMonad +-- > import XMonad.Hooks.FadeInactive +-- > +-- > myLogHook :: X () +-- > myLogHook = fadeInactiveLogHook +-- > +-- > main = xmonad defaultConfig { logHook = myLogHook } +-- +-- you will need to have xcompmgr <http://freedesktop.org/wiki/Software/xapps> +-- or something similar for this to do anything +-- +-- For more detailed instructions on editing the layoutHook see: +-- +-- "XMonad.Doc.Extending#The_log_hook_and_external_status_bars" +-- +-- For more detailed instructions on editing the layoutHook see: +-- +-- "XMonad.Doc.Extending#Editing_the_layout_hook" + +-- | +-- sets the opacity of a window +setOpacity :: Window -> Integer -> X () +setOpacity w t = withDisplay $ \dpy -> do + a <- getAtom "_NET_WM_WINDOW_OPACITY" + c <- getAtom "CARDINAL" + io $ changeProperty32 dpy w a c propModeReplace [fromIntegral t] + +-- | +-- fades a window out by setting the opacity to an arbitrary amount +fadeOut :: Window -> X () +fadeOut = flip setOpacity 0xdddddddd + +-- | +-- makes a window completely opaque +fadeIn :: Window -> X () +fadeIn = flip setOpacity 0xffffffff + +-- | +-- lowers the opacity of inactive windows +fadeInactiveLogHook :: X () +fadeInactiveLogHook = withWindowSet $ \s -> + forM_ (concatMap visibleWins $ W.current s : W.visible s) fadeOut >> + withFocused fadeIn + where + visibleWins = maybe [] unfocused . W.stack . W.workspace + unfocused (W.Stack _ l r) = l ++ r |