You are not logged in.

#126 2009-03-23 00:22:18

X/ax
Member
From: Oost vlaanderen, Belgium
Registered: 2008-01-13
Posts: 275
Website

Re: xmonad Hacking Thread

Hi,
First, I'd like to thank McManiaC for his config. Nice work ^^
However, I can't seem to get dzen2 / conky (-cli) working... I am not sure why... It seems the configuration was correct (at very least).
I put the icon pack in my ~/.dzen, and I placed the conky config in ~/.conkytoprc, I hope that was correct to do...

I'd really like to have that bar running, because not knowing whether or not someone is talking to me on pidgin e.g. is annoying ^^

Thanks in advance.

// edit:
Also, what I just noticed that somehow, out of somewhere, the mod4mask button doesn't work anymore. I can't switch desktops, I can't do anything with that key (not restart xmonad either)
Weird actually...

Last edited by X/ax (2009-03-23 00:41:37)


My coding blog (or an attempt at it)
Archer start page (or an attempt at it)

Offline

#127 2009-03-23 07:52:09

bender02
Member
From: UK
Registered: 2007-02-04
Posts: 1,328

Re: xmonad Hacking Thread

@X/ax: I hope you changed '/home/nils/.dzen' in his xmonad.hs to your home directory...

Offline

#128 2009-03-23 09:38:42

X/ax
Member
From: Oost vlaanderen, Belgium
Registered: 2008-01-13
Posts: 275
Website

Re: xmonad Hacking Thread

bender02 wrote:

@X/ax: I hope you changed '/home/nils/.dzen' in his xmonad.hs to your home directory...

I did... I'm currently running on my old xmonad.hs, perhaps starting to "merge" that one and Nils' one...

// edit
Another annoying thing is that if I run the config without changing anything (straight from the web to my .xmonad folder), I get following errors:

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

on the commandline:
    Warning: -no-recomp is deprecated: Use -fforce-recomp instead

xmonad.hs:109:10: Not in scope: `handleEventHook'

xmonad.hs:304:74: Not in scope: `W.shiftMaster'

xmonad.hs:305:53: Not in scope: `W.shiftMaster'

xmonad.hs:306:76: Not in scope: `W.shiftMaster'

Please check the file for errors.

I mostly solve that stuff by commenting them out...

Last edited by X/ax (2009-03-23 10:02:13)


My coding blog (or an attempt at it)
Archer start page (or an attempt at it)

Offline

#129 2009-03-23 10:52:00

McManiaC
Member
Registered: 2009-03-06
Posts: 15

Re: xmonad Hacking Thread

Are you using the darcs version? Thats at least what I've been running. wink

Offline

#130 2009-03-23 12:50:41

X/ax
Member
From: Oost vlaanderen, Belgium
Registered: 2008-01-13
Posts: 275
Website

Re: xmonad Hacking Thread

McManiaC wrote:

Are you using the darcs version? Thats at least what I've been running. wink

I've installed the darcs version now. And with some configuration I've got my desired outcome. Except for dzen / conky.
Once again, it doesn't seem to work. However, this time I see a small (2px wide) window outlined by xmonad.  I suspect that to be dzen... So I must be doing something wrong still...

// edit
Major breakthrough, I seem to have done something right big_smile
I think it's because I installed haskell-dzen-utils or-so... Because now I see some bar at least ^^
Thanks for the patience, from this point off, I think I'll go pay attention to the dzen / xmobar hacking thread

Last edited by X/ax (2009-03-23 13:26:06)


My coding blog (or an attempt at it)
Archer start page (or an attempt at it)

Offline

#131 2009-04-15 14:54:07

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

Re: xmonad Hacking Thread

Has anyone made something l33t with XMonad.Actions.DynamicWorkspaces? I was thinking of something like this:

I run firefox
if a workspace named "www" exists, move firefox to this workspace
else, create a workspace named "www" and move firefox to this workspace

It doesn't seem to be very hard to do, but I don't know how to check if there's such workspace.


(lambda ())

Offline

#132 2009-04-28 21:06:54

a1ex
Member
From: Germany
Registered: 2007-02-16
Posts: 91

Re: xmonad Hacking Thread

After using dwm quite some time on my laptop I decided to leave PekWM for a Gnome/Xmonad combination on my desktop.

Works great so far using the standard Gnome config provided.
But I get into trouble when trying to modify it. All templates and examples refer to default config instead of Gnome, so I often break useful things when applying something new.
Where can I get the defaults to work with?

Offline

#133 2009-04-28 22:00:33

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

Re: xmonad Hacking Thread

a1ex: GnomeConfig adds a couple of keybindings to the desktopConfig which in turn is based on defaultConfig:
http://hackage.haskell.org/packages/arc … Gnome.html
http://hackage.haskell.org/packages/arc … sktop.html

When you override say the manageHook, you should probably add it as such:
main = xmonad gnomeConfig { manageHook = myManageHook  <+> manageHook gnomeConfig, ... }

Offline

#134 2009-05-11 19:18:49

McManiaC
Member
Registered: 2009-03-06
Posts: 15

Re: xmonad Hacking Thread

Hey, I changed my xmonad.hs a little bit to have better Xinerama-support with more than one screen.

The xmonad.hs is available at

www.n-sch.de/xmonad/xmonad.hs
http://sprunge.us/ZcNV?hs (remove the ?hs from the url to get rid of the numbers at the beginning)

The whole package with icons and conkytoprc is available at:

www.n-sch.de/xmonad/xmonad.tar


So whats new?

mod + tab does ignore the visible screens and just tabs through the last recent, not visible workspaces
mod + a cycles through the different screens
mod + s swaps the current workspace on the visible screens with those visible on the other screens.

(thats line 377 to 392)

...and a few other workarounds.


I hope you enjoy!


McManiaC

Last edited by McManiaC (2009-05-11 19:20:05)

Offline

#135 2009-05-26 20:51:25

aragats
Member
From: Broomfield, CO
Registered: 2009-05-26
Posts: 30

Re: xmonad Hacking Thread

Hi folks,
How can I configure xmonad to run a program when I switch to a particular workspace?
Example: I want to run a script changing the keyboard layout to "us" unconditionally when I'm on particular workspaces (with ssh, rdesktop etc.).

Thanks for ideas!

Offline

#136 2009-05-27 11:57:19

McManiaC
Member
Registered: 2009-03-06
Posts: 15

Re: xmonad Hacking Thread

Hi!

I guess you could use the EventHook for that, but I'm not that familiar with that X11-lib.
You can also adjust your Key-Settings for the workspace-change. This is what works for me:

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

{- ... -}

    -- mod-[1..9]       , Switch to workspace N
    -- mod-shift-[1..9] , Move client to workspace N, then switch to it
    [ ((m .|. modMask, k), windows (f i) >> spawnMaybe i)
         | (i, k) <- zip (workspaces conf) ([xK_1 .. xK_9] ++ [xK_0])
         , (f, m) <- [(W.greedyView, 0), (liftM2 (.) W.greedyView W.shift, shiftMask)] ]
    ++

{- ... -}

  where spawnMaybe ws
            -- spawn urxvt with name "foo" and application "bar" on workspace 5
            | ws == (workspace conf !! 4) = spawn $ myTerminal ++ " -name foo -e bar"
            | otherwise = return ()

I hope this works, just be a bit carefull with the (!!) operator, since it will cause an error if the index is too big. The index starts at 0, so the first workspace is (workspace conf !! 0) etc... You could also use "runOrRaise" instead of "spawn" to avoid multiple instances of one application (set -name for your terminal when using this with CLI apps!).





McManiaC

Last edited by McManiaC (2009-05-27 12:07:37)

Offline

#137 2009-05-29 04:33:47

aragats
Member
From: Broomfield, CO
Registered: 2009-05-26
Posts: 30

Re: xmonad Hacking Thread

Thanks, McManiaC!

I like your idea. Works fine!

Regarding to X11-libs - I wrote a small program to manipulate keyboard layouts, it works fine for me.
I use with shell script and dzen2 to display a small flag in the status bar. Here is the C code:

// xkb3.c by Sergey Manucharian
// provides X keyboard layout switching between 3 layouts set
// in either in xorg.conf or by setxkbmap
// accept 1, 2 or 3 arguments - integers 0, 1, 2 corresponding to the layouts
// 1 argument - switches to that layout
// 2 arguments - toggles those layouts
// 3 arguments - increments layout by 1 every time or wraps around
// compile:  gcc -Wall -lxkbfile xkb3.c -o xkb3

#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/extensions/XKB.h>
#include <X11/extensions/XKBstr.h>
#define MIN_LAYOUT 0
#define MAX_LAYOUT 2
#define LAYOUT_0   0
#define LAYOUT_1   1
#define LAYOUT_2   2

int main(int argc, char *argv[])
{
   Display *dpy;
   int res;
   XkbStateRec state;
   int layout0, layout1, layout2;
   
   if (argc < 2) {printf("Usage: xkb3 layout0 [layout1]\n"); return(0);}
   
   dpy = XOpenDisplay(NULL);
   if (!dpy) {printf("Can't open display\n"); return(1);}

   res = XkbQueryExtension(dpy, NULL, NULL, NULL, NULL, NULL);
   if (!res) {printf("Can't init XKB\n"); return(1);}

   XkbGetState(dpy, XkbUseCoreKbd, &state);
  
   switch (argc)
   {
     case 2:
       layout0 = atoi(argv[1]);
       if (layout0 < MIN_LAYOUT || layout0 > MAX_LAYOUT) {printf("Argument is not within range of 0...2\n");return(1);}
           XkbLockGroup(dpy, XkbUseCoreKbd, layout0);
       break;
     case 3:
       layout0 = atoi(argv[1]);
       if (layout0 < MIN_LAYOUT || layout0 > MAX_LAYOUT) {printf("Argument #1 is not within range of 0...2\n");return(1);}
       layout1 = atoi(argv[2]);
       if (layout1 < MIN_LAYOUT || layout1 > MAX_LAYOUT) {printf("Argument #2 is not within range of 0...2\n");return(1);}
       switch (state.group)
       {
         case    LAYOUT_0:
           XkbLockGroup(dpy, XkbUseCoreKbd, layout1);
           break;
         case LAYOUT_1:
           XkbLockGroup(dpy, XkbUseCoreKbd, layout0);
           break;
         default:
           XkbLockGroup(dpy, XkbUseCoreKbd, 0);
       }
       break;
     case 4:
       layout0 = atoi(argv[1]);
       if (layout0 < MIN_LAYOUT || layout0 > MAX_LAYOUT) {printf("Argument #1 is not within range of 0...2\n");return(1);}
       layout1 = atoi(argv[2]);
       if (layout1 < MIN_LAYOUT || layout1 > MAX_LAYOUT) {printf("Argument #2 is not within range of 0...2\n");return(1);}
       layout2 = atoi(argv[3]);
       if (layout2 < MIN_LAYOUT || layout2 > MAX_LAYOUT) {printf("Argument #3 is not within range of 0...2\n");return(1);}
          XkbLockGroup(dpy, XkbUseCoreKbd, (state.group + 1)%(MAX_LAYOUT + 1));
     default:
       printf("Too many arguments, will do nothing\n");
   }
   
   XkbGetState(dpy, XkbUseCoreKbd, &state);
   XCloseDisplay(dpy);
   printf("%d\n", state.group); 

   return(0);
}

Cheers
S.M.

Last edited by aragats (2009-05-29 05:10:58)

Offline

#138 2009-05-30 04:58:57

unregistered
Member
Registered: 2008-04-09
Posts: 134

Re: xmonad Hacking Thread

does anyone know what this browser is? Is it totally keyboard friendly and mouse free?
http://arch.har-ikkje.net/gfx/ss/2008-1 … _scrot.png

Offline

#139 2009-05-30 05:13:08

Ashren
Member
From: Denmark
Registered: 2007-06-13
Posts: 1,229
Website

Offline

#140 2009-05-31 07:12:39

unregistered
Member
Registered: 2008-04-09
Posts: 134

Re: xmonad Hacking Thread

any good chm viewer that can be used sole with the keyboard for xmonad to recommend?

Offline

#141 2009-06-08 04:46:43

sw2wolf
Member
From: China
Registered: 2009-06-08
Posts: 99
Website

Re: xmonad Hacking Thread

xmonad+lxpanel

In ~/.xmonad/xmonad.hs
......
myStartupHook = do
spawn "fcitx"
spawn "lxpanel"
......

lxpanel can run normally, however there is only one problem: The Task Bar cannot display the started applications ! Can anybody shed a light on me ?


e^(π⋅i) + 1 = 0

Offline

#142 2009-06-08 22:24:10

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

Re: xmonad Hacking Thread

To display the started applications in lxpanel, you need this extension:

http://xmonad.org/xmonad-docs/xmonad-co … ktops.html

Note that it has changed somewhat since the last release (0.8.1), so beware of the api differences if you use xmonad from darcs.

Offline

#143 2009-06-09 00:13:47

sw2wolf
Member
From: China
Registered: 2009-06-08
Posts: 99
Website

Re: xmonad Hacking Thread

vogt wrote:

To display the started applications in lxpanel, you need this extension:

http://xmonad.org/xmonad-docs/xmonad-co … ktops.html

Note that it has changed somewhat since the last release (0.8.1), so beware of the api differences if you use xmonad from darcs.

thanks ! I will test it later


e^(π⋅i) + 1 = 0

Offline

#144 2009-06-10 00:44:16

sw2wolf
Member
From: China
Registered: 2009-06-08
Posts: 99
Website

Re: xmonad Hacking Thread

Hi, friends
There already is a window on workspace. Now when i start firefox, i want want it appear down the existed window.

[ className =? "Firefox" --> (ask >>= doF . W.swapDown)] doesnot compile.

tbanks!


e^(π⋅i) + 1 = 0

Offline

#145 2009-06-10 01:25:40

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

Re: xmonad Hacking Thread

sw2wolf: See the functions defined in here, which will be in the next release:
http://code.haskell.org/XMonadContrib/X … osition.hs

Offline

#146 2009-06-10 03:43:20

sw2wolf
Member
From: China
Registered: 2009-06-08
Posts: 99
Website

Re: xmonad Hacking Thread

[ className =? "Firefox" --> (ask >>= doF . W.insertUp]  works, however there is no W.insertDown ? So i want use the code you supplied first while waiting for the new release.

thanks !


e^(π⋅i) + 1 = 0

Offline

#147 2009-06-10 12:21:22

unregistered
Member
Registered: 2008-04-09
Posts: 134

Re: xmonad Hacking Thread

Hey guys, here's my current xmonad.hs file, how can I change the default tiling algorithm to say Full or some other algorithm, etc?
oh and how does the tabbed layout behave and look like?

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

main = do
    xmproc <- spawnPipe "xmobar"
    xmonad $ defaultConfig 
        { manageHook = manageDocks <+> manageHook defaultConfig
        , layoutHook = avoidStruts $ layoutHook defaultConfig
        , logHook = dynamicLogWithPP $ xmobarPP
                        { ppOutput = hPutStrLn xmproc
                        , ppTitle = xmobarColor "green" "" . shorten 50
                        }
        , focusedBorderColor = "#00ff00"
        --, modMask = mod4Mask     -- Rebind Mod to the Windows key
        }

Thanks.

Offline

#148 2009-06-10 14:53:17

Nepherte
Member
From: Singapore
Registered: 2008-09-09
Posts: 427

Re: xmonad Hacking Thread

You can do something like this:

tiled = Tall 1 1/2 3/100
myLayout = avoidStruts $ Full ||| tiled ||| Mirror tiled ||| other tiling algorithm

in your main, you should then assign the layoutHook to myLayout:

layoutHook = myLayout

You can toggle between layouts with mod + spacebar if you didn't change the default key for it.

Last edited by Nepherte (2009-06-10 14:54:05)

Offline

#149 2009-06-10 22:54:45

Lexion
Member
Registered: 2008-03-23
Posts: 510

Re: xmonad Hacking Thread

I'm having trouble with XMonad.Actions.FindEmptyWorkspace.  There are no errors, it just doesn't work.  I press 'e' (the key I binded to view the empty workspace) and nothing happens.  Here is my xmonad.hs:

import XMonad
import System.Exit
import XMonad.Layout

import XMonad.Layout.ThreeColumns
import XMonad.Layout.NoBorders
import XMonad.Layout.SimplestFloat

import XMonad.Actions.WindowNavigation
import XMonad.Actions.FindEmptyWorkspace

import XMonad.Layout.Combo
import XMonad.Layout.LayoutCombinators

import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Util.Run (spawnPipe)
import System.IO
import XMonad.Hooks.FadeInactive
import qualified XMonad.StackSet as W
import qualified Data.Map        as M

import XMonad.Config (defaultConfig)

myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
 
    [ ((modm,               xK_Return), spawn "urxvtc")
    , ((modm,               xK_p     ), spawn "bash /home/oliver/.xmonad/dmenu.sh")
    , ((modm .|. shiftMask, xK_c     ), kill)
    , ((modm,               xK_space ), sendMessage NextLayout)
    , ((modm,               xK_n     ), refresh)
    , ((modm .|. shiftMask, xK_Return), windows W.swapMaster)
    , ((modm,               xK_e     ), viewEmptyWorkspace)
    , ((modm .|. shiftMask, xK_e     ), tagToEmptyWorkspace)
    --, ((modm .|. shiftMask, xK_h), sendMessage $ swap L)
    --, ((modm .|. shiftMask, xK_l), sendMessage $ swap R)
    --, ((modm .|. shiftMask, xK_j), sendMessage $ swap D)
    --, ((modm .|. shiftMask, xK_k), sendMessage $ swap U)
    --, ((modm,               xK_w), sendMessage $ go U)
    --, ((modm,               xK_s), sendMessage $ go D)
    --, ((modm,               xK_d), sendMessage $ go R)
    --, ((modm,               xK_a), sendMessage $ go L)
    , ((modm,               xK_minus ), sendMessage Shrink)
    , ((modm,               xK_equal ), sendMessage Expand)
    , ((modm,               xK_b     ), sendMessage ToggleStruts)
    , ((modm,               xK_t     ), withFocused $ windows . W.sink)
    , ((modm              , xK_comma ), sendMessage (IncMasterN 1))
    , ((modm              , xK_period), sendMessage (IncMasterN (-1)))
    , ((modm .|. shiftMask, xK_q     ), io (exitWith ExitSuccess))
    , ((modm              , xK_q     ), restart "xmonad" True)
    ]
    ++
 
        [((m .|. modm, k), windows $ f i) | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9], (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
    ++
 
    [((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)]]
 
 
myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $
 
    [ ((modMask, button1), (\w -> focus w >> mouseMoveWindow w)), 
    ((mod1Mask, button1), (\w -> focus w >> mouseResizeWindow w))]

myLogHook :: Handle -> X ()
myLogHook h = dynamicLogWithPP $ defaultPP {
    ppCurrent    = dzenColor "#6d78ff" "#222222" . pad
    , ppVisible    = dzenColor "#222222" "#111111" . pad
    , ppLayout = \x -> " | ^fg(#bb6667)"
        ++ case x of
            "Tall"     -> "::"
            "Full"     -> "[]"
            "SimplestFloat" -> ".'"
            "combining combining Tall and Tall with Tall and combining Tall and Tall with Tall with Mirror Tall" -> "+:"
            _    -> x
        ++ "^fg(#aaaaaa) "
    , ppHidden    = dzenColor "#6d78ff" "#111111" . pad
    , ppHiddenNoWindows = dzenColor "" "" . pad
    , ppUrgent    = dzenColor "#000000" "#ffffff" . pad
    , ppWsSep    = " "
    , ppSep        = ""
    , ppTitle    = ("" ++) . dzenColor "#0095b9" "#111111" . dzenEscape
    , ppOutput    = hPutStrLn h
    }

main = do
    workspaceBarPipe <- spawnPipe "/usr/bin/dzen2 -ta l -fn -*-fixed-medium-r-*-*-13-*-*-*-*-*-* -bg #222222"    
    config <-withWindowNavigation(xK_k, xK_h, xK_j, xK_l) $ defaults { 
    manageHook = manageDocks <+> manageHook defaults
    , layoutHook = avoidStruts $ layoutHook defaults
    , logHook = myLogHook workspaceBarPipe-- >> fadeInactiveLogHook 0xdddddd
    }
    xmonad config

defaults = defaultConfig {
        focusFollowsMouse  = True,
        borderWidth        = 1,
        modMask            = mod4Mask,
        workspaces         = ["1", "2", "3", "4", "5", "6", "7", "8", "9"],
        normalBorderColor  = "#000000",
        focusedBorderColor = "#86a2be",
        keys               = myKeys,
        mouseBindings      = myMouseBindings,
        layoutHook         = smartBorders $ (twocol XMonad.Layout.||| Full XMonad.Layout.||| ((twocol *|* twocol) */* (twocol *|* twocol))),
        manageHook         = composeAll [],
        logHook            = return (),
        startupHook        = spawn "xsetroot -cursor_name left_ptr"
    }
    where
    twocol = Tall nmaster delta ratio
    nmaster = 1
    ratio = 1/2
    delta = 3/100

Btw, this thread is great!


urxvtc / wmii / zsh / configs / onebluecat.net
Arch will not hold your hand

Offline

#150 2009-06-11 01:31:48

unregistered
Member
Registered: 2008-04-09
Posts: 134

Re: xmonad Hacking Thread

Nepherte wrote:

You can do something like this:

tiled = Tall 1 1/2 3/100
myLayout = avoidStruts $ Full ||| tiled ||| Mirror tiled ||| other tiling algorithm

in your main, you should then assign the layoutHook to myLayout:

layoutHook = myLayout

You can toggle between layouts with mod + spacebar if you didn't change the default key for it.

hey I got a tiled and myLayout not in scope error when trying to compile, any ideas?

here's the config

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

main = do
    xmproc <- spawnPipe "xmobar"
    xmonad $ defaultConfig
        { manageHook = manageDocks <+> manageHook defaultConfig
        , tiled = Tall 1 1/2 3/100
        , myLayout = avoidStruts $ Full ||| Mirror tiled ||| tiled
        , layoutHook = myLayout
        , logHook = dynamicLogWithPP $ xmobarPP
                        { ppOutput = hPutStrLn xmproc
                        , ppTitle = xmobarColor "green" "" . shorten 50
                        }
        , focusedBorderColor = "#00ff00"
        --, modMask = mod4Mask     -- Rebind Mod to the Windows key
        }

Last edited by unregistered (2009-06-11 01:37:59)

Offline

Board footer

Powered by FluxBB