Xmonad and uzbl-browser
Dienstag, 6. September 2011
Every release of Opera seems to add more bugs¹ and useless features², whereas Firefox is featureless and slow without or feature-rich and ineffable slow with Add-ons. Time for an alternative! What I want is a small browser with external configurable handlers. What I don't need is qt-bloat, a Firefox clone or something with lua in it. uzbl seems to fit, but I'm tired of learning new shortcuts for tabbing implementations. Everyone and his brother integrate tabs (terminal multiplexer, terminal, browser, editor...) but only one application should obviously manage tabs - the window manager. It turned out that my original configuration of xmonad wasn't the optimal solution. I'd like to have the following behaviour:
First workspace: keep master, switch focus to new window
Second to fourth workspace: switch master and focus
Fifth workspace (for browsing): keep master and focus and use tabbed layout (open new links/tabs in background)
These are the steps that were necessary to achieve this:
1. copy xmonad-contrib-0.9.2/XMonad/Hooks/InsertPosition.hs to ./xmonad/lib/
2. apply the patch (sorry, no google account and no desire to install darcs again):
--- InsertPosition.hs
+++ InsertPositionNew.hs
@@ -16,15 +16,16 @@
module XMonad.Hooks.InsertPosition (
-- * Usage
-- $usage
- insertPosition
+ insertPosition,
+ insertPositionPerWorkspace
,Focus(..), Position(..)
) where
-import XMonad(ManageHook, MonadReader(ask))
+import XMonad(ManageHook, MonadReader(ask), WorkspaceId)
import qualified XMonad.StackSet as W
import Control.Applicative((<$>))
import Data.Maybe(fromMaybe)
-import Data.List(find)
+import Data.List(find,lookup)
import Data.Monoid(Endo(Endo))
-- $usage
@@ -44,26 +45,30 @@
-- | insertPosition. A manage hook for placing new windows. XMonad's default is
-- the same as using: @insertPosition Above Newer@.
insertPosition :: Position -> Focus -> ManageHook
-insertPosition pos foc = Endo . g <$> ask
+insertPosition = insertPositionPerWorkspace []
+
+-- | Specify an insertPosition for a particular Workspace.
+insertPositionPerWorkspace :: [(WorkspaceId, (Position, Focus))] -> Position -> Focus -> ManageHook
+insertPositionPerWorkspace l pos foc = Endo . g <$> ask
where
- g w = viewingWs w (updateFocus w . ins w . W.delete w)
- ins w = (\f ws -> fromMaybe id (W.focusWindow <$> W.peek ws) $ f ws) $
- case pos of
+ g w = viewingWs w (\i -> updateFocus i w . ins i w . W.delete w)
+ ins i w = (\f ws -> fromMaybe id (W.focusWindow <$> W.peek ws) $ f ws) $
+ case fst $ fromMaybe (pos,foc) (lookup i l) of
Master -> W.insertUp w . W.focusMaster
End -> insertDown w . W.modify' focusLast'
Above -> W.insertUp w
Below -> insertDown w
- updateFocus =
- case foc of
+ updateFocus i =
+ case snd $ fromMaybe (pos,foc) (lookup i l) of
Older -> const id
Newer -> W.focusWindow
-- | Modify the StackSet when the workspace containing w is focused
-viewingWs :: (Eq a, Eq s, Eq i, Show i) =>a-> (W.StackSet i l a s sd -> W.StackSet i l a s sd)-> W.StackSet i l a s sd-> W.StackSet i l a s sd
+viewingWs :: (Eq a, Eq s, Eq i, Show i) =>a-> (i -> W.StackSet i l a s sd -> W.StackSet i l a s sd)-> W.StackSet i l a s sd-> W.StackSet i l a s sd
viewingWs w f = do
i <- W.tag . W.workspace . W.current
ws <- find (elem w . W.integrate' . W.stack) . W.workspaces
- maybe id (fmap (W.view i . f) . W.view . W.tag) ws
+ maybe id (fmap (W.view i . f i) . W.view . W.tag) ws
-- | 'insertDown' and 'focusLast' belong in XMonad.StackSet?
insertDown :: (Eq a) => a -> W.StackSet i l a s sd -> W.StackSet i l a s sd
3. reconfigure ./xmonad/xmonad.hs
add imports:
import InsertPositionNew
import XMonad.Hooks.ManageHelpers
import XMonad.Layout.PerWorkspace
add shortcut for uzbl-browser:
, ((modm, xK_u), spawn "uzbl-browser")
change layout hook:
myLayout =
modWorkspaces myWorkspaces avoidStruts $
onWorkspace "5:www" simpleTabbedAlways $
tiled ||| Mirror tiled ||| simpleTabbedAlways ||| Full
where
-- default tiling algorithm partitions the screen into two panes
tiled = Tall nmaster delta ratio
-- The default number of windows in the master pane
nmaster = 1
-- Default proportion of screen occupied by master pane
-- ratio = 1/2
ratio = 7/10
-- Percent of screen to increment by when resizing panes
-- delta = 3/100
delta = 5/100
create manage hooks
myManageHookFloat = composeAll
[ className =? "Gimp" --> doFloat
, className =? "MPlayer" --> doFloat
,(className =? "Firefox" <&&> role =? "Manager" ) --> doFloat
] <+> composeOne [
isDialog -?> doCenterFloat
]
where role = stringProperty "WM_WINDOW_ROLE"
myManageHookShift = composeAll
[ className =? "Uzbl-core" --> doShift "5:www"
, className =? "Firefox" --> doShift "5:www" ]
myManageHookPosition = insertPositionPerWorkspace [("1",(Below,Newer)),("5:www",(Below,Older))] Above Newer
combine manage hooks and override the default config:
manageHook = myManageHookFloat <+> myManageHookPosition <+> myManageHookShift,
Done.

¹ last one: the bookmark menu needs 30s to load all bookmarks
² webserver(!), torrent- and unusable mail client
First workspace: keep master, switch focus to new window
+---------------+ +-----------+---+
| | | | 2 |
| | | | |
| 1 | -> | 1 | f |
| (focus) | | | o |
| | | | c |
| | | | . |
+---------------+ +-----------+---+
Second to fourth workspace: switch master and focus
+---------------+ +-----------+---+
| | | | 1 |
| | | | |
| 1 | -> | 2 | |
| (focus) | | (focus) | |
| | | | |
| | | | |
+---------------+ +-----------+---+
Fifth workspace (for browsing): keep master and focus and use tabbed layout (open new links/tabs in background)
+---------------+ +-------+-------+
+---------------+ +-------+-------+
| | | |
| 1 | -> | 1 |
| (focus) | | (focus) |
| | | |
| | | |
+---------------+ +---------------+
These are the steps that were necessary to achieve this:
1. copy xmonad-contrib-0.9.2/XMonad/Hooks/InsertPosition.hs to ./xmonad/lib/
2. apply the patch (sorry, no google account and no desire to install darcs again):
--- InsertPosition.hs
+++ InsertPositionNew.hs
@@ -16,15 +16,16 @@
module XMonad.Hooks.InsertPosition (
-- * Usage
-- $usage
- insertPosition
+ insertPosition,
+ insertPositionPerWorkspace
,Focus(..), Position(..)
) where
-import XMonad(ManageHook, MonadReader(ask))
+import XMonad(ManageHook, MonadReader(ask), WorkspaceId)
import qualified XMonad.StackSet as W
import Control.Applicative((<$>))
import Data.Maybe(fromMaybe)
-import Data.List(find)
+import Data.List(find,lookup)
import Data.Monoid(Endo(Endo))
-- $usage
@@ -44,26 +45,30 @@
-- | insertPosition. A manage hook for placing new windows. XMonad's default is
-- the same as using: @insertPosition Above Newer@.
insertPosition :: Position -> Focus -> ManageHook
-insertPosition pos foc = Endo . g <$> ask
+insertPosition = insertPositionPerWorkspace []
+
+-- | Specify an insertPosition for a particular Workspace.
+insertPositionPerWorkspace :: [(WorkspaceId, (Position, Focus))] -> Position -> Focus -> ManageHook
+insertPositionPerWorkspace l pos foc = Endo . g <$> ask
where
- g w = viewingWs w (updateFocus w . ins w . W.delete w)
- ins w = (\f ws -> fromMaybe id (W.focusWindow <$> W.peek ws) $ f ws) $
- case pos of
+ g w = viewingWs w (\i -> updateFocus i w . ins i w . W.delete w)
+ ins i w = (\f ws -> fromMaybe id (W.focusWindow <$> W.peek ws) $ f ws) $
+ case fst $ fromMaybe (pos,foc) (lookup i l) of
Master -> W.insertUp w . W.focusMaster
End -> insertDown w . W.modify' focusLast'
Above -> W.insertUp w
Below -> insertDown w
- updateFocus =
- case foc of
+ updateFocus i =
+ case snd $ fromMaybe (pos,foc) (lookup i l) of
Older -> const id
Newer -> W.focusWindow
-- | Modify the StackSet when the workspace containing w is focused
-viewingWs :: (Eq a, Eq s, Eq i, Show i) =>a-> (W.StackSet i l a s sd -> W.StackSet i l a s sd)-> W.StackSet i l a s sd-> W.StackSet i l a s sd
+viewingWs :: (Eq a, Eq s, Eq i, Show i) =>a-> (i -> W.StackSet i l a s sd -> W.StackSet i l a s sd)-> W.StackSet i l a s sd-> W.StackSet i l a s sd
viewingWs w f = do
i <- W.tag . W.workspace . W.current
ws <- find (elem w . W.integrate' . W.stack) . W.workspaces
- maybe id (fmap (W.view i . f) . W.view . W.tag) ws
+ maybe id (fmap (W.view i . f i) . W.view . W.tag) ws
-- | 'insertDown' and 'focusLast' belong in XMonad.StackSet?
insertDown :: (Eq a) => a -> W.StackSet i l a s sd -> W.StackSet i l a s sd
3. reconfigure ./xmonad/xmonad.hs
add imports:
import InsertPositionNew
import XMonad.Hooks.ManageHelpers
import XMonad.Layout.PerWorkspace
add shortcut for uzbl-browser:
, ((modm, xK_u), spawn "uzbl-browser")
change layout hook:
myLayout =
modWorkspaces myWorkspaces avoidStruts $
onWorkspace "5:www" simpleTabbedAlways $
tiled ||| Mirror tiled ||| simpleTabbedAlways ||| Full
where
-- default tiling algorithm partitions the screen into two panes
tiled = Tall nmaster delta ratio
-- The default number of windows in the master pane
nmaster = 1
-- Default proportion of screen occupied by master pane
-- ratio = 1/2
ratio = 7/10
-- Percent of screen to increment by when resizing panes
-- delta = 3/100
delta = 5/100
create manage hooks
myManageHookFloat = composeAll
[ className =? "Gimp" --> doFloat
, className =? "MPlayer" --> doFloat
,(className =? "Firefox" <&&> role =? "Manager" ) --> doFloat
] <+> composeOne [
isDialog -?> doCenterFloat
]
where role = stringProperty "WM_WINDOW_ROLE"
myManageHookShift = composeAll
[ className =? "Uzbl-core" --> doShift "5:www"
, className =? "Firefox" --> doShift "5:www" ]
myManageHookPosition = insertPositionPerWorkspace [("1",(Below,Newer)),("5:www",(Below,Older))] Above Newer
combine manage hooks and override the default config:
manageHook = myManageHookFloat <+> myManageHookPosition <+> myManageHookShift,
Done.

¹ last one: the bookmark menu needs 30s to load all bookmarks
² webserver(!), torrent- and unusable mail client
Firefox suckt
Mittwoch, 13. Januar 2010
Peacekeeper
Montag, 16. März 2009
Mal kurz Futuremarks neuen JS-Benchmark laufen lassen. Ich lege bei Browsern zwar mehr Wert auf Benutzbarkeit, Opera hat trotzdem gewonnen. ;)
Firefox 3.0.5 mit Darstellungsfehlern:

Opera 9.64:

139:114 ist kein Traumergebnis, mein Rechner ist eben nicht mehr der jüngste.
Aktualisierung 20.03.2009:
WinXp Opera 9.64: 153
WinXP IE7: Absturz
WinXP IE8: Absturz
Nicht ganz so nichtssagende Benchmarks, zB.: Dromaeo, Sunspider, V8 Benchmark
Firefox 3.0.5 mit Darstellungsfehlern:

Opera 9.64:

139:114 ist kein Traumergebnis, mein Rechner ist eben nicht mehr der jüngste.
Aktualisierung 20.03.2009:
WinXp Opera 9.64: 153
WinXP IE7: Absturz
WinXP IE8: Absturz
Nicht ganz so nichtssagende Benchmarks, zB.: Dromaeo, Sunspider, V8 Benchmark