[Xmonad] Dynamically reloading Config

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

[Xmonad] Dynamically reloading Config

Bas van Dijk-2
Hello,

Is it possible to dynamically reload the Config?

In a previous thread dons mentioned mod-ctrl-shift-q which calls
'restart' which exec()s itself. However when I do that xmonad closes
and I'm back at my xdm prompt.

Maybe that has to do with my ~/.xsession:

#!/bin/bash
xsetroot -gray                        &
Esetroot ~/pictures/lastlight1280.jpg &
firefox http://mail.google.com/mail &
/home/bas/bin/xmonad

Bas van Dijk

P.S.
What about using hs-plugins for dynamic configurations?
Reply | Threaded
Open this post in threaded view
|

[Xmonad] Dynamically reloading Config

Donald Bruce Stewart
v.dijk.bas:
> Hello,
>
> Is it possible to dynamically reload the Config?
>
> In a previous thread dons mentioned mod-ctrl-shift-q which calls
> 'restart' which exec()s itself. However when I do that xmonad closes
> and I'm back at my xdm prompt.

Hmm. You should you didn't 'quit' instead of 'restart'?

mod-shift-q == quit, back to xdm
mod-shift-q-ctrl == restart, fork the xmonad binary again.

If the latter doesn't work, its a bug report you need to write :-)

> Maybe that has to do with my ~/.xsession:
>
> #!/bin/bash
> xsetroot -gray                        &
> Esetroot ~/pictures/lastlight1280.jpg &
> firefox http://mail.google.com/mail &
> /home/bas/bin/xmonad

The last line should be:  
    exec /home/bas/bin/xmonad
I think.

-- Don
Reply | Threaded
Open this post in threaded view
|

[Xmonad] Dynamically reloading Config

Donald Bruce Stewart
In reply to this post by Bas van Dijk-2
v.dijk.bas:

> Hello,
>
> Is it possible to dynamically reload the Config?
>
> In a previous thread dons mentioned mod-ctrl-shift-q which calls
> 'restart' which exec()s itself. However when I do that xmonad closes
> and I'm back at my xdm prompt.
>
> Maybe that has to do with my ~/.xsession:
>
> #!/bin/bash
> xsetroot -gray                        &
> Esetroot ~/pictures/lastlight1280.jpg &
> firefox http://mail.google.com/mail &
> /home/bas/bin/xmonad
>
> Bas van Dijk
>
> P.S.
> What about using hs-plugins for dynamic configurations?

Too heavyweight for little xmonad, in my opinion (and sjanssen's).

-- Don
Reply | Threaded
Open this post in threaded view
|

[Xmonad] Dynamically reloading Config

Bas van Dijk-2
In reply to this post by Donald Bruce Stewart
On 4/13/07, Donald Bruce Stewart <[hidden email]> wrote:

> v.dijk.bas:
> > Hello,
> >
> > Is it possible to dynamically reload the Config?
> >
> > In a previous thread dons mentioned mod-ctrl-shift-q which calls
> > 'restart' which exec()s itself. However when I do that xmonad closes
> > and I'm back at my xdm prompt.
>
> Hmm. You should you didn't 'quit' instead of 'restart'?
>
> mod-shift-q == quit, back to xdm
> mod-shift-q-ctrl == restart, fork the xmonad binary again.
>
> If the latter doesn't work, its a bug report you need to write :-)
>
> > Maybe that has to do with my ~/.xsession:
> >
> > #!/bin/bash
> > xsetroot -gray                        &
> > Esetroot ~/pictures/lastlight1280.jpg &
> > firefox http://mail.google.com/mail &
> > /home/bas/bin/xmonad
>
> The last line should be:
>     exec /home/bas/bin/xmonad
> I think.
>
> -- Don
>

Even if I change the last line of my ~/.xsession to 'exec
/home/bas/bin/xmonad' then xmonad still closes after mod-shift-q-ctrl.

What information is helpful in finding this bug? For starters here's
my Config.hs:

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

-----------------------------------------------------------------------------
-- |
-- Module      :  Config.hs
-- Copyright   :  (c) Spencer Janssen 2007
-- License     :  BSD3-style (see LICENSE)
--
-- Maintainer  :  [hidden email]
-- Stability   :  stable
-- Portability :  portable
--
-----------------------------------------------------------------------------

module Config where

--
-- xmonad bindings follow mostly the dwm/wmii conventions:
--
--     key combination         action
--
--     mod-shift-return        new xterm
--     mod-p                   launch dmenu
--     mod-shift-p             launch gmrun
--
--     mod-space               switch tiling mode
--
--     mod-tab                 raise next window in stack
--     mod-j
--     mod-k
--
--     mod-h                   resize currently focused window
--     mod-l
--
--     mod-shift-c             kill client
--     mod-shift-q             exit window manager
--     mod-shift-ctrl-q        restart window manager
--
--     mod-return              cycle the current tiling order
--
--     mod-1..9                switch to workspace N
--     mod-shift-1..9          move client to workspace N
--
--     mod-w,e,r               switch to physical/Xinerama screen 1, 2 or 3.
--
-- xmonad places each window into a "workspace." Each workspace can have
-- any number of windows, which you can cycle though with mod-j and mod-k.
-- Windows are either displayed full screen, tiled horizontally, or tiled
-- vertically. You can toggle the layout mode with mod-space, which will
-- cycle through the available modes.
--
-- You can switch to workspace N with mod-N. For example, to switch to
-- workspace 5, you would press mod-5. Similarly, you can move the current
-- window to another workspace with mod-shift-N.
--
-- When running with multiple monitors (Xinerama), each screen has exactly
-- 1 workspace visible. When xmonad starts, workspace 1 is on screen 1,
-- workspace 2 is on screen 2, etc. If you switch to a workspace which is
-- currently visible on another screen, xmonad simply switches focus to
-- that screen. If you switch to a workspace which is *not* visible, xmonad
-- replaces the workspace on the *current* screen with the workspace you
-- selected.
--
-- For example, if you have the following configuration:
--
-- Screen 1: Workspace 2
-- Screen 2: Workspace 5 (current workspace)
--
-- and you wanted to view workspace 7 on screen 1, you would press:
--
-- mod-2 (to select workspace 2, and make screen 1 the current screen)
-- mod-7 (to select workspace 7)
--
-- Since switching to the workspace currently visible on a given screen is
-- such a common operation, shortcuts are provided: mod-{w,e,r} switch to
-- the workspace currently visible on screens 1, 2, and 3 respectively.
-- Likewise, shift-mod-{w,e,r} moves the current window to the workspace on
-- that screen.  Using these keys, the above example would become mod-w
-- mod-7.
--

import Data.Ratio
import Data.Bits
import qualified Data.Map as M
import System.Exit
import Graphics.X11.Xlib
import XMonad
import Operations

-- The number of workspaces:
workspaces :: Int
workspaces = 9

-- modMask lets you easily change which modkey you use. The default is mod1Mask
-- ("left alt").  You may also consider using mod3mask ("right alt"), which
-- does not conflict with emacs keybindings.
modMask :: KeyMask
modMask = mod1Mask
-- modMask = 115 -- Windows start button
-- modMask = xK_Meta_L

-- How much to change the horizontal/vertical split bar by defalut.
defaultDelta :: Rational
defaultDelta = 3%100

-- How much to change the size of a tiled window, by default.
sizeDelta :: Rational
sizeDelta = 3%100

-- The mask for the numlock key. You may need to change this on some systems.
numlockMask :: KeyMask
numlockMask = lockMask

-- What layout to start in, and what the default proportion for the
-- left pane should be in the tiled layout.  See LayoutDesc and
-- friends in XMonad.hs for options.
startingLayoutDesc :: LayoutDesc
startingLayoutDesc =
    LayoutDesc { layoutType   = Full
               , tileFraction = 1%2  }

-- The keys list.
keys :: M.Map (KeyMask, KeySym) (X ())
keys = M.fromList $
    [ ((modMask .|. shiftMask, xK_Return), spawn "Eterm --buttonbar=0
--trans --shade=60 --tint=blue -v -f white")
    , ((modMask,               xK_p     ), spawn "exe=`dmenu_path |
dmenu` && exec $exe")
    , ((modMask .|. shiftMask, xK_p     ), spawn "gmrun")
    , ((modMask,               xK_space ), switchLayout)

    , ((modMask,               xK_Tab   ), raise GT)
    , ((modMask,               xK_j     ), raise GT)
    , ((modMask,               xK_k     ), raise LT)

    , ((modMask,               xK_h     ), changeSplit (negate defaultDelta))
    , ((modMask,               xK_l     ), changeSplit defaultDelta)

    , ((modMask .|. shiftMask, xK_c     ), kill)

    , ((modMask .|. shiftMask, xK_q                     ), io $
exitWith ExitSuccess)
    , ((modMask .|. shiftMask .|. controlMask, xK_q     ), io restart)

    -- Cycle the current tiling order
    , ((modMask,               xK_Return), promote)

    ] ++
    -- Keybindings to get to each workspace:
    [((m .|. modMask, xK_0 + fromIntegral i), f (fromIntegral (pred
i))) -- index from 0.
        | i <- [1 .. workspaces]
        , (f, m) <- [(view, 0), (tag, shiftMask)]]

    -- Keybindings to each screen :
    -- mod-wer (underneath 123) switches to physical/Xinerama screens 1 2 and 3
    ++
    [((m .|. modMask, key), screenWorkspace sc >>= f)
        | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
        , (f, m) <- [(view, 0), (tag, shiftMask)]]

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

Bas van Dijk
Reply | Threaded
Open this post in threaded view
|

[Xmonad] Dynamically reloading Config

Bas van Dijk-2
In reply to this post by Donald Bruce Stewart
On 4/13/07, Donald Bruce Stewart <[hidden email]> wrote:
> > What about using hs-plugins for dynamic configurations?
>
> Too heavyweight for little xmonad, in my opinion (and sjanssen's).

I have no experience with hs-plugins but why do you consider it
heavyweight for xmonad? Is it the dependency on hs-plugins or is it
the (large?) run-time memory and cpu usage of hs-plugins?

Bas van Dijk.
Reply | Threaded
Open this post in threaded view
|

[Xmonad] Dynamically reloading Config

Donald Bruce Stewart
v.dijk.bas:
> On 4/13/07, Donald Bruce Stewart <[hidden email]> wrote:
> >> What about using hs-plugins for dynamic configurations?
> >
> >Too heavyweight for little xmonad, in my opinion (and sjanssen's).
>
> I have no experience with hs-plugins but why do you consider it
> heavyweight for xmonad? Is it the dependency on hs-plugins or is it
> the (large?) run-time memory and cpu usage of hs-plugins?

Just the dependency: its a big ugly library (and I'm the author ;)

-- Don
Reply | Threaded
Open this post in threaded view
|

[Xmonad] Dynamically reloading Config

Alec Berryman
In reply to this post by Bas van Dijk-2
Bas van Dijk on 2007-04-13 13:03:20 +0200:

>  In a previous thread dons mentioned mod-ctrl-shift-q which calls
>  'restart' which exec()s itself. However when I do that xmonad closes
>  and I'm back at my xdm prompt.
>
>  Maybe that has to do with my ~/.xsession:
>
>  #!/bin/bash
>  xsetroot -gray                        &
>  Esetroot ~/pictures/lastlight1280.jpg &
>  firefox http://mail.google.com/mail &
>  /home/bas/bin/xmonad

It sounds like /home/bas/bin is not in your $PATH.  The restart key
calls 'xmonad', not the same file that was originally executed.

The default shell on my system is not bash, so .xsession doesn't pick up
my local paths (sourced out of ~/.bash_profile or ~/.bashrc).  I have
something like this at the end of my ~/.xsession:

exec bash -l -c 'xmonad'
Reply | Threaded
Open this post in threaded view
|

[Xmonad] Dynamically reloading Config

Bas van Dijk-2
On 4/13/07, Alec Berryman <[hidden email]> wrote:
> ...
> It sounds like /home/bas/bin is not in your $PATH.  The restart key
> calls 'xmonad', not the same file that was originally executed.
>
> The default shell on my system is not bash, so .xsession doesn't pick up
> my local paths (sourced out of ~/.bash_profile or ~/.bashrc).  I have
> something like this at the end of my ~/.xsession:
>
> exec bash -l -c 'xmonad'

Yes, I think that's the problem. However If I put:

  exec bash -l -c 'xmonad'

in my .xsession then after login I immediately jump back to xdm.
Presumably because xmonad can't be found. If I put:

   exec bash -l -c '/home/bas/bin/xmonad'

then xmonad will start up but the mod-ctrl-shift-q will still bring me
back to xdm.

Note that I have the following in .bashrc:

export PATH=$HOME/bin:$PATH

Bas van Dijk
Reply | Threaded
Open this post in threaded view
|

[Xmonad] Dynamically reloading Config

Alec Berryman
Bas van Dijk on 2007-04-13 15:09:26 +0200:

> On 4/13/07, Alec Berryman <[hidden email]> wrote:
> >...
> >It sounds like /home/bas/bin is not in your $PATH.  The restart key
> >calls 'xmonad', not the same file that was originally executed.
> >
> >The default shell on my system is not bash, so .xsession doesn't pick up
> >my local paths (sourced out of ~/.bash_profile or ~/.bashrc).  I have
> >something like this at the end of my ~/.xsession:
> >
> >exec bash -l -c 'xmonad'
>
> Yes, I think that's the problem. However If I put:
>
>  exec bash -l -c 'xmonad'
>
> in my .xsession then after login I immediately jump back to xdm.
> Presumably because xmonad can't be found. If I put:
>
>   exec bash -l -c '/home/bas/bin/xmonad'
>
> then xmonad will start up but the mod-ctrl-shift-q will still bring me
> back to xdm.
>
> Note that I have the following in .bashrc:
>
> export PATH=$HOME/bin:$PATH

I passed the -l flag to make it a login shell to force bash to read my
~/.bash_profile, which sources ~/.bashrc, which has the PATH information.  I
couldn't get it to work without the -l, and presumably you won't be able to get
it to work without that PATH line in or sourced by your ~/.bash_login.

I always have to look at the bash man page when dealing with stuff like
this.