Difference between revisions of "XMonadContribTour"

From HaskellWiki
Jump to: navigation, search
(how to get screen to pass bell)
(Deleting page that hasn't been edited for over 10 years)
Line 1: Line 1:
== Meta ==
This page pretends to be like the XMonad guided tour for new users, but applied to the XMonad Contrib. Mainly because I think it's very difficult for newcomers to discover what extra features XMonad provides. Haddock documentation is pretty useful when you know what are you looking for, but when you're looking around to find if some feature is implemented already, the way that the documentation is indexed (by alphabetical order) doesn't help much.
== Showing XMonad state in statusbars ==
XMonad provides a contrib module that outputs the state changes of XMonad (worskpace change, which workspace is active if a workspace has windows or not, etc) into a external statusbar programs like [http://gorgias.mine.nu/xmobar/ xmobar] or [http://gotmor.googlepages.com/dzen dzen].
This module is called [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Hooks-DynamicLog.html XMonad.Hooks.DynamicLog] it provides some drop-in loggers and some helper functions to make your own logger.
XXX: document the new statusBar
The more interesting one is [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Hooks-DynamicLog.html#v%3AdynamicLogWithPP DynamicLogWithPP] that's a DynamicLog with a Pretty Printer. The DynamicLog contrib module ships with some PP ready to be used, for example one for xmobar, and one for dzen.
You can have your status fed into a xmobar by adding:
import XMonad.Hooks.DynamicLog
import XMonad.Util.Run -- for spawnPipe and hPutStrLn
main = do
h <- spawnPipe "xmobar"
xmonad $ defaultConfig {
logHook = dynamicLogWithPP $ xmobarPP { ppOutput = hPutStrLn h }
To do feed the output to a dzen statusbar you have to add:
import XMonad.Hooks.DynamicLog
import XMonad.Util.Run -- for spawnPipe and hPutStrLn
main = do
h <- spawnPipe "dzen OPTIONS"
xmonad $ defaultConfig {
logHook = dynamicLogWithPP $ dzenPP { ppOutput = hPutStrLn h }
xmobarPP and dzenPP are default PPs ready to be used with each application, but the real power of DynamicLogWithPP lies in that you can make your own PP, you
can start by modifing and existing one or doing one by sractch, here's [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Hooks-DynamicLog.html#t%3APP the PP type] for reference.
=== Making space for the statusbar ===
As XMonad by default uses all screen space to display and arrange it's windows, we need to find a way to show the statusbar.
There is a little module called [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Hooks-ManageDocks.html XMonad.Hooks.ManageDocks], that automatically makes room for panels (and statusbars).
The configuration nedded to run ManageDocks looks like this:
import XMonad
import XMonad.Hooks.ManageDocks
main = xmonad defaultConfig
{ manageHook = manageDocks <+> manageHook defaultConfig
, layoutHook = avoidStruts $ layoutHook defaultConfig
XXX: show a shot of the statusbar.
== Removing unneded borders around windows ==
So, you've configured XMonad to draw a nice red border around focused windows, but you find that when you have only one window open the border is still there, and because is the only window in the screen we don't need a big red border to signal us that we've focused that windows.
That's where [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-LayoutnoBorders.html XMonad.Layout.NoBorders] enters.
It provides two utilities, [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Layout-NoBorders.html#v%3AsmartBorders smartBorders] and [http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Layout-NoBorders.html#v%3AnoBorders noBorders], the former removes the borders from windows if they are the only window in the workspace, the latter removes all borders from the windows in the Worskpace
smartBorders, and noBorders can be applied to an specific Layout or a group of Layouts, so if you want your Full layuot don't render borders you will have to
add something like this to you configuration:
layoutHook = ... ||| noBorders Full ||| ...
To add smartBorders to all the Layouts (good idea) you'll have to add:
layoutHook = smartBorders $ (tiled ||| (Mirror tiled) ||| Full)
== More options in layout selection ==
== More powerful window management ==
== Getting notifications on events ==
The programs running on your windows can try to catch your attention setting what's called the "Urgency Hint" basically it means "this window needs your attention".
XMonad has some features to act uppon a window setting its urgency hint, they are located in the [http://hackage.haskell.org/packages/archive/xmonad-contrib/0.8.1/doc/html/XMonad-Hooks-UrgencyHook.html XMonad.Hooks.UrgencyHook].
This module allows you to pop-up a custom dzen with a message, use different colours in your DynamicLog for workspaces with urgent windows on them and provides you a keybind to focus the urgent window.
To have dzen flash for a period of time add this to your config:
main = xmonad $ withUrgencyHook dzenUrgencyHook { args = ["-bg", "darkgreen", "-xs", "1"] }
$ defaultConfig
You can provide the arguments you want to the dzen call, so it's very flexible.
If you don't want it flashing things but want to change your DynamicLog use this:
main = xmonad $ withUrgencyHook NoUrgencyHook
$ defaultConfig
You'll have to config you ppUrgent in your PP to make the changes you wan't to show.
XXX: show a screenshot of every one in action
=== Configuring some programs to notify xmonad of urgency ===
==== URxvt ====
If you set in your .Xresourses or .Xdefaults
URxvt.urgentOnBell: true
The terminal window will get the urgency hint when the running program inside makes a "bell", it's realy useful for Irssi notifications, mutt mail arrivings, etc.
==== Irssi ====
You have to enable the beeping feature of Irssi for it to tell the terminal program to set the urgency hint on the window.
/set bell_beeps ON
If you use it inside a GNU Screen you should set it to have audible beeps.
==== GNU Screen ====
Screen passes the bell_msg to the terminal when one of it's windows sends a bell '^G'. Without a '^G' in the bell_msg, the the terminal will not be notified to possibly set the urgency hint.
bell_msg "bell: %n (%t) [%w:%s]^G"
==== Pidgin ====
Pidgin ships with a "Message Notification" plugin, you must activate it and configure it to set the window manager urgency hint.
== Modifiying existing layouts ==
LayoutModifiers, tabbed, withIM
== Having a floating terminal always at your fingertips ==
[http://hackage.haskell.org/packages/archive/xmonad-contrib/0.8.1/doc/html/XMonad-Util-Scratchpad.html XMonad.Util.Scratchpad] provides the ability to set a keybind to launch a preconfigured floating terminal that will hide when you press the keybind again. Preety handy, trust me. Its location and size is even configurable so you can make it like a Quake-style terminal (tilda, yakuake) if you really want to.
The documentation is very straightforward on how to configure it, you can see it in action here:
XXX: show a show of a cluttered workspace and a scratchpad floating
== Launching programs in a better way ==

Revision as of 14:14, 6 February 2021