You are not logged in.

#1 2015-03-15 21:37:26

davama
Member
From: NY
Registered: 2014-02-07
Posts: 45

[Solved] xmonad copywindow loghook

Hello im trying to Highlight workspaces containing copies in logHook
I was following this: http://xmonad.org/xmonad-docs/xmonad-co … indow.html
But i cant seem to figure out how to implement it with my loghook.
This is what i have so far:
(note "--<< FROM THE HAKEL..."  lines)

myDzenStatus = myDzenbar1
myDzenLogHook h = dynamicLogWithPP $ myDzenPP h
copies <- wsContainingCopies                                                                  --<< FROM THE HASKELL PAGE
myDzenPP h = dzenPP { 
	ppOutput 		= hPutStrLn h
   	, ppTitle   		= dzenColor (colorLook Green 0) "" . wrap "^ca(2,xdotool key super+shift+c)" "^ca()" . shorten 50
    	, ppCurrent		= dzenColor (colorLook Green 1) "" . wrap "[" "]" . wrap "^ca(2,xdotool key alt+shift+c)" "^ca()"
	, ppVisible		= dzenColor (colorLook White 0) "" . wrap "(" ")"
--	, ppHidden		= dzenColor (colorLook White 1) "" . wrap "" "" . noScratch
	, ppHidden		= check                                                          --<< FROM THE HASKEL PAGE
	, ppOutput		= hPutStrLn h                                                --<< FROM THE HASKEL PAGE
	, ppHiddenNoWindows	= noScratchPad
    	, ppUrgent		= dzenColor (colorLook Black 0) (colorLook Red 0) . wrap ">" "<" . dzenStrip
	, ppLayout	  	= dzenColor (colorLook Orange 0) "" . wrap "^ca(1,xdotool key super+space)^ca(3,xdotool key super+shift+space)" "^ca()^ca()"
    	, ppSep			= " : "
    	, ppWsSep		= " "
	}
	where
		noScratch ws = if ws == "NSP" then "" else ws
		noScratchPad ws = if ws == "NSP" then "" else ""
    		let check ws | ws `elem` copies = pad . dzenColor "red" "black" $ ws | otherwise = pad ws         --<< FROM THE HASKEL PAGE

When i restart xmonad, i receive this error:
xmonad.hs:328:8: parse error on input â<-â

Which is the line "copy <- wsContainingCopies". Please help.

This is my main

xmproc <- spawnPipe myDzenStatus	
...
, logHook = myDzenLogHook xmproc

Any input is apprecieated.
Thanks
Dave

Last edited by davama (2015-03-16 00:52:32)

Offline

#2 2015-03-15 22:48:26

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

Re: [Solved] xmonad copywindow loghook

The reason that you are getting the error is that you missed a line when you were copying it over.

sampleLogHook h = do
    copies <- wsContainingCopies

These lines are necessary in this order.  Haskell is simply telling you that it has no effing idea what you want it to do with your copies line or where to put it.


Knute

Offline

#3 2015-03-15 23:12:29

davama
Member
From: NY
Registered: 2014-02-07
Posts: 45

Re: [Solved] xmonad copywindow loghook

Knute wrote:

These lines are necessary in this order.  Haskell is simply telling you that it has no effing idea what you want it to do with your copies line or where to put it.

Thank you for replying.
A simple copy of that line does not do the trick. I had already tried that. Since i already have a working logHook, "myDzenLogHook",  i was trying to implement it there.

How would i tell haskell to run that line with my current setup?

Thanks again

Offline

#4 2015-03-15 23:27:01

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

Re: [Solved] xmonad copywindow loghook

You would need to put your copies line up in your declarations at the beginning of the file.

After your import statements you may have a line similar to mine:

main = do
  nScreens <- countScreens
  dzen <- spawnPipe myStatusBar

I believe that you would need to add your copies line after main = do  where mine are.
As I have no formal training in haskell this is my best guess.


Knute

Offline

#5 2015-03-15 23:53:17

davama
Member
From: NY
Registered: 2014-02-07
Posts: 45

Re: [Solved] xmonad copywindow loghook

Knute wrote:

You would need to put your copies line up in your declarations at the beginning of the file.

I tried that here:

main = do
 copies <- wsContainingCopies
....
	, logHook = myDzenLogHook xmproc

Unfortunately i can't figure where to place my "check" line

let check ws | ws `elem` copies = pad . dzenColor "red" "black" $ ws | otherwise = pad ws

I tried placing it inside main after the copies line but "check" is not in scope.

Knute wrote:

As I have no formal training in haskell this is my best guess.

I appreciate the quick responses. Thank you.

Offline

#6 2015-03-16 00:11:51

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

Re: [Solved] xmonad copywindow loghook

It spells it out on the page:

sampleLogHook h = do
    copies <- wsContainingCopies
    let check ws | ws `elem` copies = pad . xmobarColor "red" "black" $ ws
                 | otherwise = pad ws
    dynamicLogWithPP myPP {ppHidden = check, ppOutput = hPutStrLn h}

 main = do
    h <- spawnPipe "xmobar"
    xmonad defaultConfig { logHook = sampleLogHook h }

You will need to modify the above code to use both your sampleLogHook (that you are about to create) and your myDzenLogHook h.

So you would change the defaultConfig line to read something like:

xmonad defaultConfig { logHook = sampleLogHook h <+> myDzenLogHook h}

I'm not sure if that's right or not, but you need to join them so that both will work with your logHook.  It's either the <+> or the $.  Haskell has so many different ways to join things I can't keep them all straight without looking it up. smile

HTH


Knute

Offline

#7 2015-03-16 00:51:42

davama
Member
From: NY
Registered: 2014-02-07
Posts: 45

Re: [Solved] xmonad copywindow loghook

Knute wrote:

It spells it out on the page:

You will need to modify the above code to use both your sampleLogHook (that you are about to create) and your myDzenLogHook h.

So you would change the defaultConfig line to read something like:

xmonad defaultConfig { logHook = sampleLogHook h <+> myDzenLogHook h}

I'm not sure if that's right or not, but you need to join them so that both will work with your logHook.  It's either the <+> or the $.  Haskell has so many different ways to join things I can't keep them all straight without looking it up. smile

HTH

you sir, are a GENIUS!!

So that work but i didn't like the fact of having two separate loghooks. So i move into the new one. Here is the code:

myDzenStatus = myDzenbar1
myDzenLogHook h = do
    copies <- wsContainingCopies
    let check ws | ws `elem` copies = pad . dzenColor (colorLook Yellow 0) "" $ ws
                 | otherwise = pad ws
    dynamicLogWithPP dzenPP { 
	ppOutput = hPutStrLn h
   	, ppTitle   		= dzenColor (colorLook Green 0) "" . wrap "^ca(2,xdotool key super+shift+c)" "^ca()" . shorten 50
    	, ppCurrent		= dzenColor (colorLook Green 1) "" . wrap "[" "]" . wrap "^ca(2,xdotool key alt+shift+c)" "^ca()"
	, ppVisible		= dzenColor (colorLook White 0) "" . wrap "(" ")"
	, ppHidden		= dzenColor (colorLook White 1) "" . wrap "" "" . check . noScratch
	, ppHiddenNoWindows	= noScratchPad
    	, ppUrgent		= dzenColor (colorLook Black 0) (colorLook Red 0) . wrap ">" "<" . dzenStrip
	, ppLayout	  	= dzenColor (colorLook Orange 0) "" . wrap "^ca(1,xdotool key super+space)^ca(3,xdotool key super+shift+space)" "^ca()^ca()"
    	, ppSep			= " : "
    	, ppWsSep		= " "
    }
	where
		noScratch ws = if ws == "NSP" then "" else ws
		noScratchPad ws = if ws == "NSP" then "" else ""

My Main stayed the same:

main = do
 xmproc <- spawnPipe myDzenStatus	-- Dzenbar
	, logHook = myDzenLogHook xmproc

Thanks Knute for your input.

Marking as Solved

Offline

#8 2015-03-16 01:20:59

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

Re: [Solved] xmonad copywindow loghook

You are most welcome.
And just so that you know, I suggested 2 hooks so that you could keep them separate.  It's also why haskell has so many ways of linking things.  smile

Anyway, I'm glad you got it fixed.


Knute

Offline

Board footer

Powered by FluxBB