Copyright | (c) Will Pierlot <willp@outlook.com.au> |
---|---|
License | BSD3-style (see LICENSE) |
Maintainer | Will Pierlot <willp@outlook.com.au> |
Stability | unstable |
Portability | unportable |
Safe Haskell | None |
Language | Haskell98 |
Dynamically augment workspace names logged to a status bar based on the contents (windows) of the workspace.
Synopsis
- iconsPP :: Query [String] -> PP -> X PP
- dynamicLogIconsWithPP :: Query [String] -> PP -> X ()
- appIcon :: String -> Query [String]
- dynamicIconsPP :: IconConfig -> PP -> X PP
- getWorkspaceIcons :: IconConfig -> X (String -> WindowSpace -> String)
- data IconConfig = IconConfig {
- iconConfigIcons :: Query [String]
- iconConfigFmt :: WorkspaceId -> [String] -> String
- iconConfigFilter :: Maybe (Stack Window) -> X [Window]
- iconsFmtAppend :: ([String] -> String) -> WorkspaceId -> [String] -> String
- iconsFmtReplace :: ([String] -> String) -> WorkspaceId -> [String] -> String
- wrapUnwords :: String -> String -> [String] -> String
- iconsGetAll :: Maybe (Stack Window) -> X [Window]
- iconsGetFocus :: Maybe (Stack Window) -> X [Window]
Usage
Dynamically augment Workspace's WorkspaceId
as shown on a status bar
based on the Window
s inside the Workspace.
Icons are specified by a Query [String]
, which is something like a
ManageHook
(and uses the same syntax) that returns a list of String
s
(icons). This Query
is evaluated for each window and the results are
joined together. appIcon
is a useful shortcut here.
For example:
myIcons :: Query [String] myIcons = composeAll [ className =? "discord" --> appIcon "\xfb6e" , className =? "Discord" --> appIcon "\xf268" , className =? "Firefox" --> appIcon "\63288" , className =? "Spotify" <||> className =? "spotify" --> appIcon "阮" ]
then you can add it to your XMonad.Hooks.StatusBar config:
myBar = statusBarProp "xmobar" (iconsPP myIcons myPP) main = xmonad . withSB myBar $ … $ def
Here is an example of this
Note: You can use any string you want here. The example shown here uses NerdFont Icons to represent open applications.
If you want to customize formatting and/or combine this with other
PP
extensions like XMonad.Util.ClickableWorkspaces, here's a more
advanced example how to do that:
myIconConfig = def{ iconConfigIcons = myIcons, iconConfigFmt = iconsFmtAppend concat } myBar = statusBarProp "xmobar" (clickablePP =<< dynamicIconsPP myIconConfig myPP) main = xmonad . withSB myBar . … $ def
This can be also used with XMonad.Hooks.DynamicLog:
main = xmonad $ … $ def { logHook = dynamicLogIconsWithPP myIcons xmobarPP , … }
or with more customziation:
myIconConfig = def{ iconConfigIcons = myIcons, iconConfigFmt = iconsFmtAppend concat } main = xmonad $ … $ def { logHook = xmonadPropLog =<< dynamicLogString =<< clickablePP =<< dynamicIconsPP myIconConfig xmobarPP , … }
Creating Dynamic Icons
Adjusts the PP
with the given IconSet
dynamicLogIconsWithPP Source #
Adjusts the PP
and then runs dynamicLogWithPP
Customization
dynamicIconsPP :: IconConfig -> PP -> X PP Source #
Modify a pretty-printer, PP
, to augment
workspace names with icons based on the contents (windows) of the workspace.
getWorkspaceIcons :: IconConfig -> X (String -> WindowSpace -> String) Source #
Returns a function for ppRename
that augments workspaces with icons
according to the provided IconConfig
.
data IconConfig Source #
Datatype for expanded Icon
configurations
IconConfig | |
|
Instances
Default IconConfig Source # | |
Defined in XMonad.Hooks.DynamicIcons def :: IconConfig # |
iconsFmtAppend :: ([String] -> String) -> WorkspaceId -> [String] -> String Source #
iconConfigFmt
that appends icons to the workspace name.
First parameter specifies how to concatenate multiple icons. Useful values
include: concat
, unwords
, wrapUnwords
.
Examples
>>>
iconsFmtAppend concat "1" []
"1"
>>>
iconsFmtAppend concat "1" ["A", "B"]
"1:AB"
iconsFmtReplace :: ([String] -> String) -> WorkspaceId -> [String] -> String Source #
iconConfigFmt
that replaces the workspace name with icons, if any.
First parameter specifies how to concatenate multiple icons. Useful values
include: concat
, unwords
, wrapUnwords
.
Examples
>>>
iconsFmtReplace concat "1" []
"1"
>>>
iconsFmtReplace concat "1" ["A", "B"]
"AB"
>>>
iconsFmtReplace (wrapUnwords "{" "}") "1" ["A", "B"]
"{A B}"
wrapUnwords :: String -> String -> [String] -> String Source #
Join words with spaces, and wrap the result in delimiters unless there was exactly one element.
Examples
>>>
wrapUnwords "{" "}" ["A", "B"]
"{A B}"
>>>
wrapUnwords "{" "}" ["A"]
"A"
>>>
wrapUnwords "{" "}" []
""
iconsGetAll :: Maybe (Stack Window) -> X [Window] Source #
iconConfigFilter
that shows all windows of every workspace.
iconsGetFocus :: Maybe (Stack Window) -> X [Window] Source #
iconConfigFilter
that shows only the focused window for each workspace.