hackage.haskell.org

XMonad.Hooks.EwmhDesktops

Usage

You can use this module with the following in your ~/.xmonad/xmonad.hs:

import XMonad
import XMonad.Hooks.EwmhDesktops
main = xmonad $ … . ewmhFullscreen . ewmh . … $ def{…}

or, if fullscreen handling is not desired, just

main = xmonad $ … . ewmh . … $ def{…}

You may also be interested in docks and withUrgencyHook, which provide support for other parts of the EWMH specification.

Customization

It's possible to customize the behaviour of ewmh in several ways:

Sorting/filtering of workspaces

The list of workspaces exposed to EWMH pagers (like taffybar and polybar) and clients (such as wmctrl and xdotool) may be sorted and/or filtered via a user-defined function.

To show visible workspaces first, one may switch to a Xinerama-aware sorting function:

import XMonad.Util.WorkspaceCompare
mySort = getSortByXineramaRule
main = xmonad $ … . setEwmhWorkspaceSort mySort . ewmh . … $ def{…}

Another useful example is not exposing the hidden scratchpad workspace:

import XMonad.Util.NamedScratchpad
import XMonad.Util.WorkspaceCompare
myFilter = filterOutWs [scratchpadWorkspaceTag]
main = xmonad $ … . addEwmhWorkspaceSort (pure myFilter) . ewmh . … $ def{…}

Renaming of workspaces

The workspace names exposed to EWMH pagers and other clients (e.g. arbtt) may be altered using a similar interface to ppRename. To configure workspace renaming, use addEwmhWorkspaceRename.

As an example, to expose workspaces uppercased:

import Data.Char
myRename :: String -> WindowSpace -> String
myRename s _w = map toUpper s
main = xmonad $ … . addEwmhWorkspaceRename (pure myRename) . ewmh . … $ def{…}

Some modules like XMonad.Actions.WorkspaceNames provide ready-made integrations:

import XMonad.Actions.WorkspaceNames
main = xmonad $ … . workspaceNamesEwmh . ewmh . … $ def{…}

The above ensures workspace names are exposed through EWMH.

Window activation

When a client sends a _NET_ACTIVE_WINDOW request to activate a window, by default that window is activated by invoking the doFocus ManageHook. The EWMH specification suggests that a window manager may instead just mark the window as urgent, and this can be achieved using the following:

import XMonad.Hooks.UrgencyHook
main = xmonad $ … . setEwmhActivateHook doAskUrgent . ewmh . … $ def{…}

One may also wish to ignore activation requests from certain applications entirely:

import XMonad.Hooks.ManageHelpers
myActivateHook :: ManageHook
myActivateHook =
  className /=? "Google-chrome" <&&> className /=? "google-chrome" --> doFocus
main = xmonad $ … . setEwmhActivateHook myActivateHook . ewmh . … $ def{…}

Arbitrarily complex hooks can be used. This last example marks Chrome windows as urgent and focuses everything else:

myActivateHook :: ManageHook
myActivateHook = composeOne
  [ className =? "Google-chrome" <||> className =? "google-chrome" -?> doAskUrgent
  , pure True -?> doFocus ]

See XMonad.ManageHook, XMonad.Hooks.ManageHelpers and XMonad.Hooks.Focus for functions that can be useful here.

Standalone hooks (deprecated)

ewmhDesktopsLogHook :: X () Source #

Deprecated: Use ewmh instead.

Notifies pagers and window lists, such as those in the gnome-panel of the current state of workspaces and windows.

ewmhDesktopsLogHookCustom :: WorkspaceSort -> X () Source #

Deprecated: Use ewmh and addEwmhWorkspaceSort instead.

Generalized version of ewmhDesktopsLogHook that allows an arbitrary user-specified function to sort/filter the workspace list (post-sorting).

ewmhDesktopsEventHook :: Event -> X All Source #

Deprecated: Use ewmh instead.

Intercepts messages from pagers and similar applications and reacts on them.

Currently supports:

  • _NET_CURRENT_DESKTOP (switching desktops)
  • _NET_WM_DESKTOP (move windows to other desktops)
  • _NET_ACTIVE_WINDOW (activate another window, changing workspace if needed)
  • _NET_CLOSE_WINDOW (close window)

fullscreenEventHook :: Event -> X All Source #

Deprecated: Use ewmhFullscreen instead.

An event hook to handle applications that wish to fullscreen using the _NET_WM_STATE protocol. This includes users of the gtk_window_fullscreen() function, such as Totem, Evince and OpenOffice.org.

Note this is not included in ewmh.