mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -07:00
The links were broken due to: 1. Incorrect quotes (' instead of " for module links and occasionally vice-versa). 2. Changes in the name of the "target" module not reflected in the "source" docs. 3. Typos to begin with. 4. Use of `<foo>` in the docs is rendered as just `foo` with a link to `/foo`. 5. Similarly for `"Foo"` if it starts with a capital letter (and hence could be a module). 6. Markup inside `@` code blocks still being applied. e.g. `@M-<arrow-keys>@` is rendered as `M-arrow-keys` with a spurious hyperlink from arrow-keys to `/arrow-keys`, which is confusing. Three links from XMonad.Util.Run have been removed outright, since they're no longer examples of the usage of 'runProcessWithInput'. WmiiActions has been gone since 2008, while XMonad.Prompt.Directory and XMonad.Layout.WorkspaceDir haven't been using 'runProcessWithInput' since 2020 and 2012, respectively. In some cases the `<foo>` were surrounded with @, especially in the case of key definitions, for consistency. (This wasn't done everywhere, because it looks ugly in the source.) MoreManageHelpers has never been in xmonad-contrib. ManageHelpers seems to fill the expected role. In the case of the module description for X.H.ManageDebug the quotes were simply removed because none of the likely options to make the link work were successful.
60 lines
1.8 KiB
Haskell
60 lines
1.8 KiB
Haskell
-----------------------------------------------------------------------------
|
|
-- |
|
|
-- Module : XMonad.Util.Timer
|
|
-- Description : A module for setting up timers.
|
|
-- Copyright : (c) Andrea Rossato and David Roundy 2007
|
|
-- License : BSD-style (see xmonad/LICENSE)
|
|
--
|
|
-- Maintainer : andrea.rossato@unibz.it
|
|
-- Stability : unstable
|
|
-- Portability : unportable
|
|
--
|
|
-- A module for setting up timers
|
|
-----------------------------------------------------------------------------
|
|
|
|
module XMonad.Util.Timer
|
|
( -- * Usage
|
|
-- $usage
|
|
startTimer
|
|
, handleTimer
|
|
, TimerId
|
|
) where
|
|
|
|
import XMonad
|
|
import Control.Concurrent
|
|
import Data.Unique
|
|
|
|
-- $usage
|
|
-- This module can be used to setup a timer to handle deferred events.
|
|
-- See "XMonad.Layout.ShowWName" for an usage example.
|
|
|
|
type TimerId = Int
|
|
|
|
-- | Start a timer, which will send a ClientMessageEvent after some
|
|
-- time (in seconds).
|
|
startTimer :: Rational -> X TimerId
|
|
startTimer s = io $ do
|
|
u <- hashUnique <$> newUnique
|
|
xfork $ do
|
|
d <- openDisplay ""
|
|
rw <- rootWindow d $ defaultScreen d
|
|
threadDelay (fromEnum $ s * 1000000)
|
|
a <- internAtom d "XMONAD_TIMER" False
|
|
allocaXEvent $ \e -> do
|
|
setEventType e clientMessage
|
|
setClientMessageEvent e rw a 32 (fromIntegral u) 0
|
|
sendEvent d rw False structureNotifyMask e
|
|
sync d False
|
|
return u
|
|
|
|
-- | Given a 'TimerId' and an 'Event', run an action when the 'Event'
|
|
-- has been sent by the timer specified by the 'TimerId'
|
|
handleTimer :: TimerId -> Event -> X (Maybe a) -> X (Maybe a)
|
|
handleTimer ti ClientMessageEvent{ev_message_type = mt, ev_data = dt} action = do
|
|
d <- asks display
|
|
a <- io $ internAtom d "XMONAD_TIMER" False
|
|
if mt == a && dt /= [] && fromIntegral (head dt) == ti
|
|
then action
|
|
else return Nothing
|
|
handleTimer _ _ _ = return Nothing
|