You are not logged in.

#376 2010-07-28 14:17:45

valium97582
Member
Registered: 2010-06-19
Posts: 126

Re: xmonad Hacking Thread

Just for curiosity, it may be a little offtopic and I know I may be flamed but, as a functional programming language, which avoids side effects, doesn't Xmonad go against Haskell style?

Just for curiosity.


I'm also known as zmv on IRC.

Offline

#377 2010-07-28 15:48:40

Runiq
Member
From: Germany
Registered: 2008-10-29
Posts: 1,053

Re: xmonad Hacking Thread

valium97582 wrote:

Just for curiosity, it may be a little offtopic and I know I may be flamed but, as a functional programming language, which avoids side effects, doesn't Xmonad go against Haskell style?

Just for curiosity.

Why would it? The whole point of haskell being a purely functional language is that there aren't any side effects. The things peceived as side effects are handled in some kind of functional way (one that I don't grok yet—monads and their relatives, probably).

Edit: By the way, count—I came up with the exact same way to switch workspaces entirely in xmonad.hs, and man, was I ever proud of it… Until I recompiled and got some weird kind of type error I couldn't resolve for the life of me. sad I guess I'll just copypaste.

Edit2: Thanks for the socat idea. *rubs hands with glee*

Last edited by Runiq (2010-07-28 15:54:51)

Offline

#378 2010-07-28 17:08:25

count-corrupt
Member
From: Germany
Registered: 2009-02-01
Posts: 112

Re: xmonad Hacking Thread

Runiq wrote:

Edit: By the way, count—I came up with the exact same way to switch workspaces entirely in xmonad.hs, and man, was I ever proud of it… Until I recompiled and got some weird kind of type error I couldn't resolve for the life of me. sad I guess I'll just copypaste.

It's pretty sensitive to where you apply the mapping of keys. I started using code from the actual PP module to insert the mapping way up the tree but it resulted in nonsense because the workspaces hadn't been sorted yet.

Runiq wrote:

Edit2: Thanks for the socat idea. *rubs hands with glee*

No problem. If you're gaining on that, please let us know. I'm pretty sure it won't take more than an afternoon to figure out the details but everytime I remember I wanted to do it, I have like 15mins of time sad
I never felt comfortable with running shell scripts for all the data I need displayed. And running multiple instances of conky defeats the whole purpose of conky. Socat seems an elegant way to solve this and add the possibility to create cool submenus in dzen.

I also had this strange idea last night about dzen and trayer. What if we integrated trayer's behavior into dzen? I imagine a ^tray() command that just catches systray icons and dynamically expands from 0px width to whatever space necessary. Shouldn't be too hard to do. Gotmor? I haven't yet found a clever way to handle a tray within xmonad and dzen.

Offline

#379 2010-07-28 19:06:09

count-corrupt
Member
From: Germany
Registered: 2009-02-01
Posts: 112

Re: xmonad Hacking Thread

Take a look at this

data ThinkLightUrgencyHook = ThinkLightUrgencyHook
                    { blinks :: Int -- ^ number of times to blink the thinklight 
                    }   
     deriving (Read, Show)

instance UrgencyHook ThinkLightUrgencyHook where
    urgencyHook ThinkLightUrgencyHook { blinks = d } w = do
    spawn ("thinkalert " ++ show d)
    return () 
        
myUrgencyHook = withUrgencyHook ThinkLightUrgencyHook
    { blinks = 2 }

It's an urgenthook that flashes the thinklight of Thinkpad laptops (thinkalert has to be installed of course). In my case, the LED flashes two times whenever something urgent happens. It should be easy to adapt this to other laptops or systems.

Last edited by count-corrupt (2010-07-28 19:07:26)

Offline

#380 2010-07-29 04:04:05

splittercode
Member
From: WI, USA
Registered: 2010-03-16
Posts: 203

Re: xmonad Hacking Thread

valium97582 wrote:

Just for curiosity, it may be a little offtopic and I know I may be flamed but, as a functional programming language, which avoids side effects, doesn't Xmonad go against Haskell style?

Just for curiosity.

No way! big_smile  I definitely won't flame you though, as that's a very good question.

A simple way to think about how Haskell handles state and IO is that it takes an initial "world"(in XMonad this is the empty screen you encounter when you log in) and passes it as an argument to functions that include a new "world" in their output(in XMonad these functions would be opening a new window, closing a window, shifting windows, etc).  After a world is 'used'(had a function applied to it), it disappears, never to be seen/heard from again, and only the new world remains.  This new world is then in turn fed as the input to those same functions and the process repeats.  This way, the content of any particular world cannot change once it is created and functions always produce the same output given the same input(a core idea behind Haskell).  One of the many things the infamous Monad provides is a framework to encapsulate IO so the programmer doesn't have to explicitely keep passing these worlds around their functions themselves.  Hopefully that made sense. hmm

Oh yeah, and in a last ditch attempt to stay on topic, here's my xmonad.hs. tongue
http://pastebin.com/eJe7KpsA

Offline

#381 2010-07-29 11:10:52

count-corrupt
Member
From: Germany
Registered: 2009-02-01
Posts: 112

Re: xmonad Hacking Thread

splittercode wrote:

Oh yeah, and in a last ditch attempt to stay on topic, here's my xmonad.hs. :Phttp://pastebin.com/eJe7KpsA

Those list generators in your manageHook are pretty cool. I'll adapt my config to that.

Offline

#382 2010-07-29 11:21:12

splittercode
Member
From: WI, USA
Registered: 2010-03-16
Posts: 203

Re: xmonad Hacking Thread

count-corrupt wrote:
splittercode wrote:

Oh yeah, and in a last ditch attempt to stay on topic, here's my xmonad.hs. :Phttp://pastebin.com/eJe7KpsA

Those list generators in your manageHook are pretty cool. I'll adapt my config to that.

All credit to brisbin33 on that one, I never would have thought to do that had I not seen his config.
http://pbrisbin.com:8080/pages/dots.htm … _xmonad.hs

Offline

#383 2010-07-29 14:02:09

Runiq
Member
From: Germany
Registered: 2008-10-29
Posts: 1,053

Re: xmonad Hacking Thread

count-corrupt wrote:
Runiq wrote:

Edit: By the way, count—I came up with the exact same way to switch workspaces entirely in xmonad.hs, and man, was I ever proud of it… Until I recompiled and got some weird kind of type error I couldn't resolve for the life of me. sad I guess I'll just copypaste.

It's pretty sensitive to where you apply the mapping of keys. I started using code from the actual PP module to insert the mapping way up the tree but it resulted in nonsense because the workspaces hadn't been sorted yet.

I finally figured it out. Thanks again!

Offline

#384 2010-07-29 14:09:33

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

Re: xmonad Hacking Thread

splittercode wrote:
count-corrupt wrote:
splittercode wrote:

Oh yeah, and in a last ditch attempt to stay on topic, here's my xmonad.hs. :Phttp://pastebin.com/eJe7KpsA

Those list generators in your manageHook are pretty cool. I'll adapt my config to that.

All credit to brisbin33 on that one, I never would have thought to do that had I not seen his config.
http://pbrisbin.com:8080/pages/dots.htm … _xmonad.hs

hey thanks for that callout!

i also like this one from yours:

[ ((0, x), namedScratchpadAction genScratchPads y) | (x,y) <- zip [xK_F12, xK_F11..xK_F1] myScratchPadNames ]

one note though, X.U.NamedScratchPad also exports the free accessor function 'name' because the NS datatype is defined in record syntax.  this means you could use it in myScratchPadNames (or place it directly in the above)

myScratchPadNames = map name myScratchPads

(i hope that's all accurate -- bit of a haskell noob myself)

Last edited by brisbin33 (2010-07-29 14:10:54)

Offline

#385 2010-07-30 09:06:56

splittercode
Member
From: WI, USA
Registered: 2010-03-16
Posts: 203

Re: xmonad Hacking Thread

brisbin33 wrote:

one note though, X.U.NamedScratchPad also exports the free accessor function 'name' because the NS datatype is defined in record syntax.  this means you could use it in myScratchPadNames (or place it directly in the above)

myScratchPadNames = map name myScratchPads

Nice idea!  I just added it directly to the key binding, works like a charm. 

brisbin33 wrote:

(i hope that's all accurate -- bit of a haskell noob myself)

Yeah, me too.   Haskell makes everyone feel like a noob I think tongue

Offline

#386 2010-07-30 14:53:00

count-corrupt
Member
From: Germany
Registered: 2009-02-01
Posts: 112

Re: xmonad Hacking Thread

splittercode wrote:
brisbin33 wrote:

(i hope that's all accurate -- bit of a haskell noob myself)

Yeah, me too.   Haskell makes everyone feel like a noob I think tongue

It's not even that much feeling as a noob as it is forgetting the details of the language. Haskell can do so many things in so many ways that almost everytime there's an even cleaner or more elegant solution to a problem. I've heard a whole lecture about it and still feel like I'm just touching the surface.

Anyway, I've adapted my Managehook and it now looks like this

myManageHook = (composeAll . concat $
    [ [className =? c --> doF (W.shift "web")  | c <- myWebs]
    , [className =? c --> doF (W.shift "img")  | c <- myImgs]
    , [className =? c --> doF (W.shift "IM")   | c <- myIms]
    , [className =? c --> doF (W.shift "fm")   | c <- myFms]
    , [className =? c --> doF (W.shift "laut") | c <- myLauts]
    , [className =? c --> doF (W.swapDown)     | c <- mySwapDowns]
    , [className =? c --> doFloat              | c <- myFloats]
    ]) <+> mySpecialHooks
    where
       myWebs      = ["Firefox"]
       myImgs      = ["Gimp","Gimp-2.6"]
       myIms       = ["Pidgin","Skype"]
       myFms       = ["pcmanfm","Krusader","Dolphin"]
       myLauts     = ["Amarok"]
       mySwapDowns = ["Skype","Pidgin"]
       myFloats    = ["Truecrypt","."]

       mySpecialHooks = composeAll
            [ (role =? "gimp-toolbox" <||> role =? "gimp-image-window" <||> role =? "gimp-dock") --> (ask >>= doF . W.sink)
            , name =? "Copying" --> doCenterFloat -- Krusader copy dialog
            , isFullscreen --> doFullFloat -- fullscreen flash and stuff
            , transience' -- focus parent windows of transient ones
            ]

       role = stringProperty "WM_WINDOW_ROLE"
       name = stringProperty "WM_NAME"

Which is way more elegant than my previous approach.

Offline

#387 2010-08-01 01:19:08

tomn
Member
Registered: 2010-08-01
Posts: 1

Re: xmonad Hacking Thread

Hi,

I've been using XMonad on arch for a few months now, and i really love it, but i've been seeing quite a lot of latency (almost half a second!) when doing anything with windows (switching,reordering etc). After a bit of playing, i traced it back to the dock manager (XMonad.Hooks.ManageDocks), and specifically avoidStruts, for example, the following minimal config shows the problem:

import XMonad                                                                                            
import XMonad.Hooks.DynamicLog                                                                           
import XMonad.Hooks.ManageDocks                                                                          
import XMonad.Util.Run(spawnPipe)                                                                        
import System.IO

myDock = "killall trayer; trayer --SetPartialStrut true --height 8 --widthtype request --align right --edge top --transparent true --tint 0x000000"
myTerminal = "xterm -bg black -fg white" 
myModMask = mod4Mask
                                                                                                         
main = do                                                                                                
     xmproc <- spawnPipe "xmobar" 
     spawn myDock 
     xmonad $ defaultConfig
              { manageHook = manageDocks <+> manageHook defaultConfig
              , layoutHook = avoidStruts $ layoutHook defaultConfig
              , logHook = dynamicLogWithPP $ xmobarPP
                          { ppOutput = hPutStrLn xmproc
                          , ppTitle = xmobarColor "green" "" . shorten 50
                          , ppUrgent = xmobarColor "yellow" "red" . xmobarStrip
                          }
              , modMask = myModMask
              , terminal = myTerminal
              }

The problem goes away if i remove "avoidStruts", and is worse with a larger screen area (worse with an external screen on my netbook than without.)

Has anyone else experienced anything like this, or am i just doing something daft?

Thanks in advance smile

Offline

#388 2010-08-01 02:11:27

splittercode
Member
From: WI, USA
Registered: 2010-03-16
Posts: 203

Re: xmonad Hacking Thread

tomn wrote:

I've been using XMonad on arch for a few months now, and i really love it, but i've been seeing quite a lot of latency (almost half a second!) when doing anything with windows (switching,reordering etc). After a bit of playing, i traced it back to the dock manager (XMonad.Hooks.ManageDocks), and specifically avoidStruts, for example, the following minimal config shows the problem:

Given how basic your xmonad.hs is, I'm pretty baffled by this as well.  Trayer might be interacting funny with avoidStruts, though unfortunately I sort of doubt the solution is that simple.  You might have already tried it, but see if it still lags if you start XMonad without trayer.   Also, are you using anything like xcompmgr?

If you're up to it, you could try removing the standard repo versions of xmonad, xmonad-contrib, and xmobar and get the darcs versions from the AUR.  Perhaps it's a bug that's been fixed already(XMonad has pretty active development).  If that still doesn't help and no one else can help you here, I'd highly suggest visiting the XMonad IRC channel, as I'm sure the devs would want to hear about this.

Offline

#389 2010-08-15 20:25:20

invalido
Member
From: Sweden
Registered: 2009-02-28
Posts: 17

Re: xmonad Hacking Thread

Nice thread!
Does anyone know how to make focus move to the window above when a window is automatically killed?

Offline

#390 2010-08-16 23:36:51

valium97582
Member
Registered: 2010-06-19
Posts: 126

Re: xmonad Hacking Thread

I do not, try asking in the xmonad irc channel.


I'm also known as zmv on IRC.

Offline

#391 2010-08-17 22:41:03

invalido
Member
From: Sweden
Registered: 2009-02-28
Posts: 17

Re: xmonad Hacking Thread

valium97582 wrote:

I do not, try asking in the xmonad irc channel.

Yeah tried that already but no go.
Right now im using xmonad.insertPosistion to make new windows appear below rather than above the focused one. But I cannot get my head around how to make the focus work in "reverse" order. Oh well I will continue my hunt!

Offline

#392 2010-08-18 01:16:03

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

Re: xmonad Hacking Thread

Does anybody know what class or resource name MS Word has [in xmonad] when used with wine? I'm using fade inactive and I would like to add it as an exception....

Offline

#393 2010-08-18 01:26:25

splittercode
Member
From: WI, USA
Registered: 2010-03-16
Posts: 203

Re: xmonad Hacking Thread

@abijr
You should be able to find it by running 'xprop' in a terminal and clicking on MS Word.  You can try xprop | grep CLASS to get just the class.

Offline

#394 2010-08-18 01:29:27

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

Re: xmonad Hacking Thread

splittercode wrote:

@abijr
You should be able to find it by running 'xprop' in a terminal and clicking on MS Word.  You can try xprop | grep CLASS to get just the class.

Nice..... thanks!

Offline

#395 2010-09-01 00:08:35

soderstrom
Member
Registered: 2010-08-30
Posts: 10

Re: xmonad Hacking Thread

I've been trying to find  a xmonad config that uses the cross layout. If someone have it I would really appreciate if you could share it with me.

Offline

#396 2010-09-01 00:29:43

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: xmonad Hacking Thread

soderstrom wrote:

I've been trying to find  a xmonad config that uses the cross layout. If someone have it I would really appreciate if you could share it with me.

While strickly speaking, layoutHints is pointless for Cross, it was sort of lumped in when I still had a more complex set up. Here's the relevant bits:

xmonad $ defaultConfig
      { terminal           = "urxvtc"
      , modMask            = mod4Mask
      , borderWidth        = 2
      , focusedBorderColor = "#0000ff"
      , normalBorderColor  = "#000000"
      , keys               = keys'
      , manageHook         = manageHook' 
      , layoutHook         = avoidStruts
                           $ toggleLayouts (noBorders Full)
                           $ smartBorders 
                           $ windowNavigation ( layoutHints ( Cross (3/5) (1/20)  ||| ResizableTall 1 (3/100) (1/2) [] ))

... snip ...

Offline

#397 2010-09-01 12:11:15

soderstrom
Member
Registered: 2010-08-30
Posts: 10

Re: xmonad Hacking Thread

skottish wrote:
soderstrom wrote:

I've been trying to find  a xmonad config that uses the cross layout. If someone have it I would really appreciate if you could share it with me.

While strickly speaking, layoutHints is pointless for Cross, it was sort of lumped in when I still had a more complex set up. Here's the relevant bits:

xmonad $ defaultConfig
      { terminal           = "urxvtc"
      , modMask            = mod4Mask
      , borderWidth        = 2
      , focusedBorderColor = "#0000ff"
      , normalBorderColor  = "#000000"
      , keys               = keys'
      , manageHook         = manageHook' 
      , layoutHook         = avoidStruts
                           $ toggleLayouts (noBorders Full)
                           $ smartBorders 
                           $ windowNavigation ( layoutHints ( Cross (3/5) (1/20)  ||| ResizableTall 1 (3/100) (1/2) [] ))

... snip ...

Thanks for the reply, but I have no idea where to add this in the xmonad.hs file? I've been tinkering with my Arch installation now for more than 12 hours (haha!, yeah I am a noob) and just got things working with wifi and gnome smile

I was watching this clip on youtube http://www.youtube.com/watch?v=kesRhuTctWk and loved what I saw there, but the guy don't wanna share his configuration and I've been trying to find something similar so ended up reading about the cross layout wich is similar to the circle layout but makes the windows stay in one possition just like the ones posted on you tube video.

If I could just get that style on my xmonad.hs my search for a Linux distro I feel good with is finaly over and I can decide to erase OSX for good smile Arch Linux is brilliant ones all the configuration is done. Never been so easy and fast to install applications with pacman and great support at this forum.

Offline

#398 2010-09-01 12:24:32

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

Re: xmonad Hacking Thread

Your xmonad.hs file would be located in your home directory: /home/user/.xmonad
replace the italics with the user name that you used to login with.

I'm not sure where you are in the learning curve that comes with linux, so if you don't have an xmonad.hs file inside the hidden directory .xmonad in your home directory, then you can just copy and paste what was posted as the xmonad.hs file then compile it with xmonad --recompile.


Knute

Offline

#399 2010-09-01 13:38:04

soderstrom
Member
Registered: 2010-08-30
Posts: 10

Re: xmonad Hacking Thread

Knute wrote:

Your xmonad.hs file would be located in your home directory: /home/user/.xmonad
replace the italics with the user name that you used to login with.

I'm not sure where you are in the learning curve that comes with linux, so if you don't have an xmonad.hs file inside the hidden directory .xmonad in your home directory, then you can just copy and paste what was posted as the xmonad.hs file then compile it with xmonad --recompile.

I have been learning allot the past few days and already managed to get a working xmonad.hs and xmobarrc running. Just got confused by the lack of code he posted compared to the downloaded configuration from Arch wiki I was testing. Will try it and see if I can get it to work.

Thanks for helping out!

Edit: I edited the xmonad.hs file with the code posted above saved it and did xmonad --recompile. I got this error message

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

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

Please check the file for errors.

Last edited by soderstrom (2010-09-01 13:43:48)

Offline

#400 2010-09-01 23:57:51

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

Re: xmonad Hacking Thread

Haskell is pickier than other languages about white space. 

That's saying that line 15  space zero  of your xmonad.hs file is not indented correctly.

From my experience it could be even a line before that or after it, but it is helpful.  All you need to do is go in and check your indenting.  If all you did was a cut and paste, then you may need to go back in and adjust indenting so that it looks like what was posted.
(Indenting and such is also why we use code tags when we post code, because some languages are picky about indenting, like haskell, and some, like perl and awk, don't care if you have extra spaces or not.)

HTH


Knute

Offline

Board footer

Powered by FluxBB