From e5c89fe04061392cf102bb5286bbd203b81099de Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Mon, 11 Apr 2022 17:23:42 -0600 Subject: Add clickable workspaces to XMobar. This is using xdotool to send a keystroke, which is not the best way to do this. In fact, a proper server protocol would be better, but this is how it is at the momement unfortunately. There is a problem where trying to use xdotool to send a key for a multibyte character will cause all events to freeze on XMonad for some reason, so these actions are guarded so only 'a-zA-Z0-9' are clickable and the rest are not, which is /okay/, I don't use unicode workspaces that often. --- src/Rahm/Desktop/XMobarLog.hs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/Rahm') diff --git a/src/Rahm/Desktop/XMobarLog.hs b/src/Rahm/Desktop/XMobarLog.hs index 8b0ad72..0f67ed4 100644 --- a/src/Rahm/Desktop/XMobarLog.hs +++ b/src/Rahm/Desktop/XMobarLog.hs @@ -12,6 +12,7 @@ import XMonad.Util.NamedWindows (getName) import XMonad.Util.Run (spawnPipe) import XMonad (X) import Rahm.Desktop.Lib (getPopulatedWorkspaces, WorkspaceState(..)) +import Text.Printf import qualified XMonad as X import qualified XMonad.StackSet as S @@ -43,6 +44,7 @@ xMobarLogHook (XMobarLog xmproc) = do X.liftIO $ do hPutStrLn xmproc $ trunc 80 $ execWriter $ do + tell " " tell layoutXpm tell $ " │ " @@ -51,12 +53,20 @@ xMobarLogHook (XMobarLog xmproc) = do Current -> tell "" Visible -> tell "" Hidden -> tell "" - tell (S.tag ws) + + tell $ toAction $ S.tag ws tell " " tell $ "" tell $ title tell $ "" + + where + toAction [ch] | (ch >= 'A' && ch <= 'Z') || + (ch >= 'a' && ch <= 'z') || + (ch >= '0' && ch <= '9') = + printf "%s" [ch] [ch] + toAction ch = ch -- Truncate an XMobar string to the provided number of _visible_ characters. -- This is to keep long window titles from overrunning the whole bar. -- cgit