about summary refs log tree commit diff
path: root/src/XMonad/Custom/Startup.hs
blob: 592f9b8650466f43fef2e496223988504f2a953a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
-----------------------------------------------------------------------------
-- |
-- Module      :  XMonad.Custom.Startup
-- Copyright   :  (c) azahi 2018
-- License     :  BSD3-style (see LICENSE)
--
-- Maintainer  :  azahi@teknik.io
-- Stability   :  unstable
-- Portability :  unportable
--
-----------------------------------------------------------------------------

module XMonad.Custom.Startup
    ( startupHook'
    ) where

import           Control.Monad
import           Data.Maybe
import           XMonad
import           XMonad.Hooks.ManageDocks
import           XMonad.Hooks.SetWMName
import           XMonad.Util.Cursor
import           XMonad.Util.SpawnNamedPipe

atomsToFullscreen :: [String]
atomsToFullscreen =
  [ "_NET_ACTIVE_WINDOW"
  , "_NET_CLIENT_LIST"
  , "_NET_CLIENT_LIST_STACKING"
  , "_NET_DESKTOP_NAMES"
  , "_NET_WM_DESKTOP"
  , "_NET_WM_STATE"
  , "_NET_WM_STATE_FULLSCREEN"
  , "_NET_WM_STATE_HIDDEN"
  , "_NET_WM_STRUT"
  ]

addNETSupported :: Atom -> X ()
addNETSupported x = withDisplay $ \d -> do
    r <- asks theRoot
    n <- getAtom "_NET_SUPPORTED"
    a <- getAtom "ATOM"
    liftIO $ do
        p <- join . maybeToList <$> getWindowProperty32 d n r
        when (fromIntegral x `notElem` p) $ changeProperty32 d r n a propModeAppend [fromIntegral x]

addEWMHFullscreen :: X ()
addEWMHFullscreen = do
    s <- mapM getAtom atomsToFullscreen
    mapM_ addNETSupported s

startupHook' :: X ()
startupHook' = do
    spawnNamedPipe "xmobar ~/work/xmonad-ng/xmobarrcTop.hs" "xmobarTop"
    spawnNamedPipe "xmobar ~/work/xmonad-ng/xmobarrcBot.hs" "xmobarBot"
    docksStartupHook
    addEWMHFullscreen
    setDefaultCursor xC_left_ptr
    setWMName "xmonad"

Consider giving Nix/NixOS a try! <3