mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -07:00
Add XMonad.Util.ClickableWorkspaces module (#364)
This module enables clickable workspace tags in XMobar in a relatively unobtrusive fashion. Inspired by https://arch-ed.dk/xmobar-clickable-workspaces
This commit is contained in:
parent
3dc49721b6
commit
c7afc2904b
@ -62,6 +62,12 @@
|
|||||||
A version of `XMonad.Prompt.Shell` that lets you use completions supplied by
|
A version of `XMonad.Prompt.Shell` that lets you use completions supplied by
|
||||||
zsh.
|
zsh.
|
||||||
|
|
||||||
|
* `XMonad.Util.ClickableWorkspaces`
|
||||||
|
|
||||||
|
Provides clickablePP, which when applied to the PP pretty-printer used by
|
||||||
|
`XMonad.Hooks.DynamicLog.dynamicLogWithPP`, will make the workspace tags
|
||||||
|
clickable in XMobar (for switching focus).
|
||||||
|
|
||||||
### Bug Fixes and Minor Changes
|
### Bug Fixes and Minor Changes
|
||||||
|
|
||||||
* `XMonad.Util.NamedScratchpad`
|
* `XMonad.Util.NamedScratchpad`
|
||||||
|
@ -1111,6 +1111,11 @@ external utilities.
|
|||||||
|
|
||||||
A non complete list with a brief description:
|
A non complete list with a brief description:
|
||||||
|
|
||||||
|
* "XMonad.Util.ClickableWorkspaces":
|
||||||
|
Provides clickablePP, which when applied to the PP pretty-printer used by
|
||||||
|
'XMonad.Hooks.DynamicLog.dynamicLogWithPP', will make the workspace tags
|
||||||
|
clickable in XMobar (for switching focus).
|
||||||
|
|
||||||
* "XMonad.Util.Cursor": configure the default cursor/pointer glyph.
|
* "XMonad.Util.Cursor": configure the default cursor/pointer glyph.
|
||||||
|
|
||||||
* "XMonad.Util.CustomKeys": configure key bindings (see
|
* "XMonad.Util.CustomKeys": configure key bindings (see
|
||||||
|
60
XMonad/Util/ClickableWorkspaces.hs
Normal file
60
XMonad/Util/ClickableWorkspaces.hs
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
-------------------------------------------------------------------------------
|
||||||
|
-- |
|
||||||
|
-- Module : XMonad.Util.ClickableWorkspaces
|
||||||
|
-- Copyright : (c) Geoff deRosenroll <geoffderosenroll@gmail.com>
|
||||||
|
-- License : BSD3-style (see LICENSE)
|
||||||
|
--
|
||||||
|
-- Maintainer : Geoff deRosenroll <geoffderosenroll@gmail.com>
|
||||||
|
-- Stability : unstable
|
||||||
|
-- Portability : unportable
|
||||||
|
--
|
||||||
|
-- Provides @clickablePP@, which when applied to the PP pretty-printer used by
|
||||||
|
-- the "XMonad.Hooks.DynamicLog" hook, will make the workspace tags clickable in
|
||||||
|
-- XMobar (for switching focus).
|
||||||
|
--
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
module XMonad.Util.ClickableWorkspaces (
|
||||||
|
-- * Usage
|
||||||
|
-- $usage
|
||||||
|
clickablePP
|
||||||
|
) where
|
||||||
|
|
||||||
|
import XMonad
|
||||||
|
import XMonad.Util.WorkspaceCompare (getWsIndex)
|
||||||
|
import XMonad.Hooks.DynamicLog (xmobarAction, xmobarRaw, PP(..))
|
||||||
|
|
||||||
|
-- $usage
|
||||||
|
-- However you have set up your PP, apply @clickablePP@ to it, and bind the result
|
||||||
|
-- to "XMonad.Hooks.DynamicLog"\'s dynamicLogWithPP like so:
|
||||||
|
--
|
||||||
|
-- > logHook = clickablePP xmobarPP { ... } >>= dynamicLogWithPP
|
||||||
|
--
|
||||||
|
-- * Requirements:
|
||||||
|
-- * wmctrl on system (in path)
|
||||||
|
-- * "XMonad.Hooks.EwmhDesktops" for wmctrl support (see Hackage docs for setup)
|
||||||
|
-- * use of UnsafeStdinReader in xmobarrc (rather than StdinReader)
|
||||||
|
|
||||||
|
|
||||||
|
clickableWrap :: Int -> String -> String
|
||||||
|
clickableWrap i ws = xmobarAction ("wmctrl -s " ++ show i) "1" $ xmobarRaw ws
|
||||||
|
|
||||||
|
-- Use index of workspace in users config to target workspace with wmctrl switch.
|
||||||
|
getClickable :: X (WorkspaceId -> String)
|
||||||
|
getClickable = do
|
||||||
|
wsIndex <- getWsIndex
|
||||||
|
return $ \ws -> case wsIndex ws of
|
||||||
|
Just idx -> clickableWrap idx ws
|
||||||
|
Nothing -> ws
|
||||||
|
|
||||||
|
-- | Apply clickable wrapping to all workspace fields in given PP.
|
||||||
|
clickablePP :: PP -> X PP
|
||||||
|
clickablePP pp = do
|
||||||
|
clickable <- getClickable
|
||||||
|
return $
|
||||||
|
pp { ppCurrent = ppCurrent pp . clickable
|
||||||
|
, ppVisible = ppVisible pp . clickable
|
||||||
|
, ppHidden = ppHidden pp . clickable
|
||||||
|
, ppHiddenNoWindows = ppHiddenNoWindows pp . clickable
|
||||||
|
, ppUrgent = ppUrgent pp . clickable
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user