You are not logged in.

#26 2007-12-12 21:00:59

adekoba
Member
Registered: 2007-07-10
Posts: 128
Website

Re: xmonad Hacking Thread

I just hated with the stack how when you open one client, all of the others have to resize. I also liked in wmii how you can move clients independently, as in left or right to other columns, and creating columns if it is at the edge of the screen.


abcdefghijklmnopqrstuvwxyz

Offline

#27 2007-12-13 01:45:25

semdornus
Member
From: Tokyo
Registered: 2007-08-07
Posts: 47

Re: xmonad Hacking Thread

adekoba wrote:

I also liked in wmii how you can move clients independently, as in left or right to other columns, and creating columns if it is at the edge of the screen.

Although I don't understand by what you mean with "creating columns at the edge", creating multiple layouts in one screen is possible and by using this you can get the functionality you want; move a client from one layout to the next.

Say you have a tabbed layout on the left of the screen and a tiled layout on right.  Both have 2 or more clients, then you can move the client from the tabbed one to the tiled one and if you want you can also move a client up or down inside the tiled layout as well. In case you want to try something like that: see my config I posted above for ideas on how to do this ("Window management" section of the keys).

Offline

#28 2007-12-13 09:19:12

strankan
Member
From: Sundsvall - Sweden
Registered: 2006-11-08
Posts: 97

Re: xmonad Hacking Thread

Is there any way to make an entire workspace "float"? I have some apps that I send to the "float" workspace, but i can't seem to make them all float by default. In particular it's amsn that doesnt want to play along. mplayer and other apps works just fine when I define them as always floating.

Offline

#29 2007-12-13 21:58:58

adekoba
Member
Registered: 2007-07-10
Posts: 128
Website

Re: xmonad Hacking Thread

semdornus wrote:
Xilon wrote:

Afaik you can't do that in xmonad (yet, maybe if someone write a layout algorithm)

Just a small FYI; you can do that in xmonad. See Combo, LayoutCombinators and/or LayoutScreens. Difficult to see, but in screenshot.

I have to admit, I'm not very good (at all) at haskell and I have no idea how I would go about doing this. would you mind giving an example?


abcdefghijklmnopqrstuvwxyz

Offline

#30 2007-12-14 01:36:39

semdornus
Member
From: Tokyo
Registered: 2007-08-07
Posts: 47

Re: xmonad Hacking Thread

adekoba wrote:

would you mind giving an example?

Sure, but it depends a lot on what you want to do. Short parts of a config:

Import the necessary contributions

import XMonad.Layout.Combo
import XMonad.Layout.LayoutCombinators
import XMonad.Layout.Square
import XMonad.Layout.Tabbed
import XMonad.Layout.WindowNavigation

Change you layouthook to what you want to create. This for example has two layouts. The first will split your screen in half and have the tabbed layout on the left and the normal tiled one on the right. The second example is longer and means split the screen horizontally, the top 2/3 will be split horizontally and each side will have the tab layout, the lower 1/3 will be split as a square and the left side of that will be tiled and the right will be tabbed.

In a very bad visual
1                                   2
--------|--------                --------|--------
          |                                    |
tabbed|tiled                     tabbed| tabbed
          |                          --------|--------
          |                           tiled   | tabbed
--------|--------                --------|--------

, layoutHook            = windowNavigation $
         (myTab *|* tiled)
    ||| ((myTab *|* myTab) **/* combineTwo Square tiled myTab)
}
where
    tiled = Tall 1 0.03 0.68                -- Tall <nmaster> <delta> <ratio>
    myTab = tabbed shrinkText myTabConfig

Now add something like this to your keys to move them around:

, ((modm, xK_Right), sendMessage $ Go R)   -- Go to client on the right
, ((modm, xK_Left), sendMessage $ Go L)   -- Go to client on the left
, ((modm, xK_Up), sendMessage $ Go U)   -- Go to client above
, ((modm, xK_Down), sendMessage $ Go D)   -- Go to client below
, ((modm .|. shiftMask, xK_Right), sendMessage $ Swap R)   -- Swap current client with the one on the right
, ((modm .|. shiftMask, xK_Left), sendMessage $ Swap L)   -- Swap current client with the one on the left
, ((modm .|. shiftMask, xK_Up), sendMessage $ Swap U)   -- Swap current client with the one above
, ((modm .|. shiftMask, xK_Down), sendMessage $ Swap D)   -- Swap current client with the one below
, ((modm .|. controlMask, xK_Right), sendMessage $ Move R)   -- Move client to the sub layout on the right
, ((modm .|. controlMask, xK_Left), sendMessage $ Move L)   -- Move client to the sub layout on the left
, ((modm .|. controlMask xK_Up), sendMessage $ Move U    -- Move client to the sub layout above
, ((modm .|. controlMask , xK_Down), sendMessage $ Move D)   -- Move client to the sub layout below

You can create very complex layouts this way if you want. Hope this helped a bit. If not, ask away. wink

Offline

#31 2007-12-14 11:57:40

PhrAok
Member
From: France
Registered: 2006-12-16
Posts: 66
Website

Re: xmonad Hacking Thread

thayer wrote:

What with such a small xmonad community, I thought it might be nice to have a central location here on the forums to discuss various tips & tricks. A place where you can post your xmonad.hs or snippets thereof and bounce around ideas for extensions and whatnot.

...

xmonad.hs snapshot 2007-12-12:

--
    -- ~/.xmonad/xmonad.hs
...

Thank you thayer, i use your config, but i have a problem, i can't select/switch tags with the mouse, what's wrong? i know it's a mouseless wm but...

Last edited by PhrAok (2007-12-14 16:16:32)

Offline

#32 2007-12-14 21:03:52

thayer
Fellow
From: Vancouver, BC
Registered: 2007-05-20
Posts: 1,560
Website

Re: xmonad Hacking Thread

PhrAok wrote:

Thank you thayer, i use your config, but i have a problem, i can't select/switch tags with the mouse, what's wrong? i know it's a mouseless wm but...

Unfortunately, I do not think it is possible to do this with dzen, at least not in its current form.  I know the wmii bar can do this, so maybe it's just a matter of time before dzen or xmobar does.

Last edited by thayer (2007-12-14 21:04:44)


thayer williams ~ cinderwick.ca

Offline

#33 2007-12-17 11:48:35

finferflu
Forum Fellow
From: Manchester, UK
Registered: 2007-06-21
Posts: 1,899
Website

Re: xmonad Hacking Thread

Is there any way I can use a pager together with the DynamicLog extension? I know about Xmonad.Ewhm.Desktops, but I don't know how to combine it with the DynamicLog.

These are the relevant bits from my (copied from somebody else, because I don't have a clue about haskell) config:

statusBarCmd= "dzen2 -p -h 16 -ta l -bg '" ++ myNormalBGColor ++ "' -fg '" ++ myNormalFGColor ++ "' -w 1000 -sa r -fn '" ++ myFont ++ "'"

main = do
    statusBarPipe <- spawnPipe statusBarCmd
    xmonad $ defaultConfig {
        modMask = mod4Mask,
        borderWidth = 1,
        terminal = "gnome-terminal",
        normalBorderColor = myNormalBGColor,
        focusedBorderColor = myFocusedBGColor,
        defaultGaps = [(16,0,0,0)],
        manageHook = manageHook defaultConfig <+> myManageHook,
        layoutHook = onWorkspace "3:chat" chatLayout globalLayout,
        workspaces = myWorkspaces,
        [b]logHook = dynamicLogWithPP $ myPP statusBarPipe[/b]
    }

myPP handle = defaultPP {
        ppCurrent = wrap ("^fg(" ++ myFocusedFGColor ++ ")^bg(" ++ myFocusedBGColor ++ ")^p(4)") "^p(4)^fg()^bg()",
        ppVisible = wrap ("^fg(" ++ myFocusedFGColor ++ ")^bg(" ++ myNormalBGColor ++ ")^p(4)") "^p(4)^fg()^bg()",
        ppSep     = "^fg(" ++ mySeperatorColor ++ ")^r(3x3)^fg()",
        ppLayout  = (\x -> case x of
                    "Tall"          -> " ^i(" ++ myBitmapsDir ++ "/tall.xbm) "
                    "Mirror Tall"   -> " ^i(" ++ myBitmapsDir ++ "/mtall.xbm) "
                    "Full"          -> " ^i(" ++ myBitmapsDir ++ "/full.xbm) "
                ),
        ppTitle   = wrap ("^fg(" ++ myFocusedFGColor ++ ")") "^fg()" ,
        ppOutput  = hPutStrLn handle

Thanks smile


Have you Syued today?
Free music for free people! | Earthlings

"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- A. de Saint-Exupery

Offline

#34 2007-12-17 15:13:33

Roberth
Member
From: The Pale Blue Dot
Registered: 2007-01-12
Posts: 894

Re: xmonad Hacking Thread

Do I only need to import XMonad.Layout.NoBorders? and if thats true, how do I use it?


Use the Source, Luke!

Offline

#35 2007-12-17 15:25:54

thayer
Fellow
From: Vancouver, BC
Registered: 2007-05-20
Posts: 1,560
Website

Re: xmonad Hacking Thread

Roberth wrote:

Do I only need to import XMonad.Layout.NoBorders? and if thats true, how do I use it?

Bookmark this site for reference:
http://hackage.haskell.org/packages/arc … index.html

And see this entry specifically for the NoBorders extension:
http://hackage.haskell.org/packages/arc … rders.html

From there you can see some example usage, depending on what you want to do.  If you just want to enable NoBorders in full screen mode, add noBorders to the Full layout; for example:

, layoutHook  =  tiled ||| Mirror tiled ||| noBorders Full ||| Grid ||| tabbed shrinkText defaultTConf

If you'd rather enable smartBorders, which will try to figure out on its own when a window should be borderless, you can wrap smartBorders around all layouts, like so:

, layoutHook  =  smartBorders $ tiled ||| Mirror tiled ||| Full ||| Grid ||| tabbed shrinkText defaultTConf

thayer williams ~ cinderwick.ca

Offline

#36 2007-12-19 06:27:58

acura
Member
Registered: 2007-07-08
Posts: 21

Re: xmonad Hacking Thread

thayer wrote:
--
    -- ~/.xmonad/xmonad.hs
--

-- import the necessary libraries

import XMonad
import XMonad.ManageHook
import XMonad.Operations
import XMonad.Actions.CycleWS
import XMonad.Actions.DwmPromote
import XMonad.Actions.RotSlaves
import XMonad.Actions.RotView
import XMonad.Actions.SinkAll
import XMonad.Hooks.DynamicLog   ( PP(..), dynamicLogWithPP, dzenColor, wrap, defaultPP )
import XMonad.Layout 
import XMonad.Layout.Grid
import XMonad.Layout.NoBorders   ( noBorders, smartBorders )
import XMonad.Layout.Tabbed
import XMonad.Layout.ToggleLayouts
import XMonad.Util.Run

import qualified XMonad.StackSet as W
import qualified XMonad.Actions.FlexibleResize as Flex
import qualified Data.Map as M
import Data.Bits ((.|.))
import Data.Ratio
import Graphics.X11
import System.IO
 
statusBarCmd= "dzen2 -bg '#1a1a1a' -fg '#777777' -h 16 -w 550 -sa c -e '' -fn '-*-terminus-*-r-normal-*-*-120-*-*-*-*-iso8859-*' -ta l"
 
main = do din <- spawnPipe statusBarCmd
          xmonad $ defaultConfig
 
                     { borderWidth        = 2
                     , normalBorderColor  = "#333333"
                     , focusedBorderColor = "#ff0099" 
                     , workspaces         = ["1:main", "2:mail", "3:web"] ++ map show [4 .. 9 :: Int]
                     , terminal           = "urxvt"
                     , modMask            = mod1Mask
                     , defaultGaps        = [(16,0,0,0)]
                     , manageHook            = manageHook defaultConfig <+> myManageHook
                     , logHook            = dynamicLogWithPP $ myPP din
                               , layoutHook         = toggleLayouts (noBorders Full) $
                                            smartBorders $ tiled ||| Mirror tiled ||| Full ||| Grid ||| tabbed shrinkText defaultTConf
                     , keys               = \c -> myKeys c `M.union` keys defaultConfig c
                     , mouseBindings      = \c -> myMouse c `M.union` mouseBindings defaultConfig c
                     }
                     where
                     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   = 2/(1+(toRational(sqrt(5)::Double))) -- golden
                     
                     -- Percent of screen to increment by when resizing panes
                     delta   = 5%100


-- application control 
--
myManageHook :: ManageHook
myManageHook = composeAll . concat $
    [ [ className   =? c                 --> doFloat | c <- myFloats]
    , [ title       =? t                 --> doFloat | t <- myOtherFloats]
    , [ resource    =? r                 --> doIgnore | r <- myIgnores]
    , [ className   =? "Firefox-bin"     --> doF (W.shift "3:web") ]
    , [ className   =? "Opera"           --> doF (W.shift "3:web") ]
    , [ className   =? "Thunderbird-bin" --> doF (W.shift "2:mail") ]
    ]
    where
        myIgnores       = ["panel", "stalonetray", "trayer"]
        myFloats        = ["feh", "GIMP", "gimp", "gimp-2.4", "Galculator", "VirtualBox", "VBoxSDL"]
        myOtherFloats   = ["alsamixer", "Bon Echo Preferences", "Mail/News Preferences", "Bon Echo - Restore Previous Session"] 

-- modify/add default key binds
--
myKeys (XConfig {modMask = modm}) = M.fromList $
           [
           -- custom dmenu
           ((modm, xK_p), spawn "exe=`dmenu_path | dmenu -fn '-*-terminus-*-r-normal-*-*-120-*-*-*-*-iso8859-*' -nb '#000000' -nf '#FFFFFF' -sb '#0066ff'` && eval \"exec $exe\"") -- %! Launch dmenu
           -- sink all floating windows
           ,  ((modm .|. shiftMask, xK_t), sinkAll)
           -- swap focused with master, or master with next in line 
           , ((modm, xK_Return), dwmpromote)
           , ((modm, xK_KP_Enter), dwmpromote)
           -- rotate slave clients
           , ((modm .|. shiftMask, xK_Tab   ), rotSlavesUp)
           -- cycle through non-empty workspaces
           , ((modm .|. shiftMask, xK_Right), rotView True)
           , ((modm .|. shiftMask, xK_Left), rotView False)
           -- switch to previous workspace
           , ((modm, xK_z), toggleWS)
           -- toggle to fullscreen.
           , ((modm, xK_x), sendMessage ToggleLayout)
           -- session management
           , ((modm .|. shiftMask .|. controlMask, xK_k), spawn "xkill")
           , ((modm .|. shiftMask .|. controlMask, xK_End), spawn "sudo shutdown -h now")
           , ((modm .|. shiftMask .|. controlMask, xK_Delete), spawn "sudo shutdown -r now")
           , ((mod4Mask, xK_l), spawn "xscreensaver-command --lock")
           -- application hotkeys
           , ((mod4Mask, xK_w), spawn "firefox")
           , ((mod4Mask, xK_t), spawn "thunderbird")
           , ((mod4Mask, xK_e), spawn "thunar")
           , ((mod4Mask, xK_v), spawn "urxvt -e alsamixer")
           , ((0, xK_Print), spawn "scrot %Y%m%d-dublin.png -t 280x175")
           , ((shiftMask, xK_Print), spawn "scrot %Y%m%d-dublin.png -d 3 -t 280x175")
           ]
 
-- modify/add default mouse binds
-- 
myMouse (XConfig {modMask = modm}) = M.fromList $
           [ ((modm, button3), (\w -> focus w >> Flex.mouseResizeWindow w))
           , ((modm, button4), (\_ -> rotView True)) 
           , ((modm, button5), (\_ -> rotView False))
           ]

-- dynamiclog pretty printer for dzen
--
myPP h = defaultPP 
                 { ppCurrent = wrap "^fg(#ffffff)^bg(#0066ff)^p(2)^i(/home/thayer/.xmonad/dzen/marker.xbm)" "^p(2)^fg()^bg()" . \wsId -> if (':' `elem` wsId) then drop 2 wsId else wsId    -- Trim the '[Int]:' from workspace tags
                  , ppVisible = wrap "^bg(grey30)^fg(grey75)^p(2)" "^p(2)^fg()^bg()"
                  , ppHidden = wrap "^fg(#ffffff)^bg()^p(2)^i(/home/thayer/.xmonad/dzen/marker.xbm)" "^p(2)^fg()^bg()" . \wsId -> if (':' `elem` wsId) then drop 2 wsId else wsId
                  , ppHiddenNoWindows = id . \wsId -> if (':' `elem` wsId) then drop 2 wsId else wsId
                  , ppSep     = "  ^fg(#ffffff)^r(2x2)^fg()  "
                  , ppWsSep           = " "
                  , ppLayout  = dzenColor "#cccccc" "" .
                                (\x -> case x of
                                         "Tall" -> "tall ^i(/home/thayer/.xmonad/dzen/layout-tall.xbm)"
                                         "Mirror Tall" -> "mirror ^i(/home/thayer/.xmonad/dzen/layout-mtall.xbm)"
                                         "Full" -> "full ^i(/home/thayer/.xmonad/dzen/layout-full.xbm)"
                                         "Grid" -> "grid"
                                         "Tabbed" -> "tabbed"
                                )
--                  , ppTitle   = dzenColor "white" "" . wrap "< " " >" 
                  , ppTitle   = dzenColor "white" ""
                  , ppOutput   = hPutStrLn h
                  }

Can some one explain what the . \wsId -> does? I know about the lambdas in haskell but I have never noticed this before.

Offline

#37 2007-12-19 10:03:37

buttons
Member
From: NJ, USA
Registered: 2007-08-04
Posts: 620

Re: xmonad Hacking Thread

At the risk of personal embarrassment I'm going to say it does nothing at all.  I think it's an artifact of someone else's old configuration and ':' `elem` wsId never evaluates true.


Cthulhu For President!

Offline

#38 2007-12-19 16:41:13

acura
Member
Registered: 2007-07-08
Posts: 21

Re: xmonad Hacking Thread

buttons wrote:

At the risk of personal embarrassment I'm going to say it does nothing at all.  I think it's an artifact of someone else's old configuration and ':' `elem` wsId never evaluates true.

I've found out that it is just a lamdba.
And it is used, otherwise the text in dzen would look like "1:main 2:web".
But why not just name the workspace to main, web and so on? Then you don't have to do that test on every workspace all the time which should save some computations.

Offline

#39 2007-12-19 16:44:23

buttons
Member
From: NJ, USA
Registered: 2007-08-04
Posts: 620

Re: xmonad Hacking Thread

acura wrote:
buttons wrote:

At the risk of personal embarrassment I'm going to say it does nothing at all.  I think it's an artifact of someone else's old configuration and ':' `elem` wsId never evaluates true.

I've found out that it is just a lamdba.
And it is used, otherwise the text in dzen would look like "1:main 2:web".
But why not just name the workspace to main, web and so on? Then you don't have to do that test on every workspace all the time which should save some computations.

Right.  That's what I meant by an artifact of an old config.  I don't think anyone uses that 1:blah convention anymore, at least not that I've seen.

I don't have any numbers in my config, personally.


Cthulhu For President!

Offline

#40 2007-12-19 17:10:43

thayer
Fellow
From: Vancouver, BC
Registered: 2007-05-20
Posts: 1,560
Website

Re: xmonad Hacking Thread

I do ... but don't ask me why, because I don't have a compelling answer smile


thayer williams ~ cinderwick.ca

Offline

#41 2007-12-19 17:10:55

acura
Member
Registered: 2007-07-08
Posts: 21

Re: xmonad Hacking Thread

Well here's my config and a screenshot. Based on thyers with added UrgencyHook.

--
-- ~/.xmonad/xmonad.hs
--

-- import the necessary libraries

-- base
import XMonad
import XMonad.Layout 
import XMonad.ManageHook
import XMonad.Operations

-- actions
import XMonad.Actions.CycleWS
import XMonad.Actions.DwmPromote
import XMonad.Actions.RotSlaves
import XMonad.Actions.RotView
import XMonad.Actions.SinkAll

--hooks
import XMonad.Hooks.DynamicLog   ( PP(..), dynamicLogWithPP, dzenColor, wrap, defaultPP )
import XMonad.Hooks.SetWMName
import XMonad.Hooks.UrgencyHook (withUrgencyHook, NoUrgencyHook(..))

-- loayouts
import XMonad.Layout.Grid
import XMonad.Layout.NoBorders   ( noBorders, smartBorders )
import XMonad.Layout.Tabbed
import XMonad.Layout.ToggleLayouts

import XMonad.Util.Run


import qualified XMonad.StackSet as W
import qualified XMonad.Actions.FlexibleResize as Flex
import qualified Data.Map as M
import Data.Bits ((.|.))
import Data.Ratio
import Graphics.X11
import System.IO
 
 
main = 
    do din <- spawnPipe statusBarCmd
       xmonad $ withUrgencyHook NoUrgencyHook $ defaultConfig { 
            borderWidth        = 1
            , normalBorderColor  = "#333333"
            , focusedBorderColor = "#ff0099" 
            , workspaces         = ["main", "web"] ++ map show [3 .. 8 :: Int] ++ ["warez"]
            , terminal           = "urxvt"
            , modMask            = mod1Mask
            , defaultGaps        = [(0,16,0,0)]
            , manageHook         = manageHook defaultConfig <+> myManageHook
            , logHook            = dynamicLogWithPP $ myPP din
            , layoutHook         = layouts'
            , keys               = \c -> myKeys c `M.union` keys defaultConfig c
            , mouseBindings      = \c -> myMouse c `M.union` mouseBindings defaultConfig c
            }

myFont = "-*-terminus-*-r-normal-*-*-120-*-*-*-*-iso8859-*"

statusBarCmd = "dzen2 -bg '#1a1a1a' -fg '#777777' -h 16 -w 1920 -sa c -e '' -fn "
               ++ myFont ++ " -y 1184 -ta l"

dmenu' = "exe=`dmenu_path | dmenu -fn " 
         ++ myFont 
         ++ " -nb '#000000' -nf '#FFFFFF' -sb '#ff0099'` && eval \"exec $exe\""

layouts' = 
    toggleLayouts (noBorders Full) $ 
    smartBorders $ 
    tiled ||| 
    Mirror tiled ||| 
    Full ||| 
    Grid ||| 
    tabbed shrinkText defaultTConf
        where
            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   = 2/(1+(toRational(sqrt(5)::Double))) -- golden
            -- Percent of screen to increment by when resizing panes
            delta   = 2%100

-- application control 
--
myManageHook :: ManageHook
myManageHook = composeAll . concat $
    [ [ className   =? c                 --> doFloat | c <- myFloats]
    , [ title       =? t                 --> doFloat | t <- myOtherFloats]
    , [ resource    =? r                 --> doIgnore | r <- myIgnores]
    , [ className   =? "Firefox-bin"     --> doF (W.shift "web") ]
    , [ className   =? "Opera"           --> doF (W.shift "web") ]
    , [ className   =? "Linuxdcpp"       --> doF (W.shift "warez") ]
    , [ className   =? "Pidgin"       --> doF (W.shift "3") ]
    ]
    where
        myIgnores       = ["panel", "stalonetray", "trayer"]
        myFloats        = ["feh", "GIMP", "gimp", "gimp-2.4", "Galculator", "VirtualBox", "VBoxSDL", "Inkscape"]
        myOtherFloats   = ["alsamixer", "Bon Echo Preferences", "Mail/News Preferences", "Bon Echo - Restore Previous Session"] 

-- modify/add default key binds
--
myKeys (XConfig {modMask = modm}) = M.fromList $
    [
    ((modm, xK_p), spawn dmenu')  -- %! Launch dmenu
    , ((modm .|. controlMask .|. shiftMask, xK_z), setWMName "LG3D") -- @@ Java hack
    -- sink all floating windows
    , ((modm .|. shiftMask, xK_t), sinkAll)
    -- swap focused with master, or master with next in line 
    , ((modm, xK_Return), dwmpromote)
    , ((modm, xK_KP_Enter), dwmpromote)
    -- rotate slave clients
    , ((modm .|. shiftMask, xK_Tab   ), rotSlavesUp)
    -- cycle through non-empty workspaces
    , ((modm .|. shiftMask, xK_Right), rotView True)
    , ((modm .|. shiftMask, xK_Left), rotView False)
    -- switch to previous workspace
    , ((modm, xK_z), toggleWS)
    -- toggle to fullscreen.
    , ((modm, xK_x), sendMessage ToggleLayout)
    -- session management
    , ((modm .|. shiftMask .|. controlMask, xK_k), spawn "xkill")
    , ((mod4Mask, xK_l), spawn "uxterm -e slock")
    -- application hotkeys
    , ((mod4Mask, xK_w), spawn "firefox")
    , ((mod4Mask, xK_v), spawn "urxvt -e alsamixer")
    , ((0, xK_Print), spawn "scrot %Y%m%d-acura.png -t 280x175")
    ]
 
-- modify/add default mouse binds
-- 
myMouse (XConfig {modMask = modm}) = M.fromList $
    [ ((modm, button3), (\w -> focus w >> Flex.mouseResizeWindow w))
    , ((modm, button4), (\_ -> rotView True)) 
    , ((modm, button5), (\_ -> rotView False))
    ]

-- dynamiclog pretty printer for dzen
--
myPP h = defaultPP { 
    ppCurrent   = wrap "^fg(#ffffff)^bg(#0066ff)^p(2)^i(/home/rickard/.xmonad/dzen/marker.xbm)" 
                    "^p(2)^fg()^bg()"
    , ppVisible = wrap "^bg(grey30)^fg(grey75)^p(2)" "^p(2)^fg()^bg()"
    , ppHidden  = wrap "^fg(#ffffff)^bg()^p(2)^i(/home/rickard/.xmonad/dzen/marker.xbm)" 
                    "^fg()^bg()^p(2)"
    , ppHiddenNoWindows = id
    , ppSep     = "  ^fg(#ffffff)^r(2x2)^fg()  "
    , ppWsSep   = " "
    , ppLayout  = dzenColor "#cccccc" "" .
            (\x -> case x of
                        "Tall"        -> "tall ^i(/home/rickard/.xmonad/dzen/tall.xbm)"
                        "Mirror Tall" -> "mirror ^i(/home/rickard/.xmonad/dzen/mtall.xbm)"
                        "Full"        -> "full ^i(/home/rickard/.xmonad/dzen/full.xbm)"
                        "Grid"        -> "grid ^i(/home/rickard/.xmonad/dzen/grid.xbm)"
                        "Tabbed"      -> "tabbed ^i(/home/rickard/.xmonad/dzen/tab.xbm)"
                        _             -> "unknown"
            )
    , ppUrgent  = wrap "^fg(#ff0000)^bg()^i(/home/rickard/.xmonad/dzen/has_win.xbm" "^fg()"
    , ppTitle   = dzenColor "white" "" . \str -> take 80 str
    , ppOutput  = hPutStrLn h
    }

aJHcpbbMp.png

Offline

#42 2007-12-20 20:00:09

adekoba
Member
Registered: 2007-07-10
Posts: 128
Website

Re: xmonad Hacking Thread

acura wrote:

Well here's my config and a screenshot. Based on thyers with added UrgencyHook.

--
-- ~/.xmonad/xmonad.hs
--

-- import the necessary libraries

-- base
import XMonad
import XMonad.Layout 
import XMonad.ManageHook
import XMonad.Operations

-- actions
import XMonad.Actions.CycleWS
import XMonad.Actions.DwmPromote
import XMonad.Actions.RotSlaves
import XMonad.Actions.RotView
import XMonad.Actions.SinkAll

--hooks
import XMonad.Hooks.DynamicLog   ( PP(..), dynamicLogWithPP, dzenColor, wrap, defaultPP )
import XMonad.Hooks.SetWMName
import XMonad.Hooks.UrgencyHook (withUrgencyHook, NoUrgencyHook(..))

-- loayouts
import XMonad.Layout.Grid
import XMonad.Layout.NoBorders   ( noBorders, smartBorders )
import XMonad.Layout.Tabbed
import XMonad.Layout.ToggleLayouts

import XMonad.Util.Run


import qualified XMonad.StackSet as W
import qualified XMonad.Actions.FlexibleResize as Flex
import qualified Data.Map as M
import Data.Bits ((.|.))
import Data.Ratio
import Graphics.X11
import System.IO
 
 
main = 
    do din <- spawnPipe statusBarCmd
       xmonad $ withUrgencyHook NoUrgencyHook $ defaultConfig { 
            borderWidth        = 1
            , normalBorderColor  = "#333333"
            , focusedBorderColor = "#ff0099" 
            , workspaces         = ["main", "web"] ++ map show [3 .. 8 :: Int] ++ ["warez"]
            , terminal           = "urxvt"
            , modMask            = mod1Mask
            , defaultGaps        = [(0,16,0,0)]
            , manageHook         = manageHook defaultConfig <+> myManageHook
            , logHook            = dynamicLogWithPP $ myPP din
            , layoutHook         = layouts'
            , keys               = \c -> myKeys c `M.union` keys defaultConfig c
            , mouseBindings      = \c -> myMouse c `M.union` mouseBindings defaultConfig c
            }

myFont = "-*-terminus-*-r-normal-*-*-120-*-*-*-*-iso8859-*"

statusBarCmd = "dzen2 -bg '#1a1a1a' -fg '#777777' -h 16 -w 1920 -sa c -e '' -fn "
               ++ myFont ++ " -y 1184 -ta l"

dmenu' = "exe=`dmenu_path | dmenu -fn " 
         ++ myFont 
         ++ " -nb '#000000' -nf '#FFFFFF' -sb '#ff0099'` && eval \"exec $exe\""

layouts' = 
    toggleLayouts (noBorders Full) $ 
    smartBorders $ 
    tiled ||| 
    Mirror tiled ||| 
    Full ||| 
    Grid ||| 
    tabbed shrinkText defaultTConf
        where
            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   = 2/(1+(toRational(sqrt(5)::Double))) -- golden
            -- Percent of screen to increment by when resizing panes
            delta   = 2%100

-- application control 
--
myManageHook :: ManageHook
myManageHook = composeAll . concat $
    [ [ className   =? c                 --> doFloat | c <- myFloats]
    , [ title       =? t                 --> doFloat | t <- myOtherFloats]
    , [ resource    =? r                 --> doIgnore | r <- myIgnores]
    , [ className   =? "Firefox-bin"     --> doF (W.shift "web") ]
    , [ className   =? "Opera"           --> doF (W.shift "web") ]
    , [ className   =? "Linuxdcpp"       --> doF (W.shift "warez") ]
    , [ className   =? "Pidgin"       --> doF (W.shift "3") ]
    ]
    where
        myIgnores       = ["panel", "stalonetray", "trayer"]
        myFloats        = ["feh", "GIMP", "gimp", "gimp-2.4", "Galculator", "VirtualBox", "VBoxSDL", "Inkscape"]
        myOtherFloats   = ["alsamixer", "Bon Echo Preferences", "Mail/News Preferences", "Bon Echo - Restore Previous Session"] 

-- modify/add default key binds
--
myKeys (XConfig {modMask = modm}) = M.fromList $
    [
    ((modm, xK_p), spawn dmenu')  -- %! Launch dmenu
    , ((modm .|. controlMask .|. shiftMask, xK_z), setWMName "LG3D") -- @@ Java hack
    -- sink all floating windows
    , ((modm .|. shiftMask, xK_t), sinkAll)
    -- swap focused with master, or master with next in line 
    , ((modm, xK_Return), dwmpromote)
    , ((modm, xK_KP_Enter), dwmpromote)
    -- rotate slave clients
    , ((modm .|. shiftMask, xK_Tab   ), rotSlavesUp)
    -- cycle through non-empty workspaces
    , ((modm .|. shiftMask, xK_Right), rotView True)
    , ((modm .|. shiftMask, xK_Left), rotView False)
    -- switch to previous workspace
    , ((modm, xK_z), toggleWS)
    -- toggle to fullscreen.
    , ((modm, xK_x), sendMessage ToggleLayout)
    -- session management
    , ((modm .|. shiftMask .|. controlMask, xK_k), spawn "xkill")
    , ((mod4Mask, xK_l), spawn "uxterm -e slock")
    -- application hotkeys
    , ((mod4Mask, xK_w), spawn "firefox")
    , ((mod4Mask, xK_v), spawn "urxvt -e alsamixer")
    , ((0, xK_Print), spawn "scrot %Y%m%d-acura.png -t 280x175")
    ]
 
-- modify/add default mouse binds
-- 
myMouse (XConfig {modMask = modm}) = M.fromList $
    [ ((modm, button3), (\w -> focus w >> Flex.mouseResizeWindow w))
    , ((modm, button4), (\_ -> rotView True)) 
    , ((modm, button5), (\_ -> rotView False))
    ]

-- dynamiclog pretty printer for dzen
--
myPP h = defaultPP { 
    ppCurrent   = wrap "^fg(#ffffff)^bg(#0066ff)^p(2)^i(/home/rickard/.xmonad/dzen/marker.xbm)" 
                    "^p(2)^fg()^bg()"
    , ppVisible = wrap "^bg(grey30)^fg(grey75)^p(2)" "^p(2)^fg()^bg()"
    , ppHidden  = wrap "^fg(#ffffff)^bg()^p(2)^i(/home/rickard/.xmonad/dzen/marker.xbm)" 
                    "^fg()^bg()^p(2)"
    , ppHiddenNoWindows = id
    , ppSep     = "  ^fg(#ffffff)^r(2x2)^fg()  "
    , ppWsSep   = " "
    , ppLayout  = dzenColor "#cccccc" "" .
            (\x -> case x of
                        "Tall"        -> "tall ^i(/home/rickard/.xmonad/dzen/tall.xbm)"
                        "Mirror Tall" -> "mirror ^i(/home/rickard/.xmonad/dzen/mtall.xbm)"
                        "Full"        -> "full ^i(/home/rickard/.xmonad/dzen/full.xbm)"
                        "Grid"        -> "grid ^i(/home/rickard/.xmonad/dzen/grid.xbm)"
                        "Tabbed"      -> "tabbed ^i(/home/rickard/.xmonad/dzen/tab.xbm)"
                        _             -> "unknown"
            )
    , ppUrgent  = wrap "^fg(#ff0000)^bg()^i(/home/rickard/.xmonad/dzen/has_win.xbm" "^fg()"
    , ppTitle   = dzenColor "white" "" . \str -> take 80 str
    , ppOutput  = hPutStrLn h
    }

http://pici.se/pictures/aJHcpbbMp.png

off topic, but could you post your irssi theme? thanks.

and I gave up btw. it was just too much for me... I will get haskell some day.


abcdefghijklmnopqrstuvwxyz

Offline

#43 2007-12-21 01:24:18

acura
Member
Registered: 2007-07-08
Posts: 21

Re: xmonad Hacking Thread

adekoba wrote:

off topic, but could you post your irssi theme? thanks.

and I gave up btw. it was just too much for me... I will get haskell some day.

It's not a irssi-theme it's an other client called weechat with the default theme. http://weechat.flashtux.orghttp://archlinux.org/packages/search/?q=weechat

Offline

#44 2007-12-21 17:48:38

cu3edweb
Member
From: USA
Registered: 2007-10-07
Posts: 291

Re: xmonad Hacking Thread

Sorry if this is a dumb question but for layouts in xmonad is there a difference between fullscreen and maximize?

Offline

#45 2007-12-21 18:16:52

thayer
Fellow
From: Vancouver, BC
Registered: 2007-05-20
Posts: 1,560
Website

Re: xmonad Hacking Thread

cu3edweb wrote:

Sorry if this is a dumb question but for layouts in xmonad is there a difference between fullscreen and maximize?

Not a dumb question at all, and yes there is a difference.  Full will fill the entire screen with the active client, while Maximize pulls the client out of the tile arrangement and fills about 90% of the screen (you can still see the tiled clients in the background beyond the edges of the maximized client), giving it an elegant "overlay" appearance.

I really liked the maximize extension, but I couldn't get it to wrap around all of my existing layouts and include smartBorders at the same time.

Last edited by thayer (2007-12-21 18:17:47)


thayer williams ~ cinderwick.ca

Offline

#46 2008-01-01 17:07:00

Roberth
Member
From: The Pale Blue Dot
Registered: 2007-01-12
Posts: 894

Re: xmonad Hacking Thread

Hello

I'm trying to understand how I configure an dynamic extension for xmonad with dzen2, but I can't make it work.

Xmonad.hs:

import XMonad
import System.Exit

import qualified XMonad.StackSet as W
import qualified Data.Map        as M
import qualified XMonad.Actions.FlexibleResize as Flex

-- Velge min standard terminal.
myTerminal      = "urxvt"

-- Bredde på vindusrammer i pixler.
myBorderWidth   = 2

-- Bestemmer at mod1tasten er alt.
myModMask       = mod1Mask

-- Bestemmer at mod2tasten er num lock.
myNumlockMask   = mod2Mask

-- Bestemmer hvor mange arbeidsområder det er og hva de heter.
myWorkspaces    = ["1","2","3","4","5","6","7","8","9"]

-- Farger på vindusrammene.
myNormalBorderColor  = "#000000"
myFocusedBorderColor = "#14CEFF"

-- Standard gap i mellom xmonad og kanten på skjermen (topp, bunn, venstre, høyre).
myDefaultGaps   = [(16,0,0,0)]

-- Tastebindinger, legg til endre og fjern tastebindinger.
myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
  
  -- Start standard terminal.
  [ ((modMask .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf)

  -- Kjører gmrun.
  , ((modMask .|. shiftMask, xK_p     ), spawn "gmrun")

  -- Lukker et fokusert vindu.
  , ((modMask .|. shiftMask, xK_c     ), kill)
  
  -- Endrer xmonads oppførsel.
  , ((modMask,               xK_space ), sendMessage NextLayout)

  -- Setter utførelsen på dette arbeids området til standard.
  , ((modMask .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf)

  -- Setter nåværende vinduer til riktig størrelse.
  , ((modMask,               xK_n     ), refresh)

  -- Flytt fokuset til neste vindu.
  , ((modMask,               xK_Tab   ), windows W.focusDown)

  -- Flytt fokuset til neste vindu.
  , ((modMask,               xK_j     ), windows W.focusDown)

  -- Flytt fokuset til forrige vindu.
  , ((modMask,               xK_k     ), windows W.focusUp)

  -- Flytt fokuset til hovedvindu.
  , ((modMask,               xK_m     ), windows W.focusMaster)

  -- Bytt plass mellom fokusert vindu og hovedvindu.
  , ((modMask,               xK_Return), windows W.swapMaster)

  -- Bytt plass mellom fokusert vindu og neste vindu.
  , ((modMask .|. shiftMask, xK_j     ), windows W.swapDown  )

  -- Bytt plass mellom fokusert vindu og forrige vindu.
  , ((modMask .|. shiftMask, xK_k     ), windows W.swapUp    )

  -- Krymp hovedområde.
  , ((modMask,               xK_h     ), sendMessage Shrink)

  -- Utvid hovedområde.
  , ((modMask,               xK_l     ), sendMessage Expand)

  -- Setter vindu tilbake i rutenettet.
  , ((modMask,               xK_t     ), withFocused $ windows . W.sink)

  -- Øker antall vinduer i hovedområdet.
  , ((modMask              , xK_comma ), sendMessage (IncMasterN 1))

  -- Minsk antall vinduer i hovedområdet.
  , ((modMask              , xK_period), sendMessage (IncMasterN (-1)))

  -- Forandrer status bar gapet.
  , ((modMask              , xK_b     ),
    modifyGap (\i n -> let x = (XMonad.defaultGaps conf ++ repeat (0,0,0,0)) !! i
                       in if n == x then (0,0,0,0) else x))
  -- Tar skjermdump.
  , ((0, xK_Print), spawn "scrot")

  -- Avslutt xmonad.
  , ((modMask .|. shiftMask, xK_q     ), io (exitWith ExitSuccess))

  -- Start xmonad om igjen.
  , ((modMask              , xK_q     ),
    broadcastMessage ReleaseResources >> restart (Just "xmonad") True)
  ]
  ++

  --
  -- mod-[1..9], Bytt til arbeidsområde N
  -- mod-shift-[1..9] Flytt vindu til arbeidsområde N
  --
  [((m .|. modMask, k), windows $ f i)
        | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
        , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
  ++

  --
  -- mod-{w,e,r}, Bytt til Fysisk/Xinerama skjerm 1, 2, eller 3
  -- mod-shift-{w,e,r}, Flytt vindu til skjerm 1, 2, eller 3
  --
  [((m .|. modMask, key), screenWorkspace sc >>= flip whenJust (windows . f))
        | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
        , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
  
-- Musbindinger: standard aksjon bundet til mus hendelse
--
myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $

  -- mod-button1, Setter vinduet til flytende modus og flytter det ved å dra.
  [ ((modMask, button1), (\w -> focus w >> mouseMoveWindow w))

  -- mod-button2, Hever vinduet til toppen av bunken.
  , ((modMask, button2), (\w -> focus w >> windows W.swapMaster))

  -- mod-button3, Setter vinduet til flytende modus og endrer størrelsen ved å dra.
  , ((modMask, button3), (\w -> focus w >> Flex.mouseResizeWindow w))
  ]

-- Oppførsel:

myLayout = tiled ||| Mirror tiled ||| Full
  where
     -- Standard rutenett oppførsel deler skjerm inn i to områder.
     tiled   = Tall nmaster delta ratio

     -- Standard antall vinduer i et hovedområde.
     nmaster = 1

     -- Standard oppdeling av skjermen opptatt av hoved rute.
     ratio   = 1/2

     -- Prosent av skjermen når mann endrer størrelsen på rutene.
     delta   = 3/100

-- Vindus regler.

myManageHook = composeAll
  [ className =? "MPlayer"        --> doFloat
  , className =? "Gimp"           --> doFloat
  , resource  =? "desktop_window" --> doIgnore
  , resource  =? "kdesktop"       --> doIgnore ]

-- Status barer og logg
myLogHook = return ()

-- Kjør xmonad med instillingene du spesifiserer.
main = xmonad defaults

defaults = defaultConfig {
      -- simple stuff
        terminal           = myTerminal,
        borderWidth        = myBorderWidth,
        modMask            = myModMask,
        numlockMask        = myNumlockMask,
        workspaces         = myWorkspaces,
        normalBorderColor  = myNormalBorderColor,
        focusedBorderColor = myFocusedBorderColor,
        defaultGaps        = myDefaultGaps,
 
      -- key bindings
        keys               = myKeys,
        mouseBindings      = myMouseBindings,
 
      -- hooks, layouts
        layoutHook         = myLayout,
        manageHook         = myManageHook,
        logHook            = myLogHook
    }

/bin/dzconky:

#!/bin/sh
conky | dzen2 -bg '#181818' -fg '#ffffff' -h '16' -w '1680' -ta r -fn '-*-bitstream vera sans-medium-r-normal-*-10-*-*-*-*-*-*-*'

I just want xmonad to show the number for all workspaces I got and which is the current workspace.

Can anybody show me?


Use the Source, Luke!

Offline

#47 2008-01-01 17:23:15

quarks
Member
From: Netherlands
Registered: 2007-05-14
Posts: 66

Re: xmonad Hacking Thread

Roberth wrote:

I just want xmonad to show the number for all workspaces I got and which is the current workspace.

Can anybody show me?

Basically, you need to put stuff inside:

import XMonad.Hooks.DynamicLog   ( PP(..), dynamicLogWithPP, dzenColor, wrap, defaultPP )

statusBarCmd= "dzen2 -bg '#000000' -fg '#FFFFFF' -h 16 -fn '*your font*' -sa c -e '' -ta l"
 
main = do din <- spawnPipe statusBarCmd
          xmonad $ defaultConfig
 
                     { borderWidth        = 2
                     , normalBorderColor  = "#000000"
                     , focusedBorderColor = "#14CEFF" 
                     , workspaces         = ["1","2","3","4","5","6","7","8","9"]
                     , terminal           = "urxvt"
                     , modMask            = mod1Mask
                     , defaultGaps        = [(16,0,0,0)]
                     , logHook            = dynamicLogWithPP $ myPP din
                     }

Then your key, float and other sutff.
And at the bottom of xmonad.hs

-- dynamiclog pretty printer for dzen
myPP h = defaultPP 
                 { ppCurrent = wrap "^fg(#FFFFFF)^bg(#647A90)^p(2)^i(/link_to_your_bitmaps/has_win.xbm)" "^p(2)^fg(grey55)^bg()"
                  , ppVisible = wrap "^bg(grey30)^fg(grey75)^p(2)" "^p(2)^fg(grey55)^bg()"
                  , ppSep     = " ^fg(grey60)^r(3x3)^fg() "
                  , ppLayout  = dzenColor "#647A90" "" .
                                (\x -> case x of
                                         "Tall" -> "tall ^i(/link_to_your_bitmaps/tall.xbm)"
                                         "Mirror Tall" -> "mirror ^i(/link_to_your_bitmaps/mtall.xbm)"
                                         "Full" -> "full ^i(/link_to_your_bitmaps/full.xbm)"
                                         "Grid" -> "grid"
                                         "Tabbed" -> "tabbed"
                                )
                  , ppTitle   = dzenColor "white" "" . wrap "< " " >" 
                  , ppOutput   = hPutStrLn h
                  }

Something like that.

Offline

#48 2008-01-02 23:20:37

Roberth
Member
From: The Pale Blue Dot
Registered: 2007-01-12
Posts: 894

Re: xmonad Hacking Thread

Error detected while loading xmonad configuration file: /home/roberth/.xmonad/xmonad.hs

xmonad.hs:11:17: Not in scope: `spawnPipe'

xmonad.hs:21:63: Not in scope: `myPP'

Please check the file for errors.

My xmonad.hs:

import XMonad
import System.Exit
import XMonad.Hooks.DynamicLog   ( PP(..), dynamicLogWithPP, dzenColor, wrap, defaultPP )

import qualified XMonad.StackSet as W
import qualified Data.Map        as M
import qualified XMonad.Actions.FlexibleResize as Flex

statusBarCmd= "conky | dzen2 -bg '#000000' -fg '#ffffff' -h '16' -w '1680' -ta r -fn '-*-bitstream vera sans-medium-r-normal-*-10-*-*-*-*-*-*-*'"

main = do din <- spawnPipe statusBarCmd
          xmonad $ defaultConfig
 
                     { borderWidth        = 2
                     , normalBorderColor  = "#000000"
                     , focusedBorderColor = "#9bdf32" 
                     , workspaces         = ["1","2","3","4","5","6","7","8","9"]
                     , terminal           = "urxvt"
                     , modMask            = mod1Mask
                     , defaultGaps        = [(16,0,0,0)]
                     , logHook            = dynamicLogWithPP $ myPP din
                     }

-- Velge min standard terminal.
myTerminal      = "urxvt"

-- Bredde på vindusrammer i pixler.
myBorderWidth   = 2

-- Bestemmer at mod1tasten er alt.
myModMask       = mod1Mask

-- Bestemmer at mod2tasten er num lock.
myNumlockMask   = mod2Mask

-- Bestemmer hvor mange arbeidsområder det er og hva de heter.
myWorkspaces    = ["1","2","3","4","5","6","7","8","9"]

-- Farger på vindusrammene.
myNormalBorderColor  = "#000000"
myFocusedBorderColor = "#9bdf32"

-- Standard gap i mellom xmonad og kanten på skjermen (topp, bunn, venstre, høyre).
myDefaultGaps   = [(16,0,0,0)]

-- Tastebindinger, legg til endre og fjern tastebindinger.
myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
  
  -- Start standard terminal.
  [ ((modMask .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf)

  -- Kjører gmrun.
  , ((modMask .|. shiftMask, xK_p     ), spawn "gmrun")

  -- Lukker et fokusert vindu.
  , ((modMask .|. shiftMask, xK_c     ), kill)
  
  -- Endrer xmonads oppførsel.
  , ((modMask,               xK_space ), sendMessage NextLayout)

  -- Setter utførelsen på dette arbeids området til standard.
  , ((modMask .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf)

  -- Setter nåværende vinduer til riktig størrelse.
  , ((modMask,               xK_n     ), refresh)

  -- Flytt fokuset til neste vindu.
  , ((modMask,               xK_Tab   ), windows W.focusDown)

  -- Flytt fokuset til neste vindu.
  , ((modMask,               xK_j     ), windows W.focusDown)

  -- Flytt fokuset til forrige vindu.
  , ((modMask,               xK_k     ), windows W.focusUp)

  -- Flytt fokuset til hovedvindu.
  , ((modMask,               xK_m     ), windows W.focusMaster)

  -- Bytt plass mellom fokusert vindu og hovedvindu.
  , ((modMask,               xK_Return), windows W.swapMaster)

  -- Bytt plass mellom fokusert vindu og neste vindu.
  , ((modMask .|. shiftMask, xK_j     ), windows W.swapDown  )

  -- Bytt plass mellom fokusert vindu og forrige vindu.
  , ((modMask .|. shiftMask, xK_k     ), windows W.swapUp    )

  -- Krymp hovedområde.
  , ((modMask,               xK_h     ), sendMessage Shrink)

  -- Utvid hovedområde.
  , ((modMask,               xK_l     ), sendMessage Expand)

  -- Setter vindu tilbake i rutenettet.
  , ((modMask,               xK_t     ), withFocused $ windows . W.sink)

  -- Øker antall vinduer i hovedområdet.
  , ((modMask              , xK_comma ), sendMessage (IncMasterN 1))

  -- Minsk antall vinduer i hovedområdet.
  , ((modMask              , xK_period), sendMessage (IncMasterN (-1)))

  -- Forandrer status bar gapet.
  , ((modMask              , xK_b     ),
    modifyGap (\i n -> let x = (XMonad.defaultGaps conf ++ repeat (0,0,0,0)) !! i
                       in if n == x then (0,0,0,0) else x))
  -- Tar skjermdump.
  , ((0, xK_Print), spawn "scrot")

  -- Avslutt xmonad.
  , ((modMask .|. shiftMask, xK_q     ), io (exitWith ExitSuccess))

  -- Start xmonad om igjen.
  , ((modMask              , xK_q     ),
    broadcastMessage ReleaseResources >> restart (Just "xmonad") True)
  ]
  ++

  --
  -- mod-[1..9], Bytt til arbeidsområde N
  -- mod-shift-[1..9] Flytt vindu til arbeidsområde N
  --
  [((m .|. modMask, k), windows $ f i)
        | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
        , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
  ++

  --
  -- mod-{w,e,r}, Bytt til Fysisk/Xinerama skjerm 1, 2, eller 3
  -- mod-shift-{w,e,r}, Flytt vindu til skjerm 1, 2, eller 3
  --
  [((m .|. modMask, key), screenWorkspace sc >>= flip whenJust (windows . f))
        | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
        , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
  
-- Musbindinger: standard aksjon bundet til mus hendelse
--
myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $

  -- mod-button1, Setter vinduet til flytende modus og flytter det ved å dra.
  [ ((modMask, button1), (\w -> focus w >> mouseMoveWindow w))

  -- mod-button2, Hever vinduet til toppen av bunken.
  , ((modMask, button2), (\w -> focus w >> windows W.swapMaster))

  -- mod-button3, Setter vinduet til flytende modus og endrer størrelsen ved å dra.
  , ((modMask, button3), (\w -> focus w >> Flex.mouseResizeWindow w))
  ]

-- Oppførsel:

myLayout = tiled ||| Mirror tiled ||| Full
  where
     -- Standard rutenett oppførsel deler skjerm inn i to områder.
     tiled   = Tall nmaster delta ratio

     -- Standard antall vinduer i et hovedområde.
     nmaster = 1

     -- Standard oppdeling av skjermen opptatt av hoved rute.
     ratio   = 1/2

     -- Prosent av skjermen når mann endrer størrelsen på rutene.
     delta   = 3/100

-- Vindus regler.

myManageHook = composeAll
  [ className =? "MPlayer"        --> doFloat
  , className =? "Gimp"           --> doFloat
  , resource  =? "desktop_window" --> doIgnore
  , resource  =? "kdesktop"       --> doIgnore ]

-- Status barer og logg
myLogHook = return ()

-- Kjør xmonad med instillingene du spesifiserer.
-- main = xmonad defaults

defaults = defaultConfig {
      -- simple stuff
        terminal           = myTerminal,
        borderWidth        = myBorderWidth,
        modMask            = myModMask,
        numlockMask        = myNumlockMask,
        workspaces         = myWorkspaces,
        normalBorderColor  = myNormalBorderColor,
        focusedBorderColor = myFocusedBorderColor,
        defaultGaps        = myDefaultGaps,
 
      -- key bindings
        keys               = myKeys,
        mouseBindings      = myMouseBindings,
 
      -- hooks, layouts
        layoutHook         = myLayout,
        manageHook         = myManageHook,
        logHook            = myLogHook
    }

What am I doing wrong?

Last edited by Roberth (2008-01-02 23:34:59)


Use the Source, Luke!

Offline

#49 2008-01-03 00:04:53

thayer
Fellow
From: Vancouver, BC
Registered: 2007-05-20
Posts: 1,560
Website

Re: xmonad Hacking Thread

Roberth wrote:

What am I doing wrong?

Hrmm, I could be wrong here (I'm not a programmer), but it looks to me like your config is telling the dynamicLog extension to look for custom settings under the myPP class, but you don't define anything as myPP.  That's just a guess though... for example:

, logHook            = dynamicLogWithPP $ myPP din

will use the settings defined here::

-- dynamiclog pretty printer for dzen
myPP h = defaultPP 
                 { ppCurrent = wrap "^fg(#ffffff)^bg(#0066ff)^p(2)^i(/home/thayer/.xmonad/dzen/square.xbm)" "^p(2)^fg()^bg()" . \wsId -> if (':' `elem` wsId) then drop 2 wsId else wsId    -- Trim the '[Int]:' from workspace tags
                  , ppVisible = wrap "^bg(grey30)^fg(grey75)^p(2)" "^p(2)^fg()^bg()"
                  , ppHidden = wrap "^fg(#ffffff)^bg()^p(2)^i(/home/thayer/.xmonad/dzen/corner.xbm)" "^p(2)^fg()^bg()" . \wsId -> if (':' `elem` wsId) then drop 2 wsId else wsId
                  , ppHiddenNoWindows = id . \wsId -> if (':' `elem` wsId) then drop 2 wsId else wsId
                  , ppSep     = "  ^fg(#ffffff)^r(2x2)^fg()  "
                  , ppWsSep           = " "
                  , ppLayout  = dzenColor "#cccccc" "" .
                                (\x -> case x of
                                         "Tall" -> "tall ^i(/home/thayer/.xmonad/dzen/layout-tall.xbm)"
                                         "Mirror Tall" -> "mirror ^i(/home/thayer/.xmonad/dzen/layout-mtall.xbm)"
                                         "Full" -> "full ^i(/home/thayer/.xmonad/dzen/layout-full.xbm)"
                                         "Grid" -> "grid ^i(/home/thayer/.xmonad/dzen/layout-grid.xbm)"
                                )
--                  , ppTitle   = dzenColor "white" "" . wrap "< " " >" 
                  , ppTitle   = dzenColor "white" ""
                  , ppOutput   = hPutStrLn h
                  }

thayer williams ~ cinderwick.ca

Offline

#50 2008-01-03 02:08:46

Roberth
Member
From: The Pale Blue Dot
Registered: 2007-01-12
Posts: 894

Re: xmonad Hacking Thread

thayer wrote:
-- dynamiclog pretty printer for dzen
myPP h = defaultPP 
                 { ppCurrent = wrap "^fg(#ffffff)^bg(#0066ff)^p(2)^i(/home/thayer/.xmonad/dzen/square.xbm)" "^p(2)^fg()^bg()" . \wsId -> if (':' `elem` wsId) then drop 2 wsId else wsId    -- Trim the '[Int]:' from workspace tags
                  , ppVisible = wrap "^bg(grey30)^fg(grey75)^p(2)" "^p(2)^fg()^bg()"
                  , ppHidden = wrap "^fg(#ffffff)^bg()^p(2)^i(/home/thayer/.xmonad/dzen/corner.xbm)" "^p(2)^fg()^bg()" . \wsId -> if (':' `elem` wsId) then drop 2 wsId else wsId
                  , ppHiddenNoWindows = id . \wsId -> if (':' `elem` wsId) then drop 2 wsId else wsId
                  , ppSep     = "  ^fg(#ffffff)^r(2x2)^fg()  "
                  , ppWsSep           = " "
                  , ppLayout  = dzenColor "#cccccc" "" .
                                (\x -> case x of
                                         "Tall" -> "tall ^i(/home/thayer/.xmonad/dzen/layout-tall.xbm)"
                                         "Mirror Tall" -> "mirror ^i(/home/thayer/.xmonad/dzen/layout-mtall.xbm)"
                                         "Full" -> "full ^i(/home/thayer/.xmonad/dzen/layout-full.xbm)"
                                         "Grid" -> "grid ^i(/home/thayer/.xmonad/dzen/layout-grid.xbm)"
                                )
--                  , ppTitle   = dzenColor "white" "" . wrap "< " " >" 
                  , ppTitle   = dzenColor "white" ""
                  , ppOutput   = hPutStrLn h
                  }

Could you please explain what these lines do? they aren't logical for me.

(\x -> case x of
                                         "Tall" -> "tall ^i(/home/thayer/.xmonad/dzen/layout-tall.xbm)"
                                         "Mirror Tall" -> "mirror ^i(/home/thayer/.xmonad/dzen/layout-mtall.xbm)"
                                         "Full" -> "full ^i(/home/thayer/.xmonad/dzen/layout-full.xbm)"
                                         "Grid" -> "grid ^i(/home/thayer/.xmonad/dzen/layout-grid.xbm)"
                                )

Are these needed if I don't want icons?


Use the Source, Luke!

Offline

Board footer

Powered by FluxBB