You are not logged in.

#176 2009-07-07 00:04:26

Allamgir
Member
Registered: 2009-06-11
Posts: 168

Re: xmonad Hacking Thread

I'm having some trouble with layouts. I want to rename the "Mirror Tall" layout to "Wide" so it shows up as "Wide" in my xmobar. Also, I want to make it so every workspace defaults to "Mirror Tall" (which will be called Wide), then when I hit mod-space it turns to Tall, then when I hit mod-space again it becomes Full, then goes back to Mirror Tall.

Here is my current xmonad.hs:

import XMonad
--
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.UrgencyHook
import XMonad.Hooks.ManageHelpers
--
import XMonad.Actions.FindEmptyWorkspace
--
import XMonad.Layout.Named
--
import XMonad.Util.Run(spawnPipe)
import XMonad.Util.EZConfig(additionalKeys)
--
import System.IO


myTerminal ="urxvtc"
myNormalBorderColor  = "#000000"
myFocusedBorderColor = "#e04613"
myManageHook = composeAll
    [ className =? "gimp 2.6"      --> doFloat] 
    <+> composeOne
        [ isFullscreen -?> doFullFloat ]  

main = do
    xmproc <- spawnPipe "xmobar"
    xmonad $ defaultConfig
        { manageHook = manageDocks <+> myManageHook <+> manageHook defaultConfig
    , terminal = myTerminal
    , normalBorderColor = myNormalBorderColor
    , focusedBorderColor = myFocusedBorderColor
    , borderWidth = 1
        , layoutHook = avoidStruts  $  layoutHook defaultConfig 
        , logHook = dynamicLogWithPP $ xmobarPP 
            { ppOutput = hPutStrLn xmproc
                        , ppTitle = xmobarColor "white" "" . shorten 200
            , ppCurrent = xmobarColor "#e04613" "" . wrap "[" "]"
            }
        } `additionalKeys`
        [ ((controlMask, xK_Print), spawn "sleep 0.2; scrot -s")
        , ((0, xK_Print), spawn "scrot")
        , ((mod1Mask, xK_p), spawn "exe=`dmenu_path | yeganesh -- -fn \"-*-profont-*-*-*-*-11-*-*-*-*-*-iso8859\" -nb \"#1c1d1f\" -nf \"#6c9eab\" -sb \"#e04613\" -sf \"#FFFFFF\" -b -p \"Run:\"` && eval \"exec $exe\"")
    , ((mod1Mask, xK_e), viewEmptyWorkspace)
    , ((mod1Mask .|. shiftMask, xK_e), tagToEmptyWorkspace)
    ]

I've been looking throughout the net and have found some options that should get me the desired results, but so far have not. To change the default layout switch order, I found this:

onWorkspaces ["1","2","3","4","5","6","7","8","9"] (Mirror Tall ||| Tall ||| Full)

The problem is when I add it to the bottom of my xmonad.hs like I saw in a config somewhere (sorry I don't have a link), I get this error:

xmonad.hs:48:0: parse error (possibly incorrect indentation)


For renaming "Mirror Tall" to "Wide", I found that I have to import XMonad.Layout.Named, so I did, and the XMonad.Layout.Named page (http://www.xmonad.org/xmonad-docs/xmona … Named.html) tells me to add this:

myLayouts = named "real big" Full ||| etc..

^^^WHICH I WOULD CHANGE TO:
myLayouts = named "Wide" Mirror Tall ||| etc..

RIGHT?

THEN I'M TOLD TO ADD THIS:
main = xmonad defaultConfig { layoutHook = myLayouts }

Unfortunately that does not work. I get errors at the first place these commands show up. Xmonad sees an error with the "etc.." in the first part, and also gives me one when I edit my main = xmonad line.

Can anyone help me with this? I don't know how to edit the haskell to make these things work sad


дɭɭɑӎɠїɾ

Offline

#177 2009-07-07 19:56:13

rizzix
Member
Registered: 2005-10-22
Posts: 55

Re: xmonad Hacking Thread

One solution is to use ppLayout to provide alternate names for existing ones.

logHook = dynamicLogWithPP $ xmobarPP 
    { ppOutput = hPutStrLn xmproc
    , ppTitle = xmobarColor "white" "" . shorten 200
    , ppCurrent = xmobarColor "#e04613" "" . wrap "[" "]",
    , ppLayout = codify }

And define codify somewhere as follows:

codify "Mirror Tall" = "Wide"
.
.
codify s = s

You can add any number of codify "some layout name" = "replacement name" in place of the vertical .'s

Offline

#178 2009-07-07 22:28:54

Allamgir
Member
Registered: 2009-06-11
Posts: 168

Re: xmonad Hacking Thread

rizzix wrote:

One solution is to use ppLayout to provide alternate names for existing ones.

logHook = dynamicLogWithPP $ xmobarPP 
    { ppOutput = hPutStrLn xmproc
    , ppTitle = xmobarColor "white" "" . shorten 200
    , ppCurrent = xmobarColor "#e04613" "" . wrap "[" "]",
    , ppLayout = codify }

And define codify somewhere as follows:

codify "Mirror Tall" = "Wide"
.
.
codify s = s

You can add any number of codify "some layout name" = "replacement name" in place of the vertical .'s

That worked perfectly, thanks! Now I just need to know how I can make it so in all workspaces the default layout order is
Wide, Tall, Full

instead of

Tall, Wide, Full.

(Wide is Mirror Tall)

Do you or does anyone else know how to do this? so far I have this line at the end of my xmonad.hs:

onWorkspaces ["1","2","3","4","5","6","7","8","9"] (Wide ||| Tall ||| Full)

but it keeps giving me parsing errors for the next line (which isn't open), telling me it's probably an indentation error. sadyikeshmm


дɭɭɑӎɠїɾ

Offline

#179 2009-07-08 04:00:36

rizzix
Member
Registered: 2005-10-22
Posts: 55

Re: xmonad Hacking Thread

You don't need the onWorkspaces thing at all. What you need rather is to modify the layoutHook line as follows:

, layoutHook = avoidStruts  $  Mirror Tall ||| Tall ||| Full

Offline

#180 2009-07-08 04:14:43

vogt
Member
From: Toronto, Canada
Registered: 2006-11-25
Posts: 389

Re: xmonad Hacking Thread

Allamgir wrote:

For renaming "Mirror Tall" to "Wide", I found that I have to import XMonad.Layout.Named, so I did, and the XMonad.Layout.Named page (http://www.xmonad.org/xmonad-docs/xmona … Named.html) tells me to add this:

myLayouts = named "real big" Full ||| etc..

^^^WHICH I WOULD CHANGE TO:
myLayouts = named "Wide" Mirror Tall ||| etc..

RIGHT?
...

This should be:

named "Wide" (Mirror Tall) ||| etc...

Otherwise it parses as: (((named "Wide") Mirror) Tall) ||| etc.., which doesn't make sense, since the function (named "Wide") takes a layout as its only argument, not two separate arguments Mirror and Tall

I think 'named' is clearer than messing with the output to the status bar because named does not require you to tell the default descriptions each layout appart.

Offline

#181 2009-07-08 22:03:22

Allamgir
Member
Registered: 2009-06-11
Posts: 168

Re: xmonad Hacking Thread

rizzix wrote:

You don't need the onWorkspaces thing at all. What you need rather is to modify the layoutHook line as follows:

, layoutHook = avoidStruts  $  Mirror Tall ||| Tall ||| Full

Nope, that didn't work. I get this error:

xmonad.hs:34:23:
    Couldn't match expected type `GHC.Word.Word32'
           against inferred type `Rational -> Rational -> Tall a'
      Expected type: XMonad.Layout.LayoutModifier.ModifiedLayout
                       AvoidStruts
                       (Choose (Mirror ((->) Int)) (Choose ((->) Int) Full))
                       Window
      Inferred type: XMonad.Layout.LayoutModifier.ModifiedLayout
                       AvoidStruts
                       (Choose (Mirror ((->) Int)) (Choose ((->) Int) Full))
                       (Rational -> Rational -> Tall a)
    In the `layoutHook' field of a record
    In the first argument of `additionalKeys', namely
        `defaultConfig
           {manageHook = manageDocks <+> myManageHook
                     <+>
                       manageHook defaultConfig,
            terminal = myTerminal, normalBorderColor = myNormalBorderColor,
            focusedBorderColor = myFocusedBorderColor, borderWidth = 1,
            layoutHook = avoidStruts $ Mirror Tall ||| Tall ||| Full,
            logHook = dynamicLogWithPP
                    $ xmobarPP
                        {ppOutput = hPutStrLn xmproc,
                         ppTitle = xmobarColor "white" "" . shorten 200,
                         ppCurrent = xmobarColor "#e04613" "" . wrap "[" "]",
                         ppLayout = layoutrename}}'

Please check the file for errors.

Current xmonad.hs:

import XMonad
--
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.UrgencyHook
import XMonad.Hooks.ManageHelpers
--
import XMonad.Actions.FindEmptyWorkspace
--
import XMonad.Layout.Named
--
import XMonad.Util.Run(spawnPipe)
import XMonad.Util.EZConfig(additionalKeys)
--
import System.IO


myTerminal ="urxvtc"
myNormalBorderColor  = "#000000"
myFocusedBorderColor = "#e04613"
myManageHook = composeAll
    [ className =? "gimp 2.6"      --> doFloat] 
    <+> composeOne
        [ isFullscreen -?> doFullFloat ]  

main = do
    xmproc <- spawnPipe "xmobar"
    xmonad $ defaultConfig
        { manageHook = manageDocks <+> myManageHook <+> manageHook defaultConfig
    , terminal = myTerminal
    , normalBorderColor = myNormalBorderColor
    , focusedBorderColor = myFocusedBorderColor
    , borderWidth = 1
        , layoutHook = avoidStruts  $  Mirror Tall ||| Tall ||| Full --layoutHook defaultConfig
        , logHook = dynamicLogWithPP $ xmobarPP 
            { ppOutput = hPutStrLn xmproc
                        , ppTitle = xmobarColor "white" "" . shorten 200
            , ppCurrent = xmobarColor "#e04613" "" . wrap "[" "]"
            , ppLayout = layoutrename
            }
        } `additionalKeys`
        [ ((controlMask, xK_Print), spawn "sleep 0.2; scrot -s")
        , ((0, xK_Print), spawn "scrot")
        , ((mod1Mask, xK_p), spawn "exe=`dmenu_path | yeganesh -- -fn \"-*-profont-*-*-*-*-11-*-*-*-*-*-iso8859\" -nb \"#1c1d1f\" -nf \"#6c9eab\" -sb \"#e04613\" -sf \"#FFFFFF\" -b -p \"Run:\"` && eval \"exec $exe\"")
    , ((mod1Mask, xK_e), viewEmptyWorkspace)
    , ((mod1Mask .|. shiftMask, xK_e), tagToEmptyWorkspace)
    ]
layoutrename "Mirror Tall" = "Wide"
layoutrename s = s

дɭɭɑӎɠїɾ

Offline

#182 2009-07-08 23:46:20

vogt
Member
From: Toronto, Canada
Registered: 2006-11-25
Posts: 389

Re: xmonad Hacking Thread

Allamgir: Tall takes 3 parameters

You could define (at top level) tall = let nmaster = 1; delta = 0.03; width = 0.5 in Tall nmaster delta width, and use that instead of Tall.

Offline

#183 2009-07-16 23:31:15

abijr
Member
Registered: 2008-05-18
Posts: 71

Re: xmonad Hacking Thread

How can you put gaps (spaces) between the windows in xmonad?

Offline

#184 2009-07-16 23:38:05

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: xmonad Hacking Thread

vogt wrote:

Allamgir: Tall takes 3 parameters

You could define (at top level) tall = let nmaster = 1; delta = 0.03; width = 0.5 in Tall nmaster delta width, and use that instead of Tall.

i'd recommend this:

myLayout = avoidStruts $ Mirror tall ||| tall ||| ...
  where
    tall       = Tall nmaster delta ratio
    nmaster    = 1
    delta      = 0.03
    ratio      = 0.5

my Layout hook has imLayout, tiled, threeCol, and hintedTile all defined neatly under the where statement.

Offline

#185 2009-07-17 00:22:49

vogt
Member
From: Toronto, Canada
Registered: 2006-11-25
Posts: 389

Re: xmonad Hacking Thread

abijr wrote:

How can you put gaps (spaces) between the windows in xmonad?

In xmonad-contrib-darcs, there is a module called: XMonad.Layout.Spacing, which does exactly that to any layout. Look at the source for usage information, if you can't be bothered to build the haddock documentation.

Offline

#186 2009-07-17 01:21:40

abijr
Member
Registered: 2008-05-18
Posts: 71

Re: xmonad Hacking Thread

thanks,

Offline

#187 2009-07-26 21:23:01

andre.ramaciotti
Member
From: Brazil
Registered: 2007-04-06
Posts: 649

Re: xmonad Hacking Thread

I know some people who use Xmonad don't know Haskell pretty well, so I'd like to share this tip. It doesn't do anything new, but I think the config file gets more "elegant".

This tip is aimed to those, who like me, like to have each kind of app in a different workspace. My manageHook used to have one line to each app, but you can reduce it to one line to each workspace doing like this:

myManageHook = composeAll . concat $
    [ [className =? c      --> doFloat | c <- myFloats]
    , [title =? t          --> doFloat | t <- myOtherFloats]
    , [className =? r      --> doIgnore | r <- myIgnores]

    , [className =? mp     --> doF (W.shift "mp") | mp <- mediaPlayers]
    , [className =? im     --> doF (W.shift "im") | im <- insMessenger]
    , [className =? bw     --> doF (W.shift "www") | bw <- browsers]
    , [className =? w      --> doF (W.shift "work") | w <- workApps]

    , [className =? "URxvt" --> doF (W.shift "term")]
    , [className =? "Emacs" --> doF (W.shift "emacs")]
    ]
    where
      myFloats = [ "Gimp", "MPlayer", "Nitrogen", "Galculator", "Sonata", "Thunar", "Leafpad", "Qjackctl", "Wine", "Pychrom", "Emacs"]
      myOtherFloats = ["Downloads", "Firefox Preferences", "Save As...", "Send file", "Open", "File Transfers"]
      myIgnores = ["trayer", "stalonetray"]

      mediaPlayers = ["Quodlibet"]
      insMessenger = ["Pidgin", "emesene"]
      browsers = ["Gran Paradiso", "Navigator", "Shiretoko", "Firefox", "Epiphany", "Opera", "Midori", "Conkeror"]
      workApps = ["Evince", "Mirage", "Gimp", "Inkscape"]

The variables mp, im, bw and w are replaced by each member of the lists mediaPlayers, insMessenger, browsers and workApps, respectivelly, so if I want to add one more app, it's as simple as adding one new string to the end of one list.


(lambda ())

Offline

#188 2009-08-14 15:31:34

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: xmonad Hacking Thread

so andre, i tried to modify my manageHook with your method (it's quite sweet).  but i'm getting compile errors i can't figure out:

xmonad_exp.hs:58:2:
    Couldn't match expected type `ManageHook'
           against inferred type `[a]'
    In the first argument of `(<+>)', namely...

here's what im using maybe you can help find my typo? is the <+> manageDocks throwing it?

-- Window Management
myManageHook = composeAll . concat $
  [ [title      =? i                                      --> doShift "1-irssi" | i  <- myIRC]
  , [className  =? w                                      --> doShift "2-web"   | w  <- myWebs]
  , [className  =? im                                     --> doShift "3-im"    | im <- myIms]
  , [className  =? cf                                     --> doCenterFloat     | cf <- myCenterFloats]
  , [className  =? f                                      --> doFloat           | f  <- myFloats]
  , [(className =? "Gajim.py" <&&> role =? "roster")      --> (ask >>= doF . W.sink)]
  , [(className =? "Shiretoko" <&&> resource =? "Dialog") --> doCenterFloat]
  ] <+> manageDocks
  where
    role           = stringProperty "WM_WINDOW_ROLE"
    myCenterFloats = ["Gajim.py", "MPlayer", "Zenity"]
    myFloats       = ["VirtualBox"]
    myIms          = ["Gajim.py"]
    myIRC          = ["irssi", "weechat"]
    myWebs         = ["Navigator", "Shiretoko", "Firefox", "Uzbl"]

Offline

#189 2009-08-14 18:49:20

andre.ramaciotti
Member
From: Brazil
Registered: 2007-04-06
Posts: 649

Re: xmonad Hacking Thread

I'm not sure, but if I were to guess, I'd say that opening a parentheses before "composeAll" and closing it just before "<+>" would work.


(lambda ())

Offline

#190 2009-08-14 19:18:00

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: xmonad Hacking Thread

andre.ramaciotti wrote:

I'm not sure, but if I were to guess, I'd say that opening a parentheses before "composeAll" and closing it just before "<+>" would work.

ah yes, i removed the <+> manageDocks and it compiled fine... i'll try putting it back in with your parentheses idea; either way, i'm satisfied.

/edit: yup, your parenthesis worked.  many thanks.

Last edited by brisbin33 (2009-08-14 19:26:36)

Offline

#191 2009-08-14 22:22:25

vogt
Member
From: Toronto, Canada
Registered: 2006-11-25
Posts: 389

Re: xmonad Hacking Thread

A cleaner option might be to stick manageDocks in with the other managehooks:

  , [(className =? "Gajim.py" <&&> role =? "roster")      --> (ask >>= doF . W.sink)]
  , [(className =? "Shiretoko" <&&> resource =? "Dialog") --> doCenterFloat, manageDocks ]
  ]

Offline

#192 2009-08-21 15:23:38

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: xmonad Hacking Thread

so i came up with [ what i think is ] a cool way to do multiple dzens in your xmonad.hs.  this'll let you define fonts and colors in one place (so you can change them for all dzens at once, which is how i do it) and then pass geometry and text alignment to a function and have it generate the dzen command as needed.  with this method is should be super easy to tweak colors, and add other dzen's around your screen

-- Dzen stuff
conkyFile  = "~/.dzen_conkyrc"
myDzenFont = "Verdana-8" -- xft enabled dzen req'd

colorRed   = "#ff0000" -- bright red
colorGrey0 = "#303030" -- grey
colorGrey1 = "#606060" -- light grey
colorGrey2 = "#909090" -- lighter grey

makeDzen (x,y,w,h,a) = "dzen2 -p" ++
                       " -ta "    ++ a ++
                       " -x "     ++ show x ++
                       " -y "     ++ show y ++
                       " -w "     ++ show w ++
                       " -h "     ++ show h ++
                       " -fn '"   ++ myDzenFont ++ "'" ++
                       " -fg '"   ++ colorGrey1 ++ "'" ++
                       " -bg '"   ++ colorGrey0 ++ "'"

myLeftBar   = makeDzen (0,0,700,15,"l")
myRightBar  = "conky -c " ++ conkyFile ++ " | " ++ makeDzen (700,0,1220,15,"r")

i'm pretty sure it works, though i'm not home to check visually:

┌─[ 11:21 ][ blue:~ ]
└─> ghci experimental.hs
GHCi, version 6.10.4: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
[1 of 1] Compiling Main             ( experimental.hs, interpreted )
Ok, modules loaded: Main.
*Main> show myLeftBar
"\"dzen2 -p -ta l -x 0 -y 0 -w 700 -h 15 -fn 'Verdana-8' -fg '#606060' -bg '#303030'\""
*Main> show myRightBar
"\"conky -c ~/.dzen_conkyrc | dzen2 -p -ta r -x 700 -y 0 -w 1220 -h 15 -fn 'Verdana-8' -fg '#606060' -bg '#303030'\""
*Main>

/edit: colorRed and colorGrey2 are used in my logHook.  side benefit of defining things this way.

Last edited by brisbin33 (2009-08-21 15:25:18)

Offline

#193 2009-09-06 00:37:21

SamC
Member
From: Calgary
Registered: 2008-05-13
Posts: 611
Website

Re: xmonad Hacking Thread

Does anyone know if it is possible to keep the focus on the current window when a new window is created?

Offline

#194 2009-09-06 00:53:48

Knute
Member
From: Minot, ND
Registered: 2009-03-17
Posts: 604

Re: xmonad Hacking Thread

SamC wrote:

Does anyone know if it is possible to keep the focus on the current window when a new window is created?

Not sure if there's a way to do that,  I'ld have to say probably, but a work around, since I dont know for sure, would be to create a keybinding that will open the new window then send the command to change focus to the previous window.

I know it sounds ugly, but it would do what you want.


Knute

Offline

#195 2009-09-08 16:37:39

myrkiada
Member
From: Norway
Registered: 2009-04-15
Posts: 74

Re: xmonad Hacking Thread

Ok, so I tried putting icons in my dzen bar (kinda ugly hack(?), but hey it worked). Only problem is that my urgenthook is kinda messed up, it still works but dzenStrip strips my icons away. So, I was thinking; there must be a way to change dzenStrips behaviour and make it nicer to my icons. I searched google and tought I'd try something like below, making my own dzenDontStripMyIcons. tongue I recompile and it complains that `isPrefixOf` is not in scope. Ok, i commented out that line just to see what would happen. It now compiles without problems, and urgencyHook works, but still it strips my icons away. So the big question, as I am still a n00b at haskell.. is it even possible to make it keep my icons? And if so, how do I change my dzenDontStripMyIcons to make it do so?

###
ppUrgent = dzenColor "#616161" "#D4D455" . dzenDontStripMyIcons
###

dzenDontStripMyIcons :: String -> String
dzenDontStripMyIcons = strip [] where
    strip keep x
      | null x              = keep
 --     | "^^" `isPrefixOf` x = strip (keep ++ "^") (drop 2 x)
      | '^' == head x       = strip keep (drop 1 . dropWhile (/= ')') $ x)
      | otherwise           = let (good,x') = span (/= '^') x
                              in strip (keep ++ good) x'

Below you can see how my icons are implemented:
the ^i(...) is what dzenStrip strips away.. whatever is outside of that one it keeps.

-- Workspaces
workspaces' :: [WorkspaceId]
workspaces' = clickable $ ["^i(/home/myrkiada/.xmonad/icons/sm4tik/screen.xbm):screen", -- 0
                           "^i(/home/myrkiada/.xmonad/icons/sm4tik/fox.xbm):web", -- 1
                           "^i(/home/myrkiada/.xmonad/icons/sm4tik/dev.xbm):dev", -- 2
                           "^i(/home/myrkiada/.xmonad/icons/sm4tik/book.xbm):lib", -- 3
                           "^i(/home/myrkiada/.xmonad/icons/sm4tik/mouse_01.xbm):gfx", -- 4
                           "^i(/home/myrkiada/.xmonad/icons/sm4tik/cpu.xbm):vm", -- 5
                           "^i(/home/myrkiada/.xmonad/icons/sm4tik/info_03.xbm):sys" --6
                          ]

              where clickable l = [ "^ca(1,xdotool key super+" ++ show (n) ++ ")" ++ ws ++ "^ca()" |
                                    (i,ws) <- zip [1..] l,
                                    let n = if i == 10 then 0 else i ]

No urgency:
dzenxmonadicon1.jpg
dzenStrip killed my icon:
dzenxmonadicon2.jpg

Last edited by myrkiada (2009-09-08 16:56:42)


My Configs @ Github

Offline

#196 2009-09-08 17:26:51

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: xmonad Hacking Thread

it looks like you've just copied the default dzenStrip from the latest darcs sources.

to get isPrefixOf youll need to import Data.List, but i suggest you just upgrade your darcs and try that dzenStrip first, then start hacking again.  maybe just make it more targeted?

dzenDontStripMyIcons = strip [] where
    strip keep x
      | null x               = keep
      | "^^"  `isPrefixOf` x = strip (keep ++ "^") (drop 2 x) -- i really don't know what the double ^^ is for...
      | "^fg" `isPrefixOf` x = strip keep (drop 1 . dropWhile (/= ')') $ x)
      | "^bg" `isPrefixOf` x = strip keep (drop 1 . dropWhile (/= ')') $ x)
      | otherwise            = let (good,x') = span (/= '^') x
                               in strip (keep ++ good) x'

Last edited by brisbin33 (2009-09-08 17:32:01)

Offline

#197 2009-09-08 17:41:13

myrkiada
Member
From: Norway
Registered: 2009-04-15
Posts: 74

Re: xmonad Hacking Thread

Yeah it's the default dzenStrip, I just thought it would be a good idea to start with that and make dzenDontStripMyIcons and tweak that one to my preference, but I don't really understand how the code works. tongue I updated darcs a couple of days ago, but I see there has been an update since then, so I'll do that now. Thanks for the hint on isPrefixOf, couldn't find out why it was not in scope.

Anyway, I'll try tweaking your example and see what happens. That one makes kinda more sense. smile

Edit: Ok, now "isPrefixOf" is working, so I'll just update darcs and then start hackin.

Edit2: Well, that did not work.. Without the following line XMonad hangs (and eventually crash) when urgencyhook is triggered, so I put it back in.. Anyway, thanks for your help, I'll see if I can work it out somehow. smile

| '^' == head x       = strip keep (drop 1 . dropWhile (/= ')') $ x)

Last edited by myrkiada (2009-09-08 18:35:34)


My Configs @ Github

Offline

#198 2009-09-08 19:21:41

myrkiada
Member
From: Norway
Registered: 2009-04-15
Posts: 74

Re: xmonad Hacking Thread

dzenxmonadicon3.jpg

Purrfect!

It was kinda easier than I thougt really, but having no clue about haskell whatsoever exept for playing with XMonad it took me some time to get it right. tongue

This did the trick:

dzenDontStripMyIcons :: String -> String
dzenDontStripMyIcons = strip [] where
    strip keep x
      | null x                  = keep
      | "^i" `isPrefixOf`     x = strip (keep ++"^") (drop 1 x)
      | "^ca" `isPrefixOf`    x = strip (keep ++"^") (drop 1 x)
      | '^' == head x           = strip keep (drop 1 . dropWhile (/= ')') $ x)
      | otherwise               = let (good,x') = span (/= '^') x
                                        in strip (keep ++ good) x'

Now I just have to get the "urgent workspace" to be "clickable"..

Edit: Well that was pretty simple, just add another exeption for "^ca".. (updated code above)

Last edited by myrkiada (2009-09-08 20:45:28)


My Configs @ Github

Offline

#199 2009-09-09 03:40:57

opothehippo
Member
From: hella norcal bro
Registered: 2009-08-06
Posts: 89

Re: xmonad Hacking Thread

I have a couple of xmonad.hs questions that I really havn't been able to solve just looking at configs and documentation. It's mostly an issue of my xmonad.hs being slightly different, and not working because I can't figure out the haskell.

I'm trying to find the best way of using the layout hook. Right now I've got it like this:

layoutHook' = avoidStruts $ layoutHook defaultConfig ||| simpleTabbed ||| spiral (6/7)

How would I remove the default layouts to this in a simple and straightforward way? (I want to be able to change the Tall, Mirror Tall, and Full layouts also.)

I also would like to know how to edit my logHook to modify the appearance of StdinReader. Its something to do with my logHook but every time I touch it I get a whole slew of errors. I've set up xmobar using the wiki suggestion, though not really understanding the code I copied. Here is my xmonad.hs for reference:

--imports
import XMonad
import IO
import XMonad.Hooks.DynamicLog
import XMonad.Util.Run
import XMonad.Hooks.ManageDocks

--layouts
import XMonad.Layout.NoBorders
import XMonad.Layout.Tabbed
import XMonad.Layout.Spiral
import XMonad.Layout.Named
import XMonad.Layout.Accordion
import XMonad.Layout.Grid

main = do
    xmobar <- spawnPipe "xmobar"
    xmonad $ defaultConfig
        { terminal = "urxvt"
        , workspaces = workspaces'
        , borderWidth = 1
        , normalBorderColor = "#161616"
        , focusedBorderColor = "#43a2a6"
        , logHook = dynamicLogWithPP $ xmobarPP { ppOutput = hPutStrLn xmobar }
        , manageHook = manageDocks <+> manageHook defaultConfig
        , layoutHook = layoutHook'
        }


--named workspaces
workspaces' :: [WorkspaceId]
workspaces' = ["1-term", "2-web", "3-talk", "4-code", "5-gui", "6-else", "7-else", "8-else", "9-else"]

--layoutHook
layoutHook' = avoidStruts $ layoutHook defaultConfig ||| simpleTabbed

Any other suggestions for cleaning/improving my xmonad.hs would be greatly appreciated.


Arch x86_64 | XMonad

Offline

#200 2009-09-09 13:42:24

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: xmonad Hacking Thread

opothehippo wrote:

I have a couple of xmonad.hs questions that I really havn't been able to solve just looking at configs and documentation. It's mostly an issue of my xmonad.hs being slightly different, and not working because I can't figure out the haskell.

I'm trying to find the best way of using the layout hook. Right now I've got it like this:

layoutHook' = avoidStruts $ layoutHook defaultConfig ||| simpleTabbed ||| spiral (6/7)

How would I remove the default layouts to this in a simple and straightforward way? (I want to be able to change the Tall, Mirror Tall, and Full layouts also.)

layoutHook' = avoidStruts $ myTall ||| Mirror myTall ||| simpleTabbed ||| Full ||| spiral (6/7)
  where
    myTall = -- whatever crazy tall or ResizableTall layout you want to setup...
opothehippo wrote:

I also would like to know how to edit my logHook to modify the appearance of StdinReader

main = do
    xmobar <- spawnPipe "xmobar"
    xmonad $ defaultConfig
        { terminal = "urxvt"
        , workspaces = workspaces'
        , borderWidth = 1
        , normalBorderColor = "#161616"
        , focusedBorderColor = "#43a2a6"
        , logHook = logHook' xmobar
        , manageHook = manageDocks <+> manageHook defaultConfig
        , layoutHook = layoutHook'
        }


--logHook
logHook' h = dynamicLogWithPP $ xmobarPP
  { ppCurrent = xmobarColor "foreground" "background"
  , ppHidden = xmobarColor "foreground" "background"
  , ppOutput = hputStrLn h
  }
  -- you can list just the ppThings you want to override from xmobarPP
  -- ppOutput is required
  -- check the docs on xmonad.org for all the available options
  -- xmonad-contrib-darcs /might/ be required for xmobarColor

have fun.

*note, off the top of my head, i may have typoed, but you get the idea.

Offline

Board footer

Powered by FluxBB