You are not logged in.

#201 2009-09-09 14:59:08

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

Re: xmonad Hacking Thread

@myrkiada
Thanks, I'll use dzenDontStripMyIcons too. smile


(lambda ())

Offline

#202 2009-09-09 21:05:42

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

Re: xmonad Hacking Thread

Please do. wink


My Configs @ Github

Offline

#203 2009-09-09 23:40:08

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

Re: xmonad Hacking Thread

brisbin33 wrote:
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.

The layoutHook code you gave me worked great (thanks!). However, when I mod-qed after adding the new logHook, I got the error "Not in scope: h". I assume its relativly easy to fix. Do I just have to define h somewhere?


Arch x86_64 | XMonad

Offline

#204 2009-09-10 00:08:47

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

Re: xmonad Hacking Thread

Try changing this line in your Main:

logHook = logHook' xmobar

to

logHook = logHook' h

My Configs @ Github

Offline

#205 2009-09-10 01:10:41

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

Re: xmonad Hacking Thread

myrkiada wrote:

Try changing this line in your Main:

logHook = logHook' xmobar

to

logHook = logHook' h

Thats returns a third "not in scope: h" error. Any other ideas?


Arch x86_64 | XMonad

Offline

#206 2009-09-10 04:07:58

pointone
Wiki Admin
From: Waterloo, ON
Registered: 2008-02-21
Posts: 379

Re: xmonad Hacking Thread

Post your xmonad.hs -- likely you made a simple typo somewhere.

'h' is simply a parameter to the logHook' function in the above code.


M*cr*s*ft: Who needs quality when you have marketing?

Offline

#207 2009-09-10 04:11:12

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

Re: xmonad Hacking Thread

--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 = logHook' h
        , 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 $ tiled ||| Mirror tiled ||| Full ||| named "Borderless Full" (noBorders Full) ||| spiral (6/7) ||| simpleTabbed
  where
    tiled = Tall nmaster delta ratio
    nmaster = 1
    ratio   = toRational (2/(1+sqrt(5)::Double))
    delta   = 0.03

logHook' = h dynamicLogWithPP $ xmobarPP
  { ppOutput = hPutStrLn h }

Arch x86_64 | XMonad

Offline

#208 2009-09-10 14:19:35

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

Re: xmonad Hacking Thread

i don't know much haskell, by i think i can explain this situation:

in main, your loghook outputs to some variable (a handle).  that variable gets it's value from spawnPipe (that's how it gets from ppOutput all the way to xmobar).  so whether the variable's called xmobar, h, d, or yabadadoo it just has to be consistent between the <- spawnPipe and logHook' lines.

i.e.

main = do
  d <- spawnPipe "xmobar"
  xmonad $ defaultConfig
    { ...
    , ...
    , logHook = logHook' d
    }

the same thing's going on in the logHook' function.  hPutStrLn outputs to something; and that something is a parameter to the logHook' function.  it can be h, d, xmobar,  whatever it just has to be consistent.  it can even be the same variable used in main if you want, it's a different function, so you can reuse it (people usually don't though...).

you're basically connecting "hPutStrLn" all the way up to "spawnPipe "xmobar"".

logHook' h = dynamicLogWithPP $ xmobarPP
  { ppOutput = hPutStrLn h }

note what side of the ='s the h is on smile

/edited for clarity.

Last edited by brisbin33 (2009-09-10 14:40:51)

Offline

#209 2009-09-11 03:17:02

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

Re: xmonad Hacking Thread

Woot! It works great now, thanks for all the help. I had to change a couple h's into xmobar.


Arch x86_64 | XMonad

Offline

#210 2009-09-18 02:57:33

YamiFrankc
Member
From: Mexico
Registered: 2009-06-19
Posts: 177
Website

Re: xmonad Hacking Thread

Been using  Xmonad since yesterday night and im very happy with it.
Even if i havent configured(well,just the mod key.Irssi is the only owner of Alt) it.

My first problem...ive been trying to ad keybindings to volume up volume doun and so. Also for ncmpcpp.

But i get an error wich talks about like 154 column 1.

, ((XF86AudioRaiseVolume), spawn "ossvol -t")

Is it. If i take out the character of the first column then i get an error with XF86AudoRaiseVolume.
What im doing wrong?


Thanks and greetings.

Offline

#211 2009-09-18 03:12:15

droog
Member
Registered: 2004-11-18
Posts: 877

Re: xmonad Hacking Thread

YamiFrankc wrote:
, ((XF86AudioRaiseVolume), spawn "ossvol -t")

Is it. If i take out the character of the first column then i get an error with XF86AudoRaiseVolume.
What im doing wrong?

I never tried it that way, I just used xev to get the keysyms. heres the relevant part of my config.

  
    , ((0,          0x1008ff11), spawn "ossv.sh pcm -2")
    , ((0,          0x1008ff12), spawn "ossmix pcm 0:0")
    , ((0,          0x1008ff13), spawn "ossv.sh pcm +2")
    , ((0,         0x1008ff14), spawn "mpc --no-status toggle")
    , ((0,         0x1008ff16), spawn "mpc --no-status prev")
    , ((0,         0x1008ff17), spawn "mpc --no-status next")

I think those are pretty standard keys on multimedia keyboards so might work for you.
if not you can use xev to get the right ones.

Offline

#212 2009-09-18 03:35:29

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

Re: xmonad Hacking Thread

YamiFrankc wrote:

Been using  Xmonad since yesterday night and im very happy with it.
Even if i havent configured(well,just the mod key.Irssi is the only owner of Alt) it.

My first problem...ive been trying to ad keybindings to volume up volume doun and so. Also for ncmpcpp.

But i get an error wich talks about like 154 column 1.

, ((XF86AudioRaiseVolume), spawn "ossvol -t")

Is it. If i take out the character of the first column then i get an error with t.
What im doing wrong?

The XF86 keysyms are defined in this module, which is easier to use than running cpp over your config, or manually copying out the actual values of the keysyms: http://hackage.haskell.org/packages/arc … -XF86.html

If you want to use no modmask, the key entry should look like:

 , ((0,xF86XK_AudioRaiseVolume), spawn "ossvol -t")

Offline

#213 2009-09-18 13:24:42

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

Re: xmonad Hacking Thread

another option could be X.U.EZConfig from contrib:

import XMonad.Util.EZConfig (additionalKeysP)

main = do
  d <- spawnPipe myLeftBar
  xmonad $ defaultConfig
    { terminal           = myTerminal
    , workspaces         = myWorkspaces
    , borderWidth        = myBorderWidth
    , normalBorderColor  = myNormalBorderColor
    , focusedBorderColor = myFocusedBorderColor
    , layoutHook         = myLayout
    , manageHook         = myManageHook
    , logHook            = myLogHook d
    } `additionalKeysP` myKeys

myKeys = [ ("M-S-u"                 , spawn myBrowser          ) -- open web client
         , ("M-S-m"                 , spawn myMail             ) -- open mail client
         , ("M-S-i"                 , spawn myIRC              ) -- open IRC client
         , ("M-S-p"                 , spawn myLauncher         ) -- open gmrun replacement
        
         -- Multimedia
         , ("<XF86AudioPlay>"       , spawn "mpc toggle"       ) -- play/pause mpd
         , ("<XF86AudioStop>"       , spawn "mpc stop"         ) -- stop mpd
         , ("<XF86AudioPrev>"       , spawn "mpc prev"         ) -- prev song
         , ("<XF86AudioNext>"       , spawn "mpc next"         ) -- next song
         , ("<XF86AudioMute>"       , spawn "ossvol -t"        ) -- toggle mute via custom script
         , ("<XF86AudioLowerVolume>", spawn "ossvol -d 1"      ) -- volume down via custom script
         , ("<XF86AudioRaiseVolume>", spawn "ossvol -i 1"      ) -- volume up via custom script
         ]         

         where

           myBrowser  = "uzbl"
           myLauncher = "bashrun"
           myMail     = myTerminal ++ " -e mutt"
           myIRC      = myTerminal ++ " -e irssi"

Note: you only need `additionalKeysP` myKeys, then define myKeys as what you want... i tried to give you some more context from my config b/c i find that makes it easier to merge things into your own.

Offline

#214 2009-09-18 17:43:03

YamiFrankc
Member
From: Mexico
Registered: 2009-06-19
Posts: 177
Website

Re: xmonad Hacking Thread

Ive used booth you told me,but it always complains about the comma(,) at the start of the lines. "Parse error on input `,' "


Thanks and greetings.

Offline

#215 2009-09-18 18:20:25

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

Re: xmonad Hacking Thread

better post your xmonad.hs, i'm sure it's an indentation issue.

Offline

#216 2009-09-19 04:19:22

YamiFrankc
Member
From: Mexico
Registered: 2009-06-19
Posts: 177
Website

Re: xmonad Hacking Thread

--
-- xmonad example config file.
--
-- A template showing all available configuration hooks,
-- and how to override the defaults in your own xmonad.hs conf file.
--
-- Normally, you'd only override those defaults you care about.
--
 
import XMonad
import System.Exit
 
import qualified XMonad.StackSet as W
import qualified Data.Map        as M
 
--Next one is for the cause! My cause is custom keys,you know...
import XMonad.Util.EZConfig

-- The preferred terminal program, which is used in a binding below and by
-- certain contrib modules.
--
myTerminal      = "urxvt"
 
-- Width of the window border in pixels.
--
myBorderWidth   = 1
 
-- modMask lets you specify which modkey you want to use. The default
-- is mod1Mask ("left alt").  You may also consider using mod3Mask
-- ("right alt"), which does not conflict with emacs keybindings. The
-- "windows key" is usually mod4Mask.
--
myModMask       = mod4Mask
 
-- The mask for the numlock key. Numlock status is "masked" from the
-- current modifier status, so the keybindings will work with numlock on or
-- off. You may need to change this on some systems.
--
-- You can find the numlock modifier by running "xmodmap" and looking for a
-- modifier with Num_Lock bound to it:
--
-- > $ xmodmap | grep Num
-- > mod2        Num_Lock (0x4d)
--
-- Set numlockMask = 0 if you don't have a numlock key, or want to treat
-- numlock status separately.
--
myNumlockMask   = mod2Mask
 
-- The default number of workspaces (virtual screens) and their names.
-- By default we use numeric strings, but any string may be used as a
-- workspace name. The number of workspaces is determined by the length
-- of this list.
--
-- A tagging example:
--
-- > workspaces = ["web", "irc", "code" ] ++ map show [4..9]
--
myWorkspaces    = ["1","2","3","4","5","6","7","8","9"]
 
-- Border colors for unfocused and focused windows, respectively.
--
myNormalBorderColor  = "#dddddd"
myFocusedBorderColor = "#ff0000"
 
------------------------------------------------------------------------
-- Key bindings. Add, modify or remove key bindings here.
--
myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
 
    -- launch a terminal
    [ ((modm .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf)
 
    -- launch dmenu
    , ((modm,               xK_p     ), spawn "exe=`dmenu_path | dmenu` && eval \"exec $exe\"")
 
    -- launch gmrun
    , ((modm .|. shiftMask, xK_p     ), spawn "gmrun")
 
    -- close focused window 
    , ((modm .|. shiftMask, xK_c     ), kill)
 
     -- Rotate through the available layout algorithms
    , ((modm,               xK_space ), sendMessage NextLayout)
 
    --  Reset the layouts on the current workspace to default
    , ((modm .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf)
 
    -- Resize viewed windows to the correct size
    , ((modm,               xK_n     ), refresh)
 
    -- Move focus to the next window
    , ((modm,               xK_Tab   ), windows W.focusDown)
 
    -- Move focus to the next window
    , ((modm,               xK_j     ), windows W.focusDown)
 
    -- Move focus to the previous window
    , ((modm,               xK_k     ), windows W.focusUp  )
 
    -- Move focus to the master window
    , ((modm,               xK_m     ), windows W.focusMaster  )
 
    -- Swap the focused window and the master window
    , ((modm,               xK_Return), windows W.swapMaster)
 
    -- Swap the focused window with the next window
    , ((modm .|. shiftMask, xK_j     ), windows W.swapDown  )
 
    -- Swap the focused window with the previous window
    , ((modm .|. shiftMask, xK_k     ), windows W.swapUp    )
 
    -- Shrink the master area
    , ((modm,               xK_h     ), sendMessage Shrink)
 
    -- Expand the master area
    , ((modm,               xK_l     ), sendMessage Expand)
 
    -- Push window back into tiling
    , ((modm,               xK_t     ), withFocused $ windows . W.sink)
 
    -- Increment the number of windows in the master area
    , ((modm              , xK_comma ), sendMessage (IncMasterN 1))
 
    -- Deincrement the number of windows in the master area
    , ((modm              , xK_period), sendMessage (IncMasterN (-1)))
 
    -- toggle the status bar gap (used with avoidStruts from Hooks.ManageDocks)
    -- , ((modm , xK_b ), sendMessage ToggleStruts)
 
    -- Quit xmonad
    , ((modm .|. shiftMask, xK_q     ), io (exitWith ExitSuccess))
 
    -- Restart xmonad
    , ((modm              , xK_q     ), restart "xmonad" True)
    ]
    ++
 
    --
    -- mod-[1..9], Switch to workspace N
    -- mod-shift-[1..9], Move client to workspace N
    --
    [((m .|. modm, 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}, Switch to physical/Xinerama screens 1, 2, or 3
    -- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3
    --
    [((m .|. modm, 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)]]
   
    --NOW MY KEYBINDINGS >:D 

-- Multimedia
        ,  ("<XF86AudioPlay>"       , spawn "mpc toggle"       ) -- play/pause mpd
        ,  ("<XF86AudioStop>"       , spawn "mpc stop"         ) -- stop mpd
        ,  ("<XF86AudioPrev>"       , spawn "mpc prev"         ) -- prev song
        ,  ("<XF86AudioNext>"       , spawn "mpc next"         ) -- next song
        ,  ("<XF86AudioMute>"       , spawn "ossvol -t"        ) -- toggle mute via custom 
        ,  ("<XF86AudioLowerVolume>", spawn "ossvol -d 1"      ) -- volume dow~custom 
        ,   ("<XF86AudioRaiseVolume>", spawn "ossvol -i 1"      ) -- volume up via cust~

        

------------------------------------------------------------------------
-- Mouse bindings: default actions bound to mouse events
--
myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $
 
    -- mod-button1, Set the window to floating mode and move by dragging
    [ ((modMask, button1), (\w -> focus w >> mouseMoveWindow w))
 
    -- mod-button2, Raise the window to the top of the stack
    , ((modMask, button2), (\w -> focus w >> windows W.swapMaster))
 
    -- mod-button3, Set the window to floating mode and resize by dragging
    , ((modMask, button3), (\w -> focus w >> mouseResizeWindow w))
 
    -- you may also bind events to the mouse scroll wheel (button4 and button5)
    ]
 
------------------------------------------------------------------------
-- Layouts:
 
-- You can specify and transform your layouts by modifying these values.
-- If you change layout bindings be sure to use 'mod-shift-space' after
-- restarting (with 'mod-q') to reset your layout state to the new
-- defaults, as xmonad preserves your old layout settings by default.
--
-- The available layouts.  Note that each layout is separated by |||,
-- which denotes layout choice.
--
myLayout = tiled ||| Mirror tiled ||| Full
  where
     -- default tiling algorithm partitions the screen into two panes
     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   = 1/2
 
     -- Percent of screen to increment by when resizing panes
     delta   = 3/100
 
------------------------------------------------------------------------
-- Window rules:
 
-- Execute arbitrary actions and WindowSet manipulations when managing
-- a new window. You can use this to, for example, always float a
-- particular program, or have a client always appear on a particular
-- workspace.
--
-- To find the property name associated with a program, use
-- > xprop | grep WM_CLASS
-- and click on the client you're interested in.
--
-- To match on the WM_NAME, you can use 'title' in the same way that
-- 'className' and 'resource' are used below.
--
myManageHook = composeAll
    [ className =? "MPlayer"        --> doFloat
    , className =? "Gimp"           --> doFloat
    , resource  =? "desktop_window" --> doIgnore
    , resource  =? "kdesktop"       --> doIgnore ]
 
-- Whether focus follows the mouse pointer.
myFocusFollowsMouse :: Bool
myFocusFollowsMouse = True
 
 
------------------------------------------------------------------------
-- Status bars and logging
 
-- Perform an arbitrary action on each internal state change or X event.
-- See the 'DynamicLog' extension for examples.
--
-- To emulate dwm's status bar
--
-- > logHook = dynamicLogDzen
--
myLogHook = return ()
 
------------------------------------------------------------------------
-- Startup hook
 
-- Perform an arbitrary action each time xmonad starts or is restarted
-- with mod-q.  Used by, e.g., XMonad.Layout.PerWorkspace to initialize
-- per-workspace layout choices.
--
-- By default, do nothing.
myStartupHook = return ()
 
------------------------------------------------------------------------
-- Now run xmonad with all the defaults we set up.
 
-- Run xmonad with the settings you specify. No need to modify this.
--
main = xmonad defaults
 
-- A structure containing your configuration settings, overriding
-- fields in the default config. Any you don't override, will 
-- use the defaults defined in xmonad/XMonad/Config.hs
-- 
-- No need to modify this.
--
defaults = defaultConfig {
      -- simple stuff
        terminal           = myTerminal,
        focusFollowsMouse  = myFocusFollowsMouse,
        borderWidth        = myBorderWidth,
        modMask            = myModMask,
        numlockMask        = myNumlockMask,
        workspaces         = myWorkspaces,
        normalBorderColor  = myNormalBorderColor,
        focusedBorderColor = myFocusedBorderColor,
 
      -- key bindings
        keys               = myKeys,
        mouseBindings      = myMouseBindings,
 
      -- hooks, layouts
        layoutHook         = myLayout,
        manageHook         = myManageHook,
        logHook            = myLogHook,
        startupHook        = myStartupHook
    }

PS: Is there something like a dmenu config file? Been around the man but cant find the path or something.

Last edited by YamiFrankc (2009-09-20 01:30:23)


Thanks and greetings.

Offline

#217 2009-09-21 01:35:37

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

Re: xmonad Hacking Thread

Indentation is irrelevant here, since you aren't using the `do', `case' or `let' keywords.

You have to add the keybinds as the documentation for EZConfig suggests:

--
-- xmonad example config file.
--
-- A template showing all available configuration hooks,
-- and how to override the defaults in your own xmonad.hs conf file.
--
-- Normally, you'd only override those defaults you care about.
--
 
import XMonad
import System.Exit
 
import qualified XMonad.StackSet as W
import qualified Data.Map        as M
 
--Next one is for the cause! My cause is custom keys,you know...
import XMonad.Util.EZConfig

-- The preferred terminal program, which is used in a binding below and by
-- certain contrib modules.
--
myTerminal      = "urxvt"
 
-- Width of the window border in pixels.
--
myBorderWidth   = 1
 
-- modMask lets you specify which modkey you want to use. The default
-- is mod1Mask ("left alt").  You may also consider using mod3Mask
-- ("right alt"), which does not conflict with emacs keybindings. The
-- "windows key" is usually mod4Mask.
--
myModMask       = mod4Mask
 
-- The mask for the numlock key. Numlock status is "masked" from the
-- current modifier status, so the keybindings will work with numlock on or
-- off. You may need to change this on some systems.
--
-- You can find the numlock modifier by running "xmodmap" and looking for a
-- modifier with Num_Lock bound to it:
--
-- > $ xmodmap | grep Num
-- > mod2        Num_Lock (0x4d)
--
-- Set numlockMask = 0 if you don't have a numlock key, or want to treat
-- numlock status separately.
--
myNumlockMask   = mod2Mask
 
-- The default number of workspaces (virtual screens) and their names.
-- By default we use numeric strings, but any string may be used as a
-- workspace name. The number of workspaces is determined by the length
-- of this list.
--
-- A tagging example:
--
-- > workspaces = ["web", "irc", "code" ] ++ map show [4..9]
--
myWorkspaces    = ["1","2","3","4","5","6","7","8","9"]
 
-- Border colors for unfocused and focused windows, respectively.
--
myNormalBorderColor  = "#dddddd"
myFocusedBorderColor = "#ff0000"
 
------------------------------------------------------------------------
-- Key bindings. Add, modify or remove key bindings here.
--
myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
 
    -- launch a terminal
    [ ((modm .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf)
 
    -- launch dmenu
    , ((modm,               xK_p     ), spawn "exe=`dmenu_path | dmenu` && eval \"exec $exe\"")
 
    -- launch gmrun
    , ((modm .|. shiftMask, xK_p     ), spawn "gmrun")
 
    -- close focused window 
    , ((modm .|. shiftMask, xK_c     ), kill)
 
     -- Rotate through the available layout algorithms
    , ((modm,               xK_space ), sendMessage NextLayout)
 
    --  Reset the layouts on the current workspace to default
    , ((modm .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf)
 
    -- Resize viewed windows to the correct size
    , ((modm,               xK_n     ), refresh)
 
    -- Move focus to the next window
    , ((modm,               xK_Tab   ), windows W.focusDown)
 
    -- Move focus to the next window
    , ((modm,               xK_j     ), windows W.focusDown)
 
    -- Move focus to the previous window
    , ((modm,               xK_k     ), windows W.focusUp  )
 
    -- Move focus to the master window
    , ((modm,               xK_m     ), windows W.focusMaster  )
 
    -- Swap the focused window and the master window
    , ((modm,               xK_Return), windows W.swapMaster)
 
    -- Swap the focused window with the next window
    , ((modm .|. shiftMask, xK_j     ), windows W.swapDown  )
 
    -- Swap the focused window with the previous window
    , ((modm .|. shiftMask, xK_k     ), windows W.swapUp    )
 
    -- Shrink the master area
    , ((modm,               xK_h     ), sendMessage Shrink)
 
    -- Expand the master area
    , ((modm,               xK_l     ), sendMessage Expand)
 
    -- Push window back into tiling
    , ((modm,               xK_t     ), withFocused $ windows . W.sink)
 
    -- Increment the number of windows in the master area
    , ((modm              , xK_comma ), sendMessage (IncMasterN 1))
 
    -- Deincrement the number of windows in the master area
    , ((modm              , xK_period), sendMessage (IncMasterN (-1)))
 
    -- toggle the status bar gap (used with avoidStruts from Hooks.ManageDocks)
    -- , ((modm , xK_b ), sendMessage ToggleStruts)
 
    -- Quit xmonad
    , ((modm .|. shiftMask, xK_q     ), io (exitWith ExitSuccess))
 
    -- Restart xmonad
    , ((modm              , xK_q     ), restart "xmonad" True)
    ]
    ++
 
    --
    -- mod-[1..9], Switch to workspace N
    -- mod-shift-[1..9], Move client to workspace N
    --
    [((m .|. modm, 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}, Switch to physical/Xinerama screens 1, 2, or 3
    -- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3
    --
    [((m .|. modm, 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)]]
   

        

------------------------------------------------------------------------
-- Mouse bindings: default actions bound to mouse events
--
myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $
 
    -- mod-button1, Set the window to floating mode and move by dragging
    [ ((modMask, button1), (\w -> focus w >> mouseMoveWindow w))
 
    -- mod-button2, Raise the window to the top of the stack
    , ((modMask, button2), (\w -> focus w >> windows W.swapMaster))
 
    -- mod-button3, Set the window to floating mode and resize by dragging
    , ((modMask, button3), (\w -> focus w >> mouseResizeWindow w))
 
    -- you may also bind events to the mouse scroll wheel (button4 and button5)
    ]
 
------------------------------------------------------------------------
-- Layouts:
 
-- You can specify and transform your layouts by modifying these values.
-- If you change layout bindings be sure to use 'mod-shift-space' after
-- restarting (with 'mod-q') to reset your layout state to the new
-- defaults, as xmonad preserves your old layout settings by default.
--
-- The available layouts.  Note that each layout is separated by |||,
-- which denotes layout choice.
--
myLayout = tiled ||| Mirror tiled ||| Full
  where
     -- default tiling algorithm partitions the screen into two panes
     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   = 1/2
 
     -- Percent of screen to increment by when resizing panes
     delta   = 3/100
 
------------------------------------------------------------------------
-- Window rules:
 
-- Execute arbitrary actions and WindowSet manipulations when managing
-- a new window. You can use this to, for example, always float a
-- particular program, or have a client always appear on a particular
-- workspace.
--
-- To find the property name associated with a program, use
-- > xprop | grep WM_CLASS
-- and click on the client you're interested in.
--
-- To match on the WM_NAME, you can use 'title' in the same way that
-- 'className' and 'resource' are used below.
--
myManageHook = composeAll
    [ className =? "MPlayer"        --> doFloat
    , className =? "Gimp"           --> doFloat
    , resource  =? "desktop_window" --> doIgnore
    , resource  =? "kdesktop"       --> doIgnore ]
 
-- Whether focus follows the mouse pointer.
myFocusFollowsMouse :: Bool
myFocusFollowsMouse = True
 
 
------------------------------------------------------------------------
-- Status bars and logging
 
-- Perform an arbitrary action on each internal state change or X event.
-- See the 'DynamicLog' extension for examples.
--
-- To emulate dwm's status bar
--
-- > logHook = dynamicLogDzen
--
myLogHook = return ()
 
------------------------------------------------------------------------
-- Startup hook
 
-- Perform an arbitrary action each time xmonad starts or is restarted
-- with mod-q.  Used by, e.g., XMonad.Layout.PerWorkspace to initialize
-- per-workspace layout choices.
--
-- By default, do nothing.
myStartupHook = return ()
 
------------------------------------------------------------------------
-- Now run xmonad with all the defaults we set up.
 
-- Run xmonad with the settings you specify. No need to modify this.
--
main = xmonad $ defaults `additionalKeysP`

    --NOW MY KEYBINDINGS >:D 

-- Multimedia
        [  ("<XF86AudioPlay>"       , spawn "mpc toggle"       ) -- play/pause mpd
        ,  ("<XF86AudioStop>"       , spawn "mpc stop"         ) -- stop mpd
        ,  ("<XF86AudioPrev>"       , spawn "mpc prev"         ) -- prev song
        ,  ("<XF86AudioNext>"       , spawn "mpc next"         ) -- next song
        ,  ("<XF86AudioMute>"       , spawn "ossvol -t"        ) -- toggle mute via custom 
        ,  ("<XF86AudioLowerVolume>", spawn "ossvol -d 1"      ) -- volume dow~custom 
        ,   ("<XF86AudioRaiseVolume>", spawn "ossvol -i 1"      ) -- volume up via cust~
        ]
 
-- A structure containing your configuration settings, overriding
-- fields in the default config. Any you don't override, will 
-- use the defaults defined in xmonad/XMonad/Config.hs
-- 
-- No need to modify this.
--
defaults = defaultConfig {
      -- simple stuff
        terminal           = myTerminal,
        focusFollowsMouse  = myFocusFollowsMouse,
        borderWidth        = myBorderWidth,
        modMask            = myModMask,
        numlockMask        = myNumlockMask,
        workspaces         = myWorkspaces,
        normalBorderColor  = myNormalBorderColor,
        focusedBorderColor = myFocusedBorderColor,
 
      -- key bindings
        keys               = myKeys,
        mouseBindings      = myMouseBindings,
 
      -- hooks, layouts
        layoutHook         = myLayout,
        manageHook         = myManageHook,
        logHook            = myLogHook,
        startupHook        = myStartupHook
    }

PS. If you follow the suggestion:
-- Normally, you'd only override those defaults you care about.

The config will be much easier to understand.

Offline

#218 2009-09-21 17:46:05

YamiFrankc
Member
From: Mexico
Registered: 2009-06-19
Posts: 177
Website

Re: xmonad Hacking Thread

Thanks. Now it doesnt yell for any kind of error.
But those keys do nothing...


Thanks and greetings.

Offline

#219 2009-09-21 18:05:02

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

Re: xmonad Hacking Thread

YamiFrankc wrote:

PS: Is there something like a dmenu config file? Been around the man but cant find the path or something.

there is no dmenu config file in the traditional sense.  i came up with a bit of a hacked way to do it tho smile.

i added a file at ~/.dmenurc with these contents:

# makes dmenu identical across all scripts by sourcing this file
# aur/dmenu-vertical-xft required for xft fonts

DMENU='dmenu -i -fn xft:Verdana-8 -r -x 0 -y 15 -nb #303030 -nf #909090 -sb #909090 -sf #303030'

then in any shell scripts using dmenu, i use it like this:

#!/bin/bash

if [ -f $HOME/.dmenurc ]; then
  . $HOME/.dmenurc
else
  DMENU='dmenu -i'
fi

SELECTION="$(echo the possible choices | $DMENU)"

# do whatever with $SELECTION

one might even be able to use this in xmonad.hs (though i haven't tried)

, ((modm,               xK_p     ), spawn ". /home/username/.dmenurc; exe=`dmenu_path | $DMENU` && eval \"exec $exe\"")

again, i've never tried it like that.


also, sorry about your multimedia keys.  you should verify with xev that your buttons are being recognized as XF86Whatever and that the mpc / ossvol commands work from CLI.

Offline

#220 2009-09-21 18:39:41

YamiFrankc
Member
From: Mexico
Registered: 2009-06-19
Posts: 177
Website

Re: xmonad Hacking Thread

Ill try the dmrc when i return from school. The only thing that i want is to it be in the bottom instead of the top.

Im very sure the multimedia keys works. From Openbox they do(the only change is that i mute with "Alt+XF86Raise(Lower)Volume").


Thanks and greetings.

Offline

#221 2009-09-21 21:44:56

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

Re: xmonad Hacking Thread

YamiFrankc: what happens when you add the startupHook for checking the validity of your additionalKeysP keybindinds (it is also contained in the EZConfig module)?

Offline

#222 2009-09-22 01:23:19

YamiFrankc
Member
From: Mexico
Registered: 2009-06-19
Posts: 177
Website

Re: xmonad Hacking Thread

How to add that? You mean this?

myStartupHook = return ()
startupHook        = myStartupHook

Thanks and greetings.

Offline

#223 2009-10-31 23:29:29

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

Re: xmonad Hacking Thread

Just a quick question; when using toggleFloatNext and toggleFloatAllNew (XMonad.Actions.FloatNext), how can I "ask" XMonad if it is currenty toggled or not? I'd like to have a icons in my dzen that indicates if floatNext is toggled or not.

Basicly I want to know if there is a way to lookup an internal XMonad variable from an outside script, if so, could anyone point me in the right direction?


My Configs @ Github

Offline

#224 2009-11-01 01:44:33

mikesd
Member
From: Australia
Registered: 2008-02-01
Posts: 788
Website

Re: xmonad Hacking Thread

myrkiada wrote:

Just a quick question; when using toggleFloatNext and toggleFloatAllNew (XMonad.Actions.FloatNext), how can I "ask" XMonad if it is currenty toggled or not? I'd like to have a icons in my dzen that indicates if floatNext is toggled or not.

Basicly I want to know if there is a way to lookup an internal XMonad variable from an outside script, if so, could anyone point me in the right direction?

If you are using a loghook, the floatNext module has helper functions for this. Check the docs.

Offline

#225 2009-11-02 16:13:00

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: xmonad Hacking Thread

Hello all, first post on the forums.

As I use xmonad on an eee 901, I've had to find a few ways to make the most of the screen width. One way has been to shorten the xmonad output to my status bar (dzen2). Rather than use "shorten" I knocked up a "quick" function to cut the middle out of the title string, so that in paths for example, I can see the start and end, rather than just the start.

I don't know Haskell, so there will be ways it can be improved (please do), but here it is just in case anyone finds it useful:

cutMid :: Int -> String -> String
cutMid n xs | length xs < n = xs
            | otherwise     = (take ((fromIntegral(n) `div` 2) - length mid) xs)
                            ++ mid
                            ++ (drop (length xs - (fromIntegral(n) `div` 2)) xs)
  where
    mid = "..."

Oh, and I fully expect someone to find a bug. neutral


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

Board footer

Powered by FluxBB