You are not logged in.

#426 2010-11-12 16:29:36

lifeafter2am
Member
From: 127.0.0.1
Registered: 2009-06-10
Posts: 1,332

Re: xmonad Hacking Thread

So after giving Awesome a try, I am back to XMonad.  Feels like I have come home. lol.

Anyway, I was looking into trying to get XMonad to work with dynamic workspaces.  Has anyone got this working, I have found two modules that look like something I would want to try (DynamicWorkspaces and something on the mailing list called X.A.WorkspaceNames) but didn't know how exactly they worked.


#binarii @ irc.binarii.net
Matrix Server: https://matrix.binarii.net
-------------
Allan -> ArchBang is not supported because it is stupid.

Offline

#427 2010-12-20 10:01:06

hellomynameisphil
Member
From: /home/phil/Vancouver
Registered: 2009-10-02
Posts: 257
Website

Re: xmonad Hacking Thread

hi all,

I have a dzen2 statusbar that I toggle on and off with mod-b. But whenever I toggle it on or off, I have to do a mod-n (i.e., refresh) to get the windows to adjust themselves correctly in relation to the status bar. Is there a way to have the mod-b binding not only toggle the status bar on or off, but also automatically do a refresh as well? Currently my keybinding looks like this:

 ((myModMask,                 xK_b),  spawn myStatusBar)

What I think I want is:

 ((myModMask,                 xK_b),  spawn myStatusBar and then refresh)

How would I write that in Haskell?

Offline

#428 2010-12-20 10:49:26

lymphatik
Member
From: Somewhere else
Registered: 2009-03-07
Posts: 119

Re: xmonad Hacking Thread

hellomynameisphil wrote:

hi all,

I have a dzen2 statusbar that I toggle on and off with mod-b. But whenever I toggle it on or off, I have to do a mod-n (i.e., refresh) to get the windows to adjust themselves correctly in relation to the status bar. Is there a way to have the mod-b binding not only toggle the status bar on or off, but also automatically do a refresh as well? Currently my keybinding looks like this:

 ((myModMask,                 xK_b),  spawn myStatusBar)

What I think I want is:

 ((myModMask,                 xK_b),  spawn myStatusBar and then refresh)

How would I write that in Haskell?

You might want to use togglestrut

, ((modMask, xK_b )                    , sendMessage ToggleStruts)

cf. for more information http://xmonad.org/xmonad-docs/xmonad-co … Docks.html

Offline

#429 2010-12-20 14:43:34

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

Re: xmonad Hacking Thread

Yes, use ToggleStruts. 

It's funny, '>>' is basically "and then" in a haskell Monad (the X() part of a keybind):

..., spawn myStatusBar >> refresh)

would probably work here (though it's not a "toggle", just an "on").

Offline

#430 2010-12-20 20:13:55

hellomynameisphil
Member
From: /home/phil/Vancouver
Registered: 2009-10-02
Posts: 257
Website

Re: xmonad Hacking Thread

My status bar looks like this:

1) bash script

#!/bin/sh

if [ -z $(pgrep conky) ] ; then
    conky -c $HOME/.conky/xmonad | dzen2 ${1+"$@"}
else
    killall conky
fi

2) in xmonad.hs

myStatusBar         = "xmonad-status -bg '#000000' -fn '" ++ myFontName ++ "' -y 587 -h 13"

There are 2 reasons for this toggling behaviour: 1) to save screen space when I don't need to see the status bar; 2) to save resources by not running a status bar when I don't need to look at it.

I've tried both 'spawn myStatusBar >> refresh'  and 'spawn myStatusBar >> sendMessage ToggleStruts'. Mostly what happens is that the status bar toggles on, but no gap appears. But then the gap appears when the bar is toggled off. I wonder if the 'refresh' or whatever is running before the bar has started when the bar is toggled on, and before the bar has been killed when the bar is toggled off. I googled 'sleep' functions for Haskell, thinking that I might need something like 'spawn myStatusBar >> sleep 0.5 >> refresh', but my lack of Haskell background hasn't helped me get very far with this. Could I be on the right track? Could there be another explanation?

Offline

#431 2010-12-20 20:28:29

hellomynameisphil
Member
From: /home/phil/Vancouver
Registered: 2009-10-02
Posts: 257
Website

Re: xmonad Hacking Thread

BTW, my current xmonad.hs, for reference: http://pastebin.com/ad3iQNx7

Still very much a work in progress. Messy in some places, incomplete in others, just plain wrong in still others, but still something I'm pretty happy with.

Offline

#432 2010-12-22 21:07:32

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

Re: xmonad Hacking Thread

hellomynameisphil wrote:

Could I be on the right track? Could there be another explanation?

Another explanation could be - without having looked at your code - that you're using layoutmodifiers or other stuff that introduces the weirdness. I've had this a couple of times in the past two years. Things working as expected until I changed something. You could try implementing what you're trying with a clean config and see if it works there. mod+b should work out of the box.

Edit: and if you're in for a dirty hack, you could always use xdotool to mimick an additional mod+n after a mod+b.

But meh...

Last edited by count-corrupt (2010-12-22 21:09:01)

Offline

#433 2011-01-03 18:32:07

stev3
Member
Registered: 2010-09-14
Posts: 13

Re: xmonad Hacking Thread

Would anyone know how to hide my status bar when I'm using virtualbox? or a way I can hide it for just one desktop?

Here are my configs:

Config { font = "Terminal"
       , bgColor = "#0000FF"
       , fgColor = "#FFFFFF"
       , position = Static { xpos = 0 , ypos = 0, width = 1024, height = 14 },
       , commands = [ 
       Run Network "wlan0" ["-L","0","-H","32","--normal","green","--high","red"] 5
       , Run Weather "EGGP" [
       "-t","<station>- <tempC>C","-L","18","-H","25","--normal","green","--high","red","--low","lightblue"] 10
       , Run Cpu ["-t", "<total>", "-L","5","-H","80","--normal","green","--high","red"] 10
       , Run Memory ["-t","MEM: <used>MB"] 10
       , Run Date "%a %b %_d %H:%M" "date" 10
       , Run Battery ["-t","Battery: <left>"] 10
       ]
       , sepChar = "%"
       , alignSep = "}{"
       , template = " CPU: %cpu% | %memory% | %battery% }{ %EGGP% | %date% "

       }
import XMonad
import XMonad.Hooks.ManageDocks
import XMonad.Util.Run(spawnPipe)

main = do
    xmproc <- spawnPipe "xmobar /home/ev3/.xmobarrc"
    xmonad $ defaultConfig
        { terminal="urxvt"
        ,  borderWidth=0
        , manageHook           = manageHook defaultConfig <+> manageDocks
        , layoutHook= avoidStruts (layoutHook defaultConfig)
        }

Offline

#434 2011-01-16 20:14:46

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

Re: xmonad Hacking Thread

Hi,
I've just added to the wiki  a way to restart to another wm from within xmonad and back, keeping your stuff open. Check it out! Link. And give some feedback.

BTW, is adamvo from haskell.org, vogt?

Offline

#435 2011-01-17 04:30:29

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

Re: xmonad Hacking Thread

stev3 wrote:

Would anyone know how to hide my status bar when I'm using virtualbox? or a way I can hide it for just one desktop?

Here are my configs:

Config { font = "Terminal"
       , bgColor = "#0000FF"
       , fgColor = "#FFFFFF"
       , position = Static { xpos = 0 , ypos = 0, width = 1024, height = 14 },
       , commands = [ 
       Run Network "wlan0" ["-L","0","-H","32","--normal","green","--high","red"] 5
       , Run Weather "EGGP" [
       "-t","<station>- <tempC>C","-L","18","-H","25","--normal","green","--high","red","--low","lightblue"] 10
       , Run Cpu ["-t", "<total>", "-L","5","-H","80","--normal","green","--high","red"] 10
       , Run Memory ["-t","MEM: <used>MB"] 10
       , Run Date "%a %b %_d %H:%M" "date" 10
       , Run Battery ["-t","Battery: <left>"] 10
       ]
       , sepChar = "%"
       , alignSep = "}{"
       , template = " CPU: %cpu% | %memory% | %battery% }{ %EGGP% | %date% "

       }
import XMonad
import XMonad.Hooks.ManageDocks
import XMonad.Util.Run(spawnPipe)

main = do
    xmproc <- spawnPipe "xmobar /home/ev3/.xmobarrc"
    xmonad $ defaultConfig
        { terminal="urxvt"
        ,  borderWidth=0
        , manageHook           = manageHook defaultConfig <+> manageDocks
        , layoutHook= avoidStruts (layoutHook defaultConfig)
        }

Check out the class name with xprop, and add the following to your managehook:

[className =? "VirtualBox"             --> doFullFloat]

Offline

#436 2011-01-19 16:02:39

CBM80
Member
Registered: 2010-05-06
Posts: 6

Re: xmonad Hacking Thread

abijr wrote:

Check out the class name with xprop, and add the following to your managehook:

[className =? "VirtualBox"             --> doFullFloat]

Another way to find out about resource & className is to run

wmctrl -lx

Offline

#437 2011-03-17 19:11:33

cbrunos
Member
Registered: 2010-07-22
Posts: 55

Re: xmonad Hacking Thread

Hello everyone I was wondering if there is a way to have tabs for the master area. I looked into XMonad.Layout.Tabbed and XMonad.Layout.TabBarDecoration but using that I get tabs for all my open windows. What I want is to use my traditional layouts, plus having the option to use tabs for the windows in the master area. Does anyone know how to do this?

Last edited by cbrunos (2011-03-17 21:18:33)


Xmonad gets sh*t done. Fast.

Offline

#438 2011-03-18 10:28:10

Kazuki
Member
From: Germany
Registered: 2009-05-12
Posts: 15

Re: xmonad Hacking Thread

XMonad.Layout.Combo should do what you want.

Offline

#439 2011-03-18 14:09:51

doom_phd
Member
From: US
Registered: 2009-08-11
Posts: 25

Re: xmonad Hacking Thread

I am having trouble with toggleOrDoSkip from XMonad.Actions.CycleWS. I would like to set up a keybinding in which I get the same behavior as toggleWS but certain workspaces are skipped, such as the scratchpad. Has anyone set anything like this up before? I haven't found any config similar to what I want through google. Thanks.


Don't you worry about blank. Let me worry about blank
I did do the nasty in the past-y.
Pizza delivery for... I. C. Weiner. Aww... I always thought by this stage in my life I'd be the one making the crank calls.

Offline

#440 2011-03-19 12:25:44

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

Re: xmonad Hacking Thread

doom_phd wrote:

I am having trouble with toggleOrDoSkip from XMonad.Actions.CycleWS. I would like to set up a keybinding in which I get the same behavior as toggleWS but certain workspaces are skipped, such as the scratchpad. Has anyone set anything like this up before? I haven't found any config similar to what I want through google. Thanks.

toggleOrDoSkip' :: [WorkspaceId] -> (WorkspaceId -> WindowSet -> WindowSet) -> X ()
toggleOrDoSkip' skips f = do
    ws <- gets windowset
    let hs' = W.hidden ws `skipTags` skips
    if (W.tag $ head hs')  == (W.tag . W.workspace $ W.current ws) 
        then unless (null hs') (windows . f . W.tag $ head hs')
        else windows (f $ W.tag $ head hs')

I tried what you asked for and also couldn't get it to work. Mainly because toggeOrDoSkip expects a workspaceId to switch to. And even doing

findWorkspace getSortByIndex Next AnyWS 1 >>= toggleOrDoSkip ["NSP"] W.greedyView

didn't behave as expected. It does work but won't skip workspaces. ToggleOrDoSkip' does exactly that. It toggles between the current and the last workspace unless that workspace' id is contained in skips. You can use it like this

...arbitrary key config...
    , ((myModMask , xK_numbersign), toggleOrDoSkip' ["NSP"] W.greedyView )
...arbitrary key config...

I've let it up to you to favor view over greedyView. If you don't like that, just remove all occurences of 'f' in the function and replace it with either.

Last edited by count-corrupt (2011-03-19 12:27:09)

Offline

#441 2011-03-19 18:16:26

doom_phd
Member
From: US
Registered: 2009-08-11
Posts: 25

Re: xmonad Hacking Thread

count-corrupt you are amazing. Thanks a ton. This is exactly what I wanted.


Don't you worry about blank. Let me worry about blank
I did do the nasty in the past-y.
Pizza delivery for... I. C. Weiner. Aww... I always thought by this stage in my life I'd be the one making the crank calls.

Offline

#442 2011-04-09 20:54:37

Hohoho
Member
Registered: 2007-06-23
Posts: 222

Re: xmonad Hacking Thread

Saw this thread https://bbs.archlinux.org/viewtopic.php?id=80124
And one problem with the floating layer bugged me too, with focusFollowsMouse disabled the only way to bring a floating window on top of another one was to Mod+click it. Well and it's a little more natural to simply click it, so I wrote this event hook hack:

-- don't forget to import XMonad.Actions.Promote
-- Description: bring clicked floating window to the front
-- add this function to your handleEventHook
floatClickFocusHandler :: Event -> X All
floatClickFocusHandler ButtonEvent { ev_window = w } = do
    withWindowSet $ \s -> do
        if isFloat w s
           then (focus w >> promote)
           else return ()
        return (All True)
        where isFloat w ss = M.member w $ W.floating ss
floatClickFocusHandler _ = return (All True)

Perhaps someone will find it useful.
If I invented a bicycle, please do tell me big_smile

Offline

#443 2011-04-10 04:08:50

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

Re: xmonad Hacking Thread

Hohoho wrote:

Saw this thread https://bbs.archlinux.org/viewtopic.php?id=80124
And one problem with the floating layer bugged me too, with focusFollowsMouse disabled the only way to bring a floating window on top of another one was to Mod+click it. Well and it's a little more natural to simply click it, so I wrote this event hook hack:

-- don't forget to import XMonad.Actions.Promote
-- Description: bring clicked floating window to the front
-- add this function to your handleEventHook
floatClickFocusHandler :: Event -> X All
floatClickFocusHandler ButtonEvent { ev_window = w } = do
    withWindowSet $ \s -> do
        if isFloat w s
           then (focus w >> promote)
           else return ()
        return (All True)
        where isFloat w ss = M.member w $ W.floating ss
floatClickFocusHandler _ = return (All True)

Perhaps someone will find it useful.
If I invented a bicycle, please do tell me big_smile

Would you mind posting your xmonad.hs file? I've never explicitely extended the handleEventHook, so I'd like to see what you did here.

Offline

#444 2011-04-10 04:58:32

swathe
Member
From: au
Registered: 2010-10-01
Posts: 147

Re: xmonad Hacking Thread

I am doing a fresh install of Arch in the next week or so and plan to dive into xmonad, this thread has given me quite a few ideas! smile

Offline

#445 2011-04-10 10:53:11

Hohoho
Member
Registered: 2007-06-23
Posts: 222

Re: xmonad Hacking Thread

@skottish, you can find it here https://gist.github.com/912242

Update: Damn, windows don't get brought to front if its already focused when you click on it.

Last edited by Hohoho (2011-04-10 12:56:05)

Offline

#446 2011-05-13 16:28:53

Jabrick
Member
Registered: 2011-05-13
Posts: 79

Re: xmonad Hacking Thread

Hello everybody I finally got an arch account on the forums smile and I have a favour to ask.
If its not too much trouble could someone analyze my code and tell me if there are any bugs (I'm still new, I'm sure I have a lot of useless imports)?
I'm pretty sure I used this exact same syntax to get my volume keys to work before, but then recently none of my shortcut keys were working so I can to recompile Xmonad with default configuration and redo my modification.

Anyways here is my ~/.xmonad/xmonad.hs file

-- ~/.xmonad/xmonad.hs
-- Imports {{{
import XMonad
-- Prompt
import XMonad.Prompt
import XMonad.Prompt.RunOrRaise (runOrRaisePrompt)
import XMonad.Prompt.AppendFile (appendFilePrompt)
-- Hooks
import XMonad.Operations

import System.IO
import System.Exit

import XMonad.Util.Run

import XMonad.Actions.CycleWS

import XMonad.Hooks.ManageDocks
import XMonad.Hooks.ManageHelpers
import XMonad.Hooks.SetWMName
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.UrgencyHook
import XMonad.Hooks.FadeInactive
import XMonad.Hooks.EwmhDesktops
import XMonad.Hooks.SetWMName

import XMonad.Layout.NoBorders (smartBorders, noBorders)
import XMonad.Layout.PerWorkspace (onWorkspace, onWorkspaces)
import XMonad.Layout.Reflect (reflectHoriz)
import XMonad.Layout.IM
import XMonad.Layout.SimpleFloat
import XMonad.Layout.Spacing
import XMonad.Layout.ResizableTile
import XMonad.Layout.NoBorders
-- import XMonad.Layout.Gaps
import XMonad.Layout.LayoutHints
import XMonad.Layout.LayoutModifier
import XMonad.Layout.Reflect
import XMonad.Layout.Grid

import Data.Ratio ((%))

import qualified XMonad.StackSet as W
import qualified Data.Map as M

--}}}

-- Config {{{
-- Define modMask
modMask' :: KeyMask
modMask' = mod1Mask
--}}}

-- Main {{{
main = do
    xmonad $ defaultConfig
        {keys                = keys'
        }
--}}}

-- Key mapping {{{
keys' :: XConfig Layout -> M.Map (KeyMask, KeySym) (X ())
keys' conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
    [((0,                          0x1008ff12  ), spawn "amixer -q sset Master toggle") -- XF86AudioMute
    , ((0,                          0x1008ff11  ), spawn "amixer -q sset Master 655- unmute") -- XF86AudioLowerVolume
    , ((0,                          0x1008ff13  ), spawn "amixer -q sset Master 655+ unmute") -- XF86AudioRaiseVolume
    ]
--}}}

When I recompile Xmonad I get no errors, but my designated volume keys are still not responding. I have ASLA installed.
Any help is greatly appreciated!

EDIT: Rebooting with this configuration stops XMonad from responding, making me have to go back to default configuration.


EDIT2:Also in trying to get volume keys to work this is my
~/.Xmodmap

keycode 123 = XF86AudioRaiseVolume
keycode 122 = XF86AudioLowerVolume

And this is my
~/.xinitrc

#!/bin/sh
#
# ~/.xinitrc
#
# Executed by startx (run your window manager from here)

if [ -d /etc/X11/xinit/xinitrc.d ]; then
  for f in /etc/X11/xinit/xinitrc.d/*; do
    [ -x "$f" ] && . "$f"
  done
  unset f
fi


if [ -f $HOME/.Xmodmap ]; then
    /usr/bin/xmodmap $HOME/.Xmodmap
fi
# exec gnome-session
# exec startkde
# exec startxfce4
# ...or the Window Manager of your choice
exec xmonad

Still no luck sad

Last edited by Jabrick (2011-05-13 17:05:15)

Offline

#447 2011-05-13 20:13:52

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

Re: xmonad Hacking Thread

Jabrick wrote:

Hello everybody I finally got an arch account on the forums smile and I have a favour to ask.
If its not too much trouble could someone analyze my code and tell me if there are any bugs (I'm still new, I'm sure I have a lot of useless imports)?

See the bottom of this post with respect to mapping the keys to XF86 functions.  That may be the issue; everything else looks fine to me.

As for the imports, you should be able to remove all of them except for import XMonad and maybe import System.IO (not sure if IO is needed for the main = do bit.


thayer williams ~ cinderwick.ca

Offline

#448 2011-05-14 15:06:25

Jabrick
Member
Registered: 2011-05-13
Posts: 79

Re: xmonad Hacking Thread

Hey so this was my new configuration

import XMonad
import System.IO
import qualified Data.Map as M

modMask' :: KeyMask
modMask' = mod1Mask

main = do
    xmonad $ defaultConfig
        {keys                = keys'
        }

keys' :: XConfig Layout -> M.Map (KeyMask, KeySym) (X ())
keys' conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
     [((1 , 0x1008ff12), spawn "amixer -q set PCM toggle")        --XF86AudioToggleVolume
        , ((0 , 0x1008ff11), spawn "amixer -q set PCM 1- unmute") --XF86AudioLowerVolume
        , ((3 , 0x1008ff13), spawn "amixer -q set PCM 1+ unmute") --XF86AudioRaiseVolume
     ]

And as suggested I cleared out my ~/.Xmodmap file, and also restored my ~/.xinitrc file back to normal.
After i recompiled none of my shortcut keys works after rebooting my machine, or after shutting it down. But before rebooting or shutting down Xmonad responded as normal except the volume keys still did not respond. Note that after reboot if I log in as root Xmonad works as its defaults.

Why is this happening? Could I have screwed something up in my default configuration? I tried looking for my default file in my etc directory but there is nothing with the name xmonad in there.

Its been about two days now, if anyone has any further advice I will be very happy! smile
Thank you thayer for the support.

Offline

#449 2011-05-14 16:07:42

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,092

Re: xmonad Hacking Thread

Jabrick wrote:
main = do
    xmonad $ defaultConfig
        {keys                = keys'
        }

keys' :: XConfig Layout -> M.Map (KeyMask, KeySym) (X ())
keys' conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
     [((1 , 0x1008ff12), spawn "amixer -q set PCM toggle")        --XF86AudioToggleVolume
        , ((0 , 0x1008ff11), spawn "amixer -q set PCM 1- unmute") --XF86AudioLowerVolume
        , ((3 , 0x1008ff13), spawn "amixer -q set PCM 1+ unmute") --XF86AudioRaiseVolume
     ]

That overrides _all_ the default keybindings and only gives you bindings to change the volume.

I would suggest using additionalKeysP instead

See the list of multimedia keys on the same page.


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#450 2011-05-14 17:07:57

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

Re: xmonad Hacking Thread

Good catch, Mr. Elendig!  Clearly my haskell skills are lacking.  If you'd like to more or less keep what you have (avoiding the additionalKeysP extension), you can change your keys' section to look like this:

keys' x = M.union (keys defaultConfig x) (M.fromList (keys' x))
keys' conf@(XConfig {XMonad.modMask = modm}) =
    [ ((1 , 0x1008ff12), spawn "amixer -q set PCM toggle"   ) --XF86AudioToggleVolume
    , ((0 , 0x1008ff11), spawn "amixer -q set PCM 1- unmute") --XF86AudioLowerVolume
    , ((3 , 0x1008ff13), spawn "amixer -q set PCM 1+ unmute") --XF86AudioRaiseVolume
    ]

source: XMonad.Doc.Extending

Finally, I'm not sure what the intent is for the varying numbers in front of the keycodes ((1 , 0x1008ff12), (3 , 0x1008ff13)).  All of the configs I've seen in the past simply use a 0 to specify no mod key: (0 , 0x1008ff11), (0 , 0x1008ff12), (0 , 0x1008ff13), etc.

Last edited by thayer (2011-05-14 17:11:14)


thayer williams ~ cinderwick.ca

Offline

Board footer

Powered by FluxBB