mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 03:20:21 -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.
85 lines
2.5 KiB
Haskell
85 lines
2.5 KiB
Haskell
{-# LANGUAGE InstanceSigs #-}
|
|
-----------------------------------------------------------------------------
|
|
-- |
|
|
-- Module : XMonad.Hooks.ShowWName
|
|
-- Description : Like 'XMonad.Layout.ShowWName', but as a logHook
|
|
-- Copyright : (c) 2022 Tony Zorman
|
|
-- License : BSD3-style (see LICENSE)
|
|
--
|
|
-- Maintainer : Tony Zorman <soliditsallgood@mailbox.org>
|
|
--
|
|
-- Flash the names of workspaces name when switching to them. This is a
|
|
-- reimplementation of "XMonad.Layout.ShowWName" as a logHook.
|
|
-----------------------------------------------------------------------------
|
|
|
|
module XMonad.Hooks.ShowWName (
|
|
-- * Usage
|
|
-- $usage
|
|
showWNameLogHook,
|
|
SWNConfig(..),
|
|
flashName,
|
|
) where
|
|
|
|
import qualified XMonad.StackSet as W
|
|
import qualified XMonad.Util.ExtensibleState as XS
|
|
|
|
import XMonad
|
|
import XMonad.Layout.ShowWName (SWNConfig (..))
|
|
import XMonad.Prelude
|
|
import XMonad.Util.XUtils (WindowConfig (..), showSimpleWindow)
|
|
|
|
import Control.Concurrent (threadDelay)
|
|
|
|
{- $usage
|
|
|
|
You can use this module with the following in your
|
|
@~\/.xmonad\/xmonad.hs@:
|
|
|
|
> import XMonad.Hooks.ShowWName
|
|
>
|
|
> main :: IO ()
|
|
> main = xmonad $ def
|
|
> { logHook = showWNameLogHook def
|
|
> }
|
|
|
|
Whenever a workspace gains focus, the above logHook will flash its name.
|
|
You can customise the duration of the flash, as well as colours by
|
|
customising the 'SWNConfig' argument that 'showWNameLogHook' takes.
|
|
|
|
Alternatively, you can also bind 'flashName' to a key and manually
|
|
invoke it when you want to know which workspace you are on.
|
|
-}
|
|
|
|
-- | LogHook for flashing the name of a workspace upon entering it.
|
|
showWNameLogHook :: SWNConfig -> X ()
|
|
showWNameLogHook cfg = do
|
|
LastShown s <- XS.get
|
|
foc <- withWindowSet (pure . W.currentTag)
|
|
unless (s == foc) $ do
|
|
flashName cfg
|
|
XS.put (LastShown foc)
|
|
|
|
-- | Flash the name of the currently focused workspace.
|
|
flashName :: SWNConfig -> X ()
|
|
flashName cfg = do
|
|
n <- withWindowSet (pure . W.currentTag)
|
|
showSimpleWindow cfg' [n] >>= \w -> void . xfork $ do
|
|
dpy <- openDisplay ""
|
|
threadDelay (fromEnum $ swn_fade cfg * 1000000) -- 1_000_000 needs GHC 8.6.x and up
|
|
void $ destroyWindow dpy w
|
|
closeDisplay dpy
|
|
where
|
|
cfg' :: WindowConfig
|
|
cfg' = def{ winFont = swn_font cfg, winBg = swn_bgcolor cfg, winFg = swn_color cfg }
|
|
|
|
-- | Last shown workspace.
|
|
newtype LastShown = LastShown WorkspaceId
|
|
deriving (Show, Read)
|
|
|
|
instance ExtensionClass LastShown where
|
|
initialValue :: LastShown
|
|
initialValue = LastShown ""
|
|
|
|
extensionType :: LastShown -> StateExtension
|
|
extensionType = PersistentExtension
|