You are not logged in.

#1 2008-01-21 20:41:32

gazj
Member
From: /home/gazj -> /uk/cambs
Registered: 2007-02-09
Posts: 681
Website

[Solved] Switching wm's without restarting X

I know some window manager's have the --replace option, unfortunately fluxbox and awesome don't.  I am looking for a way to switch between wm's without losing my X session.  If i kill the first wm (awesome in this case) X will fall before I can start another.  Any ideas on how (if) this can be done.  This is what my .xinitrc currently looks like. smile

#set PATH here as gdm does not pass it in .bashrc (needed for dmenu)
export PATH=$PATH:/home/gary/.bin

#set background before wm starts
eval ~/.fehbg &

#start window manager and store pid
awesome & wmpid=$!

#start some programs
urxvt &
urxvt &
urxvt &
rox &
rox &
rox &
pidgin &
firefox &
awesomebar &

# wait for window manager to exit
wait $wmpid

#tidy up, I hate storing crap
rm -Rv ~/.thumbnails

Thanks Guys smile

Last edited by gazj (2008-01-22 18:01:25)

Offline

#2 2008-01-21 21:05:37

Gilneas
Member
From: Netherlands
Registered: 2006-10-22
Posts: 320

Re: [Solved] Switching wm's without restarting X

Won't something like killall awesome && setsid fluxbox do?

Or does the problem lie in that Xorg closes when there are no more windows?
You can start it with "-noreset" to counter that.

Offline

#3 2008-01-21 21:21:49

synorgy
Member
From: $HOME
Registered: 2005-07-11
Posts: 272
Website

Re: [Solved] Switching wm's without restarting X

Why not use SelectWM? My .xinitrc looks like this:

exec numlockx &
ivman &
nitrogen --restore &
#xbindkeys &
selectwm

selectwm lets you choose what WM you want to start when you run it. So you pick what you want when X starts, but you can also have it run when the WM quits, meaning you could easily switch between any WM you have installed.

Hope this helps.


"Unix is basically a simple operating system, but you have to be a genius to understand the simplicity." (Dennis Ritchie)

Offline

#4 2008-01-21 22:57:19

gazj
Member
From: /home/gazj -> /uk/cambs
Registered: 2007-02-09
Posts: 681
Website

Re: [Solved] Switching wm's without restarting X

Won't something like killall awesome && setsid fluxbox do?

Unfortunately when awesome dies X reaches the end of .xinitrc and falls down.

selectwm lets you choose what WM you want to start when you run it. So you pick what you want when X starts, but you can also have it run when the WM quits, meaning you could easily switch between any WM you have installed.

This is a nifty little app that I will defintely remember for future.  Although what I am trying to achieve is to switch window manager's while leaving my apps all open.  This should in theory be possible as long as you keep X up, a window manager is just another program like any other.

Thank you both for you ideas though. smile

Offline

#5 2008-01-21 23:03:44

rson451
Member
From: Annapolis, MD USA
Registered: 2007-04-15
Posts: 1,233
Website

Re: [Solved] Switching wm's without restarting X

something like

while true
do
   selectwm
done

in your .xinitrc maybe? i'm not sure how selectwm works.


archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson

Offline

#6 2008-01-21 23:10:05

gazj
Member
From: /home/gazj -> /uk/cambs
Registered: 2007-02-09
Posts: 681
Website

Re: [Solved] Switching wm's without restarting X

Ok got it, although the method used is not very elegant.

The program awesomebar is just a bash script that puts some information into the awesome-client buffer.  So I can have it running for my whole x session and I won't even notice that it is there regardless of my window manager.  So I started awesome as a normal program adding an '&' and then stored the pid of awesomebar as I was doing for my window manager.  My xinitrc now looks like this.

#set PATH here as gdm does not pass it in .bashrc (needed for dmenu)
export PATH=$PATH:/home/gary/.bin

#set background before wm starts
eval ~/.fehbg &

#start window manager and store pid (not wm anymore so I can swap wm's without losing X)
awesomebar & wmpid=$!

#start some programs
urxvt &
urxvt &
urxvt &
rox &
rox &
rox &
pidgin &
firefox &
awesome &

# wait for window manager to exit
wait $wmpid

#tidy up, I hate crap
rm -Rv ~/.thumbnails

I can now run or keybind "killall awesome && fluxbox" and the wm will change.  Like I said it's not elegant but works.  Any better solution would be appreciated.

Another problem now is, that fluxbox will only pickup windows in my active tag in awesome, so I have to move all windows to a single tag before changing wm's.  Any ideas anyone?  Any awesome command that will pull all windows to the desired tag before I leave awesome?

Many thanks peeps

Last edited by gazj (2008-01-22 00:24:33)

Offline

#7 2008-01-21 23:20:57

gazj
Member
From: /home/gazj -> /uk/cambs
Registered: 2007-02-09
Posts: 681
Website

Re: [Solved] Switching wm's without restarting X

rson451 wrote:

something like

while true
do
   selectwm
done

in your .xinitrc maybe? i'm not sure how selectwm works.

Unortunately that won't work with selectwm.  Selectwm gives you a gui choice of wm's, then runs your wm for you.  When your wm exits you return to the menu.  If you call the menu while your wm is running it won't run another wm because another one from the first session is already running. 

When you leave your window manager you return to the selection gui you would normally then click exit (then x would finish).  The loop above would make the gui reappear everytime you clicked exit.

I hope those last 2 paragraph's make sense :s

I totally understand where your idea was coming from though smile

Offline

#8 2008-01-21 23:37:52

rson451
Member
From: Annapolis, MD USA
Registered: 2007-04-15
Posts: 1,233
Website

Re: [Solved] Switching wm's without restarting X

gotcha, selectwm makes the loop redundant. smile i may try that out on my desktop (once the new dwm comes out with xinerama yummy)


archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson

Offline

#9 2008-01-21 23:42:05

gazj
Member
From: /home/gazj -> /uk/cambs
Registered: 2007-02-09
Posts: 681
Website

Re: [Solved] Switching wm's without restarting X

Yeah, why didn't I just say that big_smile

Offline

#10 2008-01-22 00:40:56

finferflu
Forum Fellow
From: Manchester, UK
Registered: 2007-06-21
Posts: 1,899
Website

Re: [Solved] Switching wm's without restarting X

heh, that's the very reason that made me switch from Xmonad to Ratpoison (since Ratpoison has an option called "tmpwm" which allows me to run another window manager on top of it). So I look forward to see if there is any solution for other window managers. Perhaps the key is that of running them on top of each other, like Ratpoison does...

Last edited by finferflu (2008-01-22 00:41:33)


Have you Syued today?
Free music for free people! | Earthlings

"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- A. de Saint-Exupery

Offline

#11 2008-01-22 01:21:04

gazj
Member
From: /home/gazj -> /uk/cambs
Registered: 2007-02-09
Posts: 681
Website

Re: [Solved] Switching wm's without restarting X

Well I am getting closer, the last solution caused some problems with the window manager's not exiting in a normal status.  I have changed .xinitrc again.

#set PATH here as gdm does not pass it in .bashrc (needed for dmenu)
export PATH=$PATH:/home/gary/.bin

#set background before wm starts
eval ~/.fehbg &

#start window manager and store pid
awesomebar & wmpid=$!

#start some programs
urxvt &
urxvt &
urxvt &
rox &
rox &
rox &
pidgin &
firefox &

# when one window manager exits start the next, finally quit when awesomebar is killed
while true
do
   awesome
   fluxbox
   done

#tidy up, I hate crap
rm -Rv ~/.thumbnails

Then what I have done is bound the key Mod4+Shift+w on each window manager to there exit command.  This way they exit gracefully and the next wm starts (and it fixed my above problem of fluxbox not taking over all of awesome's windows wink )

I have bound the exit keys / menu's on the window manager to kill the awesomebar.  All I need now is someone with more knowledge than me to tell me how to get the while loop to monitor this process.

Then all should work really well.  I would recommend giving it a try finferflu smile

Last edited by gazj (2008-01-22 01:37:06)

Offline

#12 2008-01-22 12:38:49

Gilneas
Member
From: Netherlands
Registered: 2006-10-22
Posts: 320

Re: [Solved] Switching wm's without restarting X

maybe

while [ -n $(pgrep awesomebar) ]; do ...; done

You'll still have to go through one rotation though.

Offline

#13 2008-01-22 18:00:21

gazj
Member
From: /home/gazj -> /uk/cambs
Registered: 2007-02-09
Posts: 681
Website

Re: [Solved] Switching wm's without restarting X

Ok I have got it.

I have changed .xinitrc almost to how it was originally, but now instead of calling a window manager, I call a script called wmrotate.  When I want to leave X i kill wmrotate.

.xinitrc

#set PATH here as gdm does not pass it in .bashrc (needed for dmenu)
export PATH=$PATH:/home/gary/.bin

#set background before wm starts
eval ~/.fehbg &

#start window manager rotater script
wmrotate & wmpid=$!

#start some programs
awesomebar &
urxvt &
urxvt &
urxvt &
rox &
rox &
rox &
pidgin &
firefox &

# close x when wmrotate comes down
wait $wmpid

#tidy up, I hate crap
rm -Rv ~/.thumbnails

and wmrotate

#!/bin/sh
while true
do
   awesome
   fluxbox
done

Got there in the end smile Thanks for all your help

Offline

#14 2008-01-22 19:12:41

finferflu
Forum Fellow
From: Manchester, UK
Registered: 2007-06-21
Posts: 1,899
Website

Re: [Solved] Switching wm's without restarting X

So, in this way do you run two window managers at the same time all the time?


Have you Syued today?
Free music for free people! | Earthlings

"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- A. de Saint-Exupery

Offline

#15 2008-01-22 20:15:47

gazj
Member
From: /home/gazj -> /uk/cambs
Registered: 2007-02-09
Posts: 681
Website

Re: [Solved] Switching wm's without restarting X

Not at the same time, as soon as one window manager exits the next one starts.  But becuase X does not close your windows stay open between window manager changes wink

So when I hit mod4+shift+w awesome lets go of my windows and fluxbox picks them up, another mod4+shift+w fluxbox lets go and awesome picks them back up again.

Last edited by gazj (2008-01-22 20:17:30)

Offline

#16 2008-01-22 20:18:30

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

Re: [Solved] Switching wm's without restarting X

I always switch from fluxbox to anything else (if I ever switch at all).
Always worked, fluxbox even has this submenu to aid you as such...


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

Offline

#17 2023-06-08 18:22:13

Digit
Member
Registered: 2008-04-28
Posts: 71

Re: [Solved] Switching wm's without restarting X

Excuse the necro-bump, but, even after all this time, I, and others, still reference this thread / post ( https://bbs.archlinux.org/viewtopic.php … 76#p320776 ), and so perhaps it serves to point out, this also exists now:

https://wiki.archlinux.org/title/Xinit# … w_managers

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

(^ Which at time of writing, has the following method:

4.5 Switching between desktop environments/window managers

If you are frequently switching between different desktop environments or window managers, it is convenient to either use a display manager or expand ~/.xinitrc to make the switching possible.

The following example shows how to start a particular desktop environment or window manager with an argument:

~/.xinitrc

...

# Here Xfce is kept as default
session=${1:-xfce}

case $session in
    i3|i3wm           ) exec i3;;
    kde               ) exec startplasma-x11;;
    xfce|xfce4        ) exec startxfce4;;
    # No known session, try to run it as command
    *                 ) exec $1;;
esac

To pass the argument session:

$ xinit session

or

$ startx ~/.xinitrc session

)

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

ps, I've been using the method developed in this thread for years.  Thanks gazj.


fave quote of the mo': "Man's reach should exceed his grasp, else what's a heaven for." - Robert Browning

Offline

#18 2023-06-08 18:27:45

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,728

Re: [Solved] Switching wm's without restarting X

Closing this old topic -- maybe just update your references to the wiki where this stuff can be maintained properly.

Offline

Board footer

Powered by FluxBB