aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2022-04-11 17:23:42 -0600
committerJosh Rahm <joshuarahm@gmail.com>2022-10-09 12:19:46 -0600
commite5c89fe04061392cf102bb5286bbd203b81099de (patch)
tree8a043c6b9ab24ac0d9db7503e0df90b18637aa21 /src
parent074987f0f5ebdf608aea6c2d86f70fd5fbc6b640 (diff)
downloadrde-e5c89fe04061392cf102bb5286bbd203b81099de.tar.gz
rde-e5c89fe04061392cf102bb5286bbd203b81099de.tar.bz2
rde-e5c89fe04061392cf102bb5286bbd203b81099de.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/Rahm/Desktop/XMobarLog.hs12
1 files changed, 11 insertions, 1 deletions
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 $ "<fc=#404040> │ </fc>"
@@ -51,12 +53,20 @@ xMobarLogHook (XMobarLog xmproc) = do
Current -> tell "<fn=1><fc=#ff8888>"
Visible -> tell "<fn=6><fc=#8888ff>"
Hidden -> tell "<fn=2><fc=#888888>"
- tell (S.tag ws)
+
+ tell $ toAction $ S.tag ws
tell " </fc></fn>"
tell $ "<fc=#404040>│ </fc><fc=#a0a0a0><fn=3>"
tell $ title
tell $ "</fn></fc>"
+
+ where
+ toAction [ch] | (ch >= 'A' && ch <= 'Z') ||
+ (ch >= 'a' && ch <= 'z') ||
+ (ch >= '0' && ch <= '9') =
+ printf "<action=`xdotool key 'Hyper_L+g' '%s'`>%s</action>" [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.