You are not logged in.

#226 2009-11-02 23:07:15

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

Re: xmonad Hacking Thread

Depends on what you mean by bug wink

For example, your cutMid fails to satisfy my expectation that   (cutMid n) always produces a list no longer than length n. But in practice it isn't too far off.

Even if you did cause an error, say call head [] or some other partial function (which you don't), xmonad won't crash since it catches user errors (well except in the manage hook at the moment, and maybe elsewhere).

Otherwise it's pretty useful snippet smile

Offline

#227 2009-11-03 12:36:14

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

Re: xmonad Hacking Thread

vogt wrote:

Depends on what you mean by bug wink

For example, your cutMid fails to satisfy my expectation that   (cutMid n) always produces a list no longer than length n. But in practice it isn't too far off.

Yeah, that'd be a bug. hmm

I guessed a few things about Haskell, so I'm not that surprised. I had thought it would never be longer than n as I thought "div" rounded down. If it (sometimes) rounds up, then you'll get > n chars in those instances.

Thinking about it, I think there will be an issue with very short strings too (eg n <= 7).

TBH I also couldn't be bothered to count the exact number characters returned as I'm only estimating how many I can display anyway. So it's close enough for jazz.

Eventually though, I aim to have all my dzen2 status bars generated by xmonad (some are currently bash scripts) and have it calculate how many characters will be viewable (the status bars can change, and that may stay). So if I'm out, I hope I'll have to fix it eventually. smile

vogt wrote:

Even if you did cause an error, say call head [] or some other partial function (which you don't), xmonad won't crash since it catches user errors (well except in the manage hook at the moment, and maybe elsewhere).

Yes, I've found it very stable. Things tend to fail silently rather than cause it to fall over. Which in a WM makes fixing problems a lot easier.

vogt wrote:

Otherwise it's pretty useful snippet smile

Thanks for that.


"...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

#228 2009-11-29 23:12:57

orlonth
Member
Registered: 2009-11-29
Posts: 4

Re: xmonad Hacking Thread

I`m new to XMonad, used for some hours, and I really like it.
So I tried to create my own config file:

import XMonad
import XMonad.Layout.NoBorders
import XMonad.ManageHook
import XMonad.Layout
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Util.Run(spawnPipe)
import XMonad.Util.EZConfig(additionalKeys)
import System.IO

main = xmonad $ defaultConfig
        { borderWidth        = 1
        , terminal ="aterm -bg black +sb -fg green -fn -*-terminus-medium-*-normal-*-17-*-*-*-*-*-*-*"
        , normalBorderColor="#333333"
        , focusedBorderColor="darkgreen"
        , layoutHook = smartborders $ (tiled ||| (Mirror tiled) ||| Full)
        }

But this gives some errors:

~$ xmonad --recompile
Error detected while loading xmonad configuration file: ~/.xmonad/xmonad.hs

xmonad.hs:16:16: Not in scope: `smartborders'

xmonad.hs:16:32: Not in scope: `tiled'

xmonad.hs:16:50: Not in scope: `tiled'

Please check the file for errors.

What`s wrong in this small config?
Thanks!

Offline

#229 2009-11-29 23:16:55

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

Re: xmonad Hacking Thread

orlonth wrote:

I`m new to XMonad, used for some hours, and I really like it.
So I tried to create my own config file:

import XMonad
import XMonad.Layout.NoBorders
import XMonad.ManageHook
import XMonad.Layout
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Util.Run(spawnPipe)
import XMonad.Util.EZConfig(additionalKeys)
import System.IO

main = xmonad $ defaultConfig
        { borderWidth        = 1
        , terminal ="aterm -bg black +sb -fg green -fn -*-terminus-medium-*-normal-*-17-*-*-*-*-*-*-*"
        , normalBorderColor="#333333"
        , focusedBorderColor="darkgreen"
        , layoutHook = smartborders $ (tiled ||| (Mirror tiled) ||| Full)
        }

But this gives some errors:

~$ xmonad --recompile
Error detected while loading xmonad configuration file: ~/.xmonad/xmonad.hs

xmonad.hs:16:16: Not in scope: `smartborders'

xmonad.hs:16:32: Not in scope: `tiled'

xmonad.hs:16:50: Not in scope: `tiled'

Please check the file for errors.

What`s wrong in this small config?
Thanks!

You didn't define 'tiled'. Look back at some of the earlier posts and see how 'tiled' is defined by the 'where' command.

Offline

#230 2009-11-30 01:42:36

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

Re: xmonad Hacking Thread

Haskell is case sensitive, so if you want to refer to the (fully qualified with module name) XMonad.Layout.NoBorders.smartBorders function, you need to type smartBorders, not smartborders

Then, tiled is not defined anywhere in the XMonad library. You probably want to copy the 'where' binding from the template config which does name a layout 'tiled' (as skottish pointed out). Or you could just use (Tall 1 0.03 0.5) instead of having so much indirection.

Offline

#231 2009-11-30 03:54:08

beepressure
Member
Registered: 2009-10-29
Posts: 80

Re: xmonad Hacking Thread

Ive got pidgin set to float in my config file, but every time i start it it starts in full screen. I resize it with mod+rightclick and it will be right back to full screen when i close and reopen it or if i minimize it to the tray. What gives? I need to to keep the window size

Offline

#232 2009-11-30 15:17:27

Cyrusm
Member
From: Bozeman, MT
Registered: 2007-11-15
Posts: 1,053

Re: xmonad Hacking Thread

my layout is very close to the defaults, I like to keep things as simple as possible.  I added in the spiral layout, but  I'm still tweaking the ratio argument to get something usable.

import XMonad
import qualified Data.Map as M
import qualified XMonad.StackSet as W
import System.IO
import System.Exit
import Data.Monoid
import XMonad.Layout.Spiral
import XMonad.ManageHook

main = do
    xmonad $ defaultConfig
        { modMask              = myModMask
        , terminal             = myTerminal
        , keys                 = myKeys
        , layoutHook           = myLayout 
        , manageHook           = myManageHook
        , normalBorderColor    = myNormalBorderColor
        , focusedBorderColor   = myFocusedBorderColor
        }

myModMask      =    mod4Mask                 --rebind mod to the windows key.        
myTerminal     =    "aterm -tr +sb -sh 50"         --transparent terminal, so i can enjoy my wallpapers.
--modify colors
myNormalBorderColor  = "#000000"
myFocusedBorderColor = "#000066"

--myKeys custom key configuration


------------------------------------------------------------------------
-- 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 gmrun
    , ((modm ,            xK_x     ), spawn "gmrun")
 
    -- close focused window
    , ((modm .|. shiftMask, xK_c     ), kill)

-- My Programs
     -- Web Browsers
    , ((modm ,              xK_f     ), spawn "firefox")
    , ((modm ,             xK_c     ), spawn "chromium-browser")
     -- Office Suite
    , ((modm ,             xK_o     ), spawn "soffice")
    -- Calculator
    , ((0    ,            0x1008ff1d), spawn "xcalc")
     -- XMMS Key Bindings
    , ((modm ,             xK_m     ), spawn "xmms")
    , ((0    ,           0x1008ff14), spawn "xmms -t")
    , ((0    ,           0x1008ff15), spawn "xmms -s")
    , ((0    ,            0x1008ff16), spawn "xmms -r")
    , ((0    ,            0x1008ff17), spawn "xmms -f")
 
     -- 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
    -- Use this binding with avoidStruts from Hooks.ManageDocks.
    -- See also the statusBar function from Hooks.DynamicLog.
    --
    -- , ((modm              , xK_b     ), sendMessage ToggleStruts)
 
    -- Quit xmonad
    , ((modm .|. shiftMask, xK_q     ), io (exitWith ExitSuccess))
 
    -- Restart xmonad
    , ((modm              , xK_q     ), spawn "xmonad --recompile; xmonad --restart")
    ]
    ++
 
    --
    -- mod-[1..9], Switch to workspace N
    --
    -- 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)]]
 
myLayout = tiled ||| Mirror tiled ||| Full ||| spiral (4 / 2)
  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

myManageHook = composeAll . concat $
    [ [className   =?  c --> doFloat | c <- myCFloats]
    , [title       =?  t --> doFloat | t <- myTFloats]
    ]
    where
    myCFloats = ["MPlayer" , "XCalc" , "XMMS" , "Gimp"]
    myTFloats = ["Downloads", "Save As..."]

Hofstadter's Law:
           It always takes longer than you expect, even when you take into account Hofstadter's Law.

Offline

#233 2009-12-01 00:31:58

methuselah
Member
Registered: 2007-10-02
Posts: 570

Re: xmonad Hacking Thread

Hello Xmonad users, I'm brand new to xmoand and so far I'm loving it. I installed it as the window manager on top of the Xfce4 desktop environment: http://haskell.org/haskellwiki/Xmonad/U … ad_in_XFCE


Screenshot-Xmonad-new-2.png Screenshot-19-14.png Screenshot-18-11.png


This is my xmonad.hs:

import XMonad
import XMonad.Config.Xfce
import qualified XMonad.StackSet as W
import XMonad.Util.EZConfig
import XMonad.Hooks.ManageDocks

-- Width of the window border in pixels.
--
myBorderWidth   = 2
 
-- 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       = mod1Mask
-- other imports

 
myWorkspaces = ["1","2","3","4","5","6","7","8","9","0"]
 
modm = mod1Mask -- for numpad workspaces
 
myKeys = -- use with EZConfig.additionalKeys or edit to match your key binding method
    [
    ((modm .|. shiftMask, xK_KP_Add ), kill),
    ((modm .|. shiftMask, xK_KP_Enter ), spawn "/home/seventy3/firefox_start.sh"),
    ((modm .|. shiftMask, xK_KP_Delete ), spawn "Thunar"),
    ((modm,               xK_KP_Subtract ), windows W.focusDown),
    ((modm .|. shiftMask, xK_KP_Subtract ), windows W.swapDown),
    ((modm .|. shiftMask, xK_KP_Multiply ), windows W.swapUp),
    ((modm,               xK_KP_Multiply ), windows W.focusUp),
    ((modm,               xK_Page_Up ), sendMessage Shrink),
    ((modm,               xK_Page_Down ), sendMessage Expand)
    ]
    ++
    [((m .|. modm, k), windows $ f i)
        | (i, k) <- zip myWorkspaces numPadKeys
        ,  (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]
    ]
    
 
-- Non-numeric num pad keys, sorted by number 
numPadKeys = [ xK_KP_End,  xK_KP_Down,  xK_KP_Page_Down -- 1, 2, 3
             , xK_KP_Left, xK_KP_Begin, xK_KP_Right     -- 4, 5, 6
             , xK_KP_Home, xK_KP_Up,    xK_KP_Page_Up   -- 7, 8, 9
             , xK_KP_Insert] -- 0 
 
-- 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
 
-- Border colors for unfocused and focused windows, respectively.
--
myNormalBorderColor  = "#66458F"
myFocusedBorderColor = "#AE75F6"

-- manage hooks attempt
--
myManageHook = composeAll
   [ className =? "Vlc"                                    --> doFloat,
     className =? "Gimp-2.6"                               --> doFloat,
     className =? "Inkscape"                               --> doShift "6",
     className =? "Agave"                                  --> doFloat,
     className =? "Xfce4-appearance-settings"              --> doFloat,
     className =? "Xfce4-screenshooter-plugin"             --> doFloat,
     className =? "Xfrun4"                                 --> doFloat,
     className =? "Gcalctool"                              --> doFloat,
     className =? "Xarchiver"                              --> doFloat,
     className =? "File-roller"                            --> doFloat,
     className =? "Firefox" <&&> resource =? "Dialog"      --> doFloat,
     className =? "Firefox" <&&> resource =? "Extension"   --> doFloat,
     className =? "Firefox" <&&> resource =? "Browser"     --> doFloat,
     className =? "Firefox" <&&> resource =? "Download"    --> doFloat
   ]

 
------------------------------------------------------------------------

 
main = xmonad $ xfceConfig
    {
    borderWidth        = myBorderWidth,
    normalBorderColor  = myNormalBorderColor,
        modMask            = myModMask,       
        workspaces         = myWorkspaces,
        manageHook         = myManageHook <+> manageHook xfceConfig,
    focusedBorderColor = myFocusedBorderColor
    }`additionalKeys` myKeys

So far I have most things configured, but I do have a question about doFloat and doShift. My question is about using doShift or viewShift along with a doFloat for the same app (like if I want to open a floating Gimp on workspace "7"). How would I write that (I couldn't find the info on using both a float and a shift for the same app).


My second question is about the "xfce4-session-logout". I tried to add this code:

((modm .|. shiftMask, xK_q), spawn "xfce4-session-logout")

..... but it doesn't open the xfce4 logout app (for shutdown, reboot, suspend, hibernate, logout), all it does is logout me out to the Slim Login screen (same as before I added that aprt to my xmonad.hs)..... I reboot or halt in the Slim login to continue the reboot/shutdown process but I would rather be able to shutdown without using my password.


My third question is one that I haven't really searched out yet, but I might as well ask just to be sent in the correct direction. I would basically like to add a conky bar to the bottom of my screen if it is possible. I saw that people use xmonadbar with conky-cli, I wondering if this is what I need to do, and will it conflict with xfce4-panel?

Last edited by methuselah (2009-12-01 00:38:31)

Offline

#234 2009-12-01 01:01:50

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

Re: xmonad Hacking Thread

Hi, I'm in a hurry, so only a quick response to your first question. wink

You can combine hooks with <+> (remember to put () around them), example;

className =? "Gimp-2.6"        --> (doFloat <+> doShift "6"),

Hope that helps.

Last edited by myrkiada (2009-12-01 01:04:03)


My Configs @ Github

Offline

#235 2009-12-01 01:03:49

methuselah
Member
Registered: 2007-10-02
Posts: 570

Re: xmonad Hacking Thread

myrkiada wrote:

Hi, I'm in a hurry, so only a quick response to your first question. wink

You can combine hooks with <+> (remember to put () around them), example;

className =? "Gimp-2.6"        --> (doFloat <+> doShift "6"),

Hope that helps.

Thank you very much.

Last edited by methuselah (2009-12-01 01:06:22)

Offline

#236 2009-12-01 01:06:35

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

Re: xmonad Hacking Thread

No problem, as far as I know it should work with all kinds of hooks.

And yeah, a little typo, it should say doShift "7" in my sample, but you get the point. tongue

Good luck.


My Configs @ Github

Offline

#237 2009-12-01 01:25:26

methuselah
Member
Registered: 2007-10-02
Posts: 570

Re: xmonad Hacking Thread

myrkiada wrote:

No problem, as far as I know it should work with all kinds of hooks.

And yeah, a little typo, it should say doShift "7" in my sample, but you get the point. tongue

Good luck.

Thanks again. No sweat about the typo, I actually changed my Gimp workspace to "9" and Inkscape to "8"..... and I took off the doFloat for Vlc since I mostly use the command line version of cvlc and xprop | grep CLASS doesn't work for that.... so I'll just manually move cvlc to workspace "0".


Is there a way to make it change automatically to that workspace for gimp while using: (doFloat <+> doShift "9"),

Last edited by methuselah (2009-12-01 01:27:46)

Offline

#238 2009-12-01 01:51:44

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

Re: xmonad Hacking Thread

methuselah wrote:

My second question is about the "xfce4-session-logout". I tried to add this code:

((modm .|. shiftMask, xK_q), spawn "xfce4-session-logout")

..... but it doesn't open the xfce4 logout app (for shutdown, reboot, suspend, hibernate, logout), all it does is logout me out to the Slim Login screen (same as before I added that aprt to my xmonad.hs)..... I reboot or halt in the Slim login to continue the reboot/shutdown process but I would rather be able to shutdown without using my password.

I'm sorry that I haven't been able to check this out more, but perhaps there is another command rather than xfce4-session-logout that will get you the desired results.  From a quick google search it appears that xfce4-session has quite a bit to it.  I don't use xfce myself, otherwise I could give you a more complete answer here.

methuselah wrote:

My third question is one that I haven't really searched out yet, but I might as well ask just to be sent in the correct direction. I would basically like to add a conky bar to the bottom of my screen if it is possible. I saw that people use xmonadbar with conky-cli, I wondering if this is what I need to do, and will it conflict with xfce4-panel?

It's easy to set up space for conky.  You set up a gap, and then put conky in that gap.

You would need xmonad-contrib-darcs, and add the following in the appropriate places:

import XMonad.Layout.Gaps
layoutHook = gaps [(U,80), (R,40)] $ blah....

Basically the gaps command tells xmonad to leave whatever nbr of pixels against whatever edge you want (R for right, L for left, U for up (i guess the top of the screen), and D for down (or the bottom of the screen).

I leave 80 pixels at the top and toss conky in there along with stalonetray and my dzen bar.   I can post a screenshot if you are interested.  But it works without a problem.
HTH


Knute

Offline

#239 2009-12-01 03:15:36

methuselah
Member
Registered: 2007-10-02
Posts: 570

Re: xmonad Hacking Thread

Knute wrote:

It's easy to set up space for conky.  You set up a gap, and then put conky in that gap.


import XMonad.Layout.Gaps
layoutHook = gaps [(U,80), (R,40)] $ blah....

Basically the gaps command tells xmonad to leave whatever nbr of pixels against whatever edge you want (R for right, L for left, U for up (i guess the top of the screen), and D for down (or the bottom of the screen).
HTH

Thank you very much, this is the result:


Screenshot-32-15.png


Knute wrote:
methuselah wrote:

My second question is about the "xfce4-session-logout". I tried to add this code:

((modm .|. shiftMask, xK_q), spawn "xfce4-session-logout")

..... but it doesn't open the xfce4 logout app (for shutdown, reboot, suspend, hibernate, logout), all it does is logout me out to the Slim Login screen (same as before I added that aprt to my xmonad.hs)..... I reboot or halt in the Slim login to continue the reboot/shutdown process but I would rather be able to shutdown without using my password.

I'm sorry that I haven't been able to check this out more, but perhaps there is another command rather than xfce4-session-logout that will get you the desired results.  From a quick google search it appears that xfce4-session has quite a bit to it.  I don't use xfce myself, otherwise I could give you a more complete answer here.

I've been searching for the answer for that but have had no luck.

Last edited by methuselah (2009-12-01 10:30:55)

Offline

#240 2009-12-01 19:42:19

orlonth
Member
Registered: 2009-11-29
Posts: 4

Re: xmonad Hacking Thread

Thanks Skottish and Vogt, got the config working.
But, as you might have guessed, some new problems arose:

- Starting apps with my Fn key (XF86WakeUp) (had to add it in xmodmap, although fluxbox recognizes the key, xmonad doesn`t..)

.......
        , layoutHook = smartBorders $ layoutHook defaultConfig
        } `additionalKeysP` mykeys

mykeys = [ ("<XF86WakeUp>-x" , spawn "aterm" )
         , ("<XF86WakeUp>-u" , spawn "iceweasel" )
         ]
.....

This does not seem to work. (no error or compile output)

- Autostarting some apps on login:

.....
startupHook = startup

startup :: X ()
startup = do
        spawn "myterm"
        spawn "gnome-settings-daemon &"
........

Doesn't work either.

Offline

#241 2009-12-02 08:11:09

rickpt
Member
Registered: 2009-09-10
Posts: 3

Re: xmonad Hacking Thread

Cant you just those files in you .xinit file?
like:

myterm&

gnome-settings-daemon&

exec xmonad

Offline

#242 2009-12-02 13:36:34

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

Re: xmonad Hacking Thread

orlonth wrote:

Thanks Skottish and Vogt, got the config working.
But, as you might have guessed, some new problems arose:

- Starting apps with my Fn key (XF86WakeUp) (had to add it in xmodmap, although fluxbox recognizes the key, xmonad doesn`t..)

.......
        , layoutHook = smartBorders $ layoutHook defaultConfig
        } `additionalKeysP` mykeys

mykeys = [ ("<XF86WakeUp>-x" , spawn "aterm" )
         , ("<XF86WakeUp>-u" , spawn "iceweasel" )
         ]
.....

This does not seem to work. (no error or compile output)

Your setup of the key is strange.   It looks like you are trying to use one of the alternate methods of inserting the shortcut keys, yet, it won't work without the appropriate library imported.

You could try something like this:

mykeys = [ ((0 .|. xK_XF86WakeUp, xK_x), spawn "aterm")
                 , ((0 .|. xK_XF86WakeUp, xK_u), spawn "iceweasel" )
                 ]
......

If you wanted to make your Wakeup key the modmask then you could set that up as your modMask and use the modMask rather than the zero,  though,  I'm not quite sure if that will work like I intended, as the zero says no modMask at all. 

orlonth wrote:

- Autostarting some apps on login:

.....
startupHook = startup

startup :: X ()
startup = do
        spawn "myterm"
        spawn "gnome-settings-daemon &"
........

Doesn't work either.

Take out the "&"  as it isn't needed in this setup.
You need to be aware that whatever you put in the startupHook gets started every time xmonad starts.   So if you restart xmonad (say, even after you recompile your ~/.xmonad/xmonad.hs, these apps will be started again, so if you keep X running most of the time, and just restart on the fly after you edit your config you may have several instances of these programs running.  Just FYI.

HTH


Knute

Offline

#243 2009-12-03 02:43:54

axion419
Member
Registered: 2007-04-12
Posts: 185

Re: xmonad Hacking Thread

I can not get custom keys set up for my xmonad.hs . I want to change the colors that dmenu uses when it launches, so I figured I just need to add a new keybinding in my xmonad.hs to override the default.  The only problem is, I cant seem to find a xmonad.hs that resembles mine that has custom key bindings.  Any help would be great.

I want to add something like this to mod4key + p

 
$(dmenu_path | dmenu -b -nb '#E0E9D0' -sb '#a6b38d' -sf '#070806')
-- Imports.
import XMonad
import XMonad.Hooks.DynamicLog


-- MY STUFF

myTerminal        = "urxvtc"
myWorkspaces    = ["1", "2" ,"3", "4", "5", "6", "7", "8", "9"]
myNormalBorderColor    = "#3F3F3F"
myFocusedBorderColor = "#DCA3A3"
myBorderWidth = 4

 
-- The main function.
main = xmonad =<< statusBar myBar myPP toggleStrutsKey myConfig

-- Command to launch the bar.
myBar = "xmobar"

-- Custom PP, configure it as you like. It determines what's being written to the bar.
myPP = xmobarPP { ppCurrent = xmobarColor "#DCDCCC" "" . wrap "<" ">" }

-- Keybinding to toggle the gap for the bar.
toggleStrutsKey XConfig {XMonad.modMask = modMask} = (modMask, xK_b)

-- Main configuration, override the defaults to your liking.
myConfig = defaultConfig {
        terminal           = myTerminal,
        borderWidth        = myBorderWidth,
        normalBorderColor  = myNormalBorderColor,
        focusedBorderColor = myFocusedBorderColor,
        modMask               = mod4Mask -- use the Windows button as mod
}

Once again, any help would be great, thanks.

Offline

#244 2009-12-03 02:55:48

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

Re: xmonad Hacking Thread

axion419 wrote:

I want to add something like this to mod4key + p

 
$(dmenu_path | dmenu -b -nb '#E0E9D0' -sb '#a6b38d' -sf '#070806')

The easiest thing to do that I can think of is to put the command that you want into a script file in your path, give it execute permissions, and then just simply call the script file.

I have one in my ~/bin file that I call dmrun, and is very handy to have around.

#!/bin/sh
$(dmenu_path | \
dmenu -b -fn '-*-liberation mono-*-*-*-*-25-*-*-*-*-*-*-*' \
-nb '#000066' -nf '#FFFF00' -sb '#002200' -sf '#00ffff')

HTH


Knute

Offline

#245 2009-12-03 03:44:02

jtemple
Member
Registered: 2009-11-29
Posts: 11

Re: xmonad Hacking Thread

I'm trying to get xmonad playing nicely with my dual monitors. Basic functionality works fine, but how do I get xmobar and trayer to work? When I specific xmobar to be on the "left" it puts it on my default monitor, and trayer on the right it will put it all the way on the other side of my desktop, on the second monitor. I want them both on the same screen in this configuration

Offline

#246 2009-12-03 04:14:05

llcawthorne
Member
From: Columbia, SC
Registered: 2009-10-16
Posts: 142

Re: xmonad Hacking Thread

jtemple wrote:

I'm trying to get xmonad playing nicely with my dual monitors. Basic functionality works fine, but how do I get xmobar and trayer to work? When I specific xmobar to be on the "left" it puts it on my default monitor, and trayer on the right it will put it all the way on the other side of my desktop, on the second monitor. I want them both on the same screen in this configuration

On my setup, I have trayer on my far right hand monitor, so this isn't a problem.  .xmobar by default goes to the main monitor.  Trayer goes to the far left or far right of the setup.  So an easy fix (if you like it), might be to left-align trayer, and then setup xmobar to go right.  It should stay on screen 0 but be right aligned, and trayer should be all the way to the right.  Maybe...

If this is not acceptable or flat out doesn't work, then maybe you can do something with the --distance option.  It is a width in pixels, so perhaps if you did --distance [width of second monitor] it would place it in the right place?

The manpage for trayer is included in this post, if you need it:
http://bbs.archlinux.org/viewtopic.php?id=46818


To understand recursion, you must understand recursion.

Offline

#247 2009-12-03 06:40:38

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

Re: xmonad Hacking Thread

Giving Xmonad another try, after trying awesome and dwm more "harder" and even the awesome musca.

EDIT: Was going to post a "problem". But i dint notice there was web instead of www roll

Last edited by YamiFrankc (2009-12-03 06:43:41)


Thanks and greetings.

Offline

#248 2009-12-03 11:36:13

Paul-S
Member
From: Wales
Registered: 2008-02-04
Posts: 353

Re: xmonad Hacking Thread

import XMonad 
import Data.Maybe
import Data.List
import XMonad.Layout
import System.Exit
import XMonad.Layout.LayoutHints
import XMonad.Config (defaultConfig)
import XMonad.Layout.NoBorders
import XMonad.Operations
import XMonad.Layout.Grid
import XMonad.Layout.Named
import XMonad.Layout.SimpleFloat
import XMonad.Core
import XMonad.Layout.Reflect
import XMonad.Layout.PerWorkspace (onWorkspace)
import XMonad.Layout.ToggleLayouts
import XMonad.Util.WorkspaceCompare
import XMonad.Util.Font
import XMonad.Layout.ThreeColumns
import XMonad.Layout.ResizableTile
import XMonad.Layout.Gaps
import XMonad.Util.Scratchpad (scratchpadSpawnAction, scratchpadManageHook, scratchpadFilterOutWorkspace)
import XMonad.Layout.IM
import XMonad.Layout.Spacing
import Data.Ratio ((%))
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.UrgencyHook
import XMonad.ManageHook 
import System.IO.UTF8
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.ManageHelpers
import XMonad.Layout.WindowNavigation
import XMonad.Util.Run (spawnPipe, runInTerm, hPutStrLn)
import qualified XMonad.StackSet as S
import qualified XMonad.StackSet as W
import qualified Data.Map        as M
import qualified XMonad.Layout.Magnifier as Mag
import XMonad.Prompt
import XMonad.Prompt.Shell
import XMonad.Prompt.Theme
import XMonad.Prompt.AppendFile (appendFilePrompt)
import qualified XMonad.Prompt         as P
import qualified XMonad.Actions.Submap as SM
import qualified XMonad.Actions.Search as S

myModMask       = mod4Mask

myNumlockMask   = mod2Mask

myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $

    [ ((modMask, xK_Return), spawn $ XMonad.terminal conf)
    , ((modMask,               xK_i     ), runInTerm "" "screen")
    , ((modMask,               xK_p     ), spawn "exe=`dmenu_path | dmenu -nb 'snow1' -nf '#543532' -sb '#ffffff' -sf '#ffffff' -fn 'Bitstream Vera Sans-8'` && eval \"exec $exe\"")
    , ((modMask .|. shiftMask, xK_p     ), spawn "gmrun")
    , ((modMask .|. shiftMask, xK_n     ), spawn "nautilus --no-desktop") 
    , ((modMask .|. shiftMask, xK_x     ), spawn "xclock -norender -bg black -fg white -hd white -hl white -bd white")
    , ((modMask .|. shiftMask, xK_c     ), kill)
    , ((mod4Mask,              xK_c     ), runInTerm "" "ctw --refresh=15 UKXX0146")
    , ((modMask,               xK_u     ), spawn "uzbl-browser")
    , ((modMask,               xK_f     ), spawn "firefox")
    , ((modMask,               xK_x     ), spawn "xlock")
    , ((modMask,               xK_t     ), spawn "thunar")
    , ((modMask,               xK_v     ), spawn "vlc")
    , ((modMask,               xK_d     ), spawn "deluge")
    , ((modMask .|. shiftMask, xK_s     ), scratchpadSpawnAction defaultConfig { terminal = myTerminal })
    , ((modMask,               xK_Right ), sendMessage $ Go R)
    , ((modMask,               xK_Left  ), sendMessage $ Go L)
    , ((modMask,               xK_Up    ), sendMessage $ Go U)
    , ((modMask,               xK_Down  ), sendMessage $ Go D)
    , ((modMask,               xK_space ), sendMessage NextLayout)
    , ((modMask .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf)
    , ((modMask,               xK_n     ), spawn "nitrogen /home/paul/downloads/wallpaper")
    , ((modMask,               xK_Tab   ), windows W.focusDown)
    , ((modMask,               xK_j     ), windows W.focusDown)
    , ((modMask,               xK_s     ), SM.submap $ searchEngineMap $ S.promptSearch paulXPConfig)
    , ((modMask,               xK_a     ), shellPrompt paulXPConfig)
    , ((modMask .|. shiftMask, xK_a     ), appendFilePrompt paulXPConfig "/home/paul/Desktop/notes")
    , ((0,                     xK_Print ), spawn "/home/paul/scripts/screenshot")
    , ((modMask,               xK_k     ), windows W.focusUp)
    , ((modMask,               xK_m     ), windows W.focusMaster)
    , ((modMask .|. shiftMask, xK_Return), windows W.swapMaster)
    , ((modMask .|. shiftMask, xK_j     ), windows W.swapDown)
    , ((modMask .|. shiftMask, xK_k     ), windows W.swapUp)
    , ((modMask,               xK_h     ), sendMessage Shrink)
    , ((modMask,               xK_l     ), sendMessage Expand)
    , ((modMask,               xK_comma ), sendMessage (IncMasterN 1))
    , ((modMask,               xK_period), sendMessage (IncMasterN (-1)))
    , ((modMask .|. controlMask, xK_r   ), spawn "killall mpdinfo1 mpdinfo conky dzen-status dzen-cal dzen2" >> restart "/home/paul/bin/xmonad" True)
    , ((modMask .|. shiftMask, xK_q     ), io (exitWith ExitSuccess))
    , ((modMask,               xK_q     ), restart "/home/paul/bin/xmonad" True)
    ]
    ++

    [((m .|. modMask, k), windows $ f i)
        | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
        , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
    ++

    [((m .|. modMask, 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)]]



paulXPConfig = defaultXPConfig
           { font = myFont
                           , bgColor = "snow1"
                           , fgColor = "#543532"
                           , fgHLight = "#543532"
                           , bgHLight = "#543532"
                           , promptBorderWidth = 0
                           , position = Bottom
                           , height = 19
                           , historySize = 32 
                           , defaultText = []
                           }


myManageHook = scratchpadManageHook (W.RationalRect 0.25 0 0.5 0.35) <+>
               (composeAll $
    [ resource  =? "deluge"         --> doF (W.shift "5")
    , resource  =? "xclock"         --> doFloat
    , className =? "MPlayer"        --> (ask >>= doF . W.sink)
    , className =? "Gimp"           --> doF (W.shift "5")
    , resource  =? "desktop_window" --> doIgnore
    , resource  =? "pidgin" <&&> role =? "buddy_list" --> doF (W.shift "4:im")
    , resource  =? "uzbl"           --> doF (W.shift "net")
    , resource  =? "uzbl_tabbed.py" --> doF (W.shift "net")
    , className =? "Shiretoko"      --> doF (W.shift "net") ])

  where  
    role = stringProperty "WM_WINDOW_ROLE"

newManageHook = myManageHook <+> manageHook defaultConfig

myTerminal = "urxvt"
myWorkspaces = ["1:net","2:screen","3:files","4:im"] ++ map show [5..9]
myBorderWidth = 1
myFont = "xft:Bitstream Vera Sans:size=9"
myNormalBorderColor = "#FF9933"
myFocusedBorderColor = "#FF9933"
myStartupHook = return ()
myFocusFollowsMouse = True

searchEngineMap method = M.fromList $
    [ ((0, xK_g), method S.google)
    , ((0, xK_w), method S.wikipedia)
    , ((0, xK_i), method S.imdb)
    , ((0, xK_y), method S.youtube)
    , ((0, xK_d), method S.dictionary)
    , ((0, xK_b), method $ S.searchEngine "archbbs" "http://bbs.archlinux.org/search.php?action=search&keywords=")
    , ((0, xK_r), method $ S.searchEngine "AUR" "http://aur.archlinux.org/packages.php?O=0&L=0&C=0&K=")
    , ((0, xK_a), method $ S.searchEngine "archwiki" "http://wiki.archlinux.org/index.php/Special:Search?search=")
    ] 

imLayout = avoidStruts $
           IM (1%7) (Or (Title "Buddy List")
                    (And (Resource "main") (ClassName "pidgin")))

standardLayouts = avoidStruts $
                  windowNavigation $
                  onWorkspace "1:net" mag $
                  tiled ||| Mirror tiled ||| Full ||| Grid 
  
 where
    tiled = Tall nmaster delta ratio
    grid = layoutHints Grid
    mag = named "Grid" $ Mag.magnifiercz 1.15 $ Grid
    nmaster = 1
    ratio = toRational (2/(1 + sqrt 5 :: Double))
    delta = 3/100

myLayout = onWorkspace "4:im" imLayout $
           standardLayouts

main = do
       din <- spawnPipe myStatusBar
       din2 <- spawnPipe myStatusBar2
       din3 <- spawnPipe myStatusBar3
       din4 <- spawnPipe myStatusBar4
       xmonad $ withUrgencyHook NoUrgencyHook $ defaultConfig
        { terminal = "urxvt"
                , normalBorderColor = "#543532"
                , workspaces = myWorkspaces
                , manageHook = newManageHook <+> manageDocks
                , focusedBorderColor = "#543532"
        , logHook = myLogHook din
                , modMask = myModMask
        , layoutHook = myLayout
        , keys = \c -> myKeys c
        }

myLogHook h = dynamicLogWithPP $ defaultPP {
              ppSort = fmap (.scratchpadFilterOutWorkspace) getSortByTag
            , ppCurrent = dzenColor "#D84739" "snow1" . pad
            , ppVisible = dzenColor "#D84739" "snow1" . pad
            , ppHidden = dzenColor "#543532" "snow1" . pad
            , ppTitle = dzenColor "#D84739" "snow1" . shorten 70 
            , ppHiddenNoWindows = const ""
            , ppUrgent = wrap (dzenColor "#FF9933" "" "(") (dzenColor "#FF9933" "" ")") . pad
            , ppSep = dzenColor "#543532" "snow1" "  :  "
            , ppWsSep = ""
            , ppLayout = dzenColor "#543532" "snow1" .
                           (\ x -> case x of
                                           "Tall" -> "^i(/home/paul/icons/dzen2/tall-thin-updated-big-outline.xbm)"
                                           "Mirror Tall" -> "^i(/home/paul/icons/dzen2/mtall-thin-updated-big-outline.xbm)"
                                           "Full" -> "^i(/home/paul/icons/dzen2/full-thin-updated-big-outline.xbm)"
                                           "Grid" -> "^i(/home/paul/icons/dzen2/grid-updated-big-outline.xbm)"
                                           "IM Grid" -> "^i(/home/paul/icons/dzen2/full-thin-updated-big-im.xbm)"
                           )
            , ppOutput = System.IO.UTF8.hPutStrLn h
            }
            where
            icon h = "^i(/home/paul/icons/dzen2/" ++ h ++ ")"
            fill h i = "^p(" ++ show i ++ ")" ++ h ++ "^p(" ++ show i ++ ")"

myStatusBar = "dzen2 -p -ta left -fn 'Bitstream Vera Sans-9' -x 0 -y 1031 -h 19 -w 840 -bg 'snow1'"
myStatusBar2 = "conky -c ~/.conkyrc1 | dzen2 -p -ta right -fn 'Bitstream Vera Sans-9' -x 840 -y 1031 -h 19 -w 840  -bg 'snow1'"
myStatusBar3 = "conky -c ~/.conkyrc2 | dzen2 -p -ta right -fn 'Bitstream Vera Sans-9' -x 840 -y 0 -h 19 -w 840 -bg 'snow1'"
myStatusBar4 = "conky -c ~/.conkyrc3 | dzen2 -p -ta left -fn 'Bitstream Vera Sans-9' -x 0 -y 0 -h 19 -w 840 -bg 'snow1'"
defaults = defaultConfig {
       focusFollowsMouse = myFocusFollowsMouse,
       numlockMask = myNumlockMask,
       keys = myKeys,
       workspaces = myWorkspaces,
       manageHook = myManageHook,
       startupHook = myStartupHook
        }

Any chance anyone can take a quick look at my xmonad.hs and see why my paulXPConfig doesn't use
the proper font, I've replaced font = myFont with the font name but that doesn't work either.

Cheers
Paul-S

Offline

#249 2009-12-03 14:10:47

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

Re: xmonad Hacking Thread

Paul-S wrote:

-- snip --

myFont = "xft:Bitstream Vera Sans:size=9"

-- snip --

Paul,

Not sure it matters, but i use this format,

myXFTFont    = "xft:Verdana-8"

and it works fine.  maybe try "xft:Bitstream Vera Sans-9" instead?

Offline

#250 2009-12-03 14:26:08

Paul-S
Member
From: Wales
Registered: 2008-02-04
Posts: 353

Re: xmonad Hacking Thread

Yeah I've tried every combination of font name and size I can think of, it just shows some ugly little default font.

Offline

Board footer

Powered by FluxBB