[xmonad] run a program when switching to a workspace

Brent Yorgey byorgey at seas.upenn.edu
Wed May 27 22:52:04 EDT 2009


On Mon, May 25, 2009 at 08:47:42AM -0600, Sergey Manucharian wrote:
> Hi folks,
> 
> How can I configure xmonad to run a program when switching to a
> particular workspace? Example: I want to run a script changing the
> keyboard layout to "us" unconditionally when I'm on particular
> workspaces (with ssh, rdesktop etc.).

The easiest way to do this is to add an action to your logHook that
checks the current workspace, and sets the keyboard layout if it is
the desired workspace:
 
  ...
  logHook = ...other stuff... >> checkKBLayout

  ...

  checkKBLayout :: X ()
  checkKBLayout = do
    curTag <- gets (W.currentTag . windowset)
    when (curTag == "foo") $ spawn "set keyboard layout"

Of course, "foo" should be replaced with whatever workspace you want,
and "set keyboard layout" should be replaced with a suitable command
for setting the keyboard layout.

-Brent


More information about the xmonad mailing list