From ebeb708303972db7ab3dc68156c0e69a69427929 Mon Sep 17 00:00:00 2001 From: Martin Potier Date: Mon, 23 Nov 2020 16:01:13 +0200 Subject: [PATCH] Attempt to react to screen event --- lib/ScreenEvents.hs | 20 ++++++++++++++++++++ xmonad.hs | 13 +++++++------ 2 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 lib/ScreenEvents.hs diff --git a/lib/ScreenEvents.hs b/lib/ScreenEvents.hs new file mode 100644 index 0000000..0de53d3 --- /dev/null +++ b/lib/ScreenEvents.hs @@ -0,0 +1,20 @@ +module ScreenEvents ( + ScreenEvents.modify +) where + +import XMonad +import Data.Monoid (All(..)) +import Graphics.X11.Xlib.Extras (Event(RRScreenChangeNotifyEvent)) + +screenChangeHandler :: Event -> X All +screenChangeHandler (RRScreenChangeNotifyEvent _ _ _ _ _ _ _ _ _ _ _ _ _ _ _) = + spawn "~/.fehbg" >> return (All True) +screenChangeHandler _ = return (All True) + +modify :: XConfig l -> XConfig l +modify conf = conf + { handleEventHook = mconcat + [ screenChangeHandler + , handleEventHook conf ] } + + diff --git a/xmonad.hs b/xmonad.hs index 98da457..4e8011c 100755 --- a/xmonad.hs +++ b/xmonad.hs @@ -19,7 +19,6 @@ import XMonad.Layout.Spacing import XMonad.Layout.ThreeColumns (ThreeCol(..)) import XMonad.Layout.ToggleLayouts (toggleLayouts) - import XMonad.Util.EZConfig import qualified Solarized as S @@ -28,6 +27,7 @@ import KeyBindings as Keys (modify) import MouseBindings as Mouse (modify) import Projects (modify) import Scratchpad (modify) +import ScreenEvents (modify) -------------------- toggle btw vvvvvvvvvv or vvvvv --layouts = titleBar $ toggleLayouts fullscreen tiled @@ -62,11 +62,12 @@ myManageHook = composeOne ------------ build the full config withConfig = - Projects.modify -- Apply projects config - $ Keys.modify -- Apply keybindings config - $ Mouse.modify -- Apply mouse bindings config - $ Scratchpad.modify -- Apply scratchpad managehook config - $ desktopConfig -- on a default desktop config + Projects.modify -- Apply projects config + $ Keys.modify -- Apply keybindings config + $ Mouse.modify -- Apply mouse bindings config + $ Scratchpad.modify -- Apply scratchpad managehook config + $ ScreenEvents.modify -- Apply screen event hook config + $ desktopConfig -- on a default desktop config { manageHook = myManageHook <+> manageHook desktopConfig , layoutHook = desktopLayoutModifiers layouts , terminal = "nvidia-offload alacritty"