aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad/Hooks/SetCursor.hs
blob: 047d582abe96ae6b6c0054d2c43aa12a01579ae0 (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
-----------------------------------------------------------------------------
-- |
-- Module      :  XMonad.Hooks.SetCursor
-- Copyright   :  (c) 2009 Nils Schweinsberg
-- License     :  BSD3-style (see LICENSE)
--
-- Maintainer  :  Nils Schweinsberg <mail@n-sch.de>
-- Stability   :  unstable
-- Portability :  unportable
--
-- Set a default cursor on startup.
--
-- Thanks to Andres Salomon for his initial idea for this startup hook.
--
-----------------------------------------------------------------------------

module XMonad.Hooks.SetCursor (
    -- * Usage
    -- $usage
      setDefaultCursor
    ) where

import XMonad

{- $usage

To use this startup hook add a line to your startup hook:

> myStartupHook = do
>     setDefaultCursor 68
>     -- more stuff

Where @68@ is the default left pointer.

-}

-- | Set the default (root) cursor
setDefaultCursor :: Glyph -- ^ the cursor to use
    -> X ()
setDefaultCursor glyph = do
    dpy   <- asks display
    rootw <- asks theRoot
    liftIO $ do
        curs <- createFontCursor dpy glyph
        defineCursor dpy rootw curs
        flush dpy
        freeCursor dpy curs