howto switch among WMs

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

howto switch among WMs

#1 Post by MU »

no dotpup, as it is required to tweak some systemfiles.
So only a description, so you can adapt this idea on any pupplett.

WARNING:
remember that you can use "mp filename" to edit files, if X fails to start, when you made a mistake :!:


Edit /usr/X11R7/bin/xwin

around line 17, replace
echo -n "$1" > /etc/windowmanager
with
echo -n "muppywm $1" > /etc/windowmanager

Now create a file (and set it executable!)
/usr/local/bin/muppywm

Code: Select all

#!/bin/ash

$1 &

while [ 1 ]
do

sleep 10000

done
I use "ash" as shell, as it needs less resources than bash.

If you now start X with "xwin jwm", then jwm will not run directly.
Instead, the "endless loop" muppywm is the highest instance that runs.
muppywm now will run jwm as a childprocess.
So if you kill jwm from a rxvt, X will continue to run.

So all we need now, is a grafical tool to kill the running WM, and start another one.
I encountered some timing-problems, so this looks maybe a bit complex.

/usr/local/bin/muppywmchooser

Code: Select all

#!/bin/bash

if [ "$1" == "-restartwm" ];then


	pid=`ps -ax | grep " jwm " |grep -v muppywm|grep -v grep | sed -e "s/^ *//" -e "s/ .*//"`
	if [ "$pid" != "" ];then
		xmessage -bg orange -center -borderless -buttons "" "jwm shuts down, wait......" &
		mpid=$!
		#jwm needs a focus-change to continue, so build and destroy a second dummy-message
		xmessage -bg orange -center -borderless -buttons "" "jwm shuts down, wait......" &
		dpid=$!


		while [ "$pid" != "" ];do 
			pid=`ps -ax | grep " jwm " |grep -v muppywm|grep -v grep | sed -e "s/^ *//" -e "s/ .*//"`
			kill $pid
			kill $dpid
		done
		kill $mpid
	fi

  	icepid=`ps -ax | grep " icewm " |grep -v grep | sed -e "s/^ *//" -e "s/ .*//"`
	kill $icepid
	killall icewmtray

	xmessage -bg orange -center -borderless -buttons "" "rebuilding menus..." &
	pid=$!
	fixmenus
	kill $pid
	wm=`cat /etc/windowmanager | sed "s/^muppywm //"`

	xmessage -timeout 3 -bg orange -center -borderless -buttons "" "starting $wm..." &

	"$wm" &
	exit 0
fi

xmessage -bg orange -center -title "WindowManager" -buttons Icewm:101,jwm:102 Choose your Windowmanager



a=$?

#xmessage $a

if [ "$a" == "101" ];then

	echo "muppywm starticewm">/etc/windowmanager

	#killall icewm
	pid=`ps -ax | grep " icewm " |grep -v grep | sed -e "s/^ *//" -e "s/ .*//"`
	kill $pid
	killall icewmtray

	pid=`ps -ax | grep " jwm " |grep -v muppywm|grep -v grep | sed -e "s/^ *//" -e "s/ .*//"`
	if [ "$pid" != "" ];then
		xmessage -bg orange -center -borderless -buttons "" "jwm shuts down, wait......" &
		mpid=$!
		#jwm needs a focus-change to continue, so build and destroy a second dummy-message
		xmessage -bg orange -center -borderless -buttons "" "jwm shuts down, wait......" &
		dpid=$!


		while [ "$pid" != "" ];do 
			pid=`ps -ax | grep " jwm " |grep -v muppywm|grep -v grep | sed -e "s/^ *//" -e "s/ .*//"`
			kill $pid
			kill $dpid
		done
		kill $mpid
	fi

	xmessage -timeout 3 -bg orange -center -borderless -buttons "" "starting icewm..." &

	starticewm &

	exit 0
fi


if [ "$a" == "102" ];then

	echo "muppywm jwm">/etc/windowmanager

	pid=`ps -ax | grep " icewm " |grep -v grep | sed -e "s/^ *//" -e "s/ .*//"`
	kill $pid
	killall icewmtray

	pid=`ps -ax | grep " jwm " |grep -v muppywm|grep -v grep | sed -e "s/^ *//" -e "s/ .*//"`
	if [ "$pid" != "" ];then
		xmessage -bg orange -center -borderless -buttons "" "jwm shuts down, wait......" &
		mpid=$!
		#jwm needs a focus-change to continue, so build and destroy a second dummy-message
		xmessage -bg orange -center -borderless -buttons "" "jwm shuts down, wait......" &
		dpid=$!


		while [ "$pid" != "" ];do 
			pid=`ps -ax | grep " jwm " |grep -v muppywm|grep -v grep | sed -e "s/^ *//" -e "s/ .*//"`
			kill $pid
			kill $dpid
		done
		kill $mpid
	fi

	xmessage -timeout 3 -bg orange -center -borderless -buttons "" "starting jwm..." &

	sleep 1
	jwm &
	exit 0
fi
If you saved (and made it executable!), you finally must add it to your startmenus.
And you can replace the old "restart wm" entries with new ones, that will run "fixmenus" when you restart one of them.
This could be needed after the installation of a dotpup.
Edit the templates in /etc/xdg/templates, then run "fixmenus" and restart your WM.
for jwm:

Code: Select all

  <Program label="WindowManager" icon="xapp.png">exec muppywmchooser</Program>
 <Program label="Restart JWM" icon="mini-windows.xpm"> muppywmchooser -restartwm</Program>
for icewm:

Code: Select all

	prog "WindowManager" mini-windows muppywmchooser
	restart "Restart IceWM" mini-windows muppywmchooser -restartwm
Now you have a new entry "windowmanager" in jwm and icewm, that displays a dialog with 2 buttons to choose jwm or icewm.
You could enhance it to work with fluxbox and others.

Mark

User avatar
cb88
Posts: 1165
Joined: Mon 29 Jan 2007, 03:12
Location: USA
Contact:

#2 Post by cb88 »

MU have you ever looked at murga lua? there is a script in DSL 4.0 to switch WM and it works quite well...
Taking Puppy Linux to the limit of perfection. meanwhile try "puppy pfix=duct_tape" kernel parem eater.
X86: Sager NP6110 3630QM 16GB ram, Tyan Thunder 2 2x 300Mhz
Sun: SS2 , LX , SS5 , SS10 , SS20 ,Ultra 1, Ultra 10 , T2000
Mac: Platinum Plus, SE/30

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#3 Post by MU »

no, had no look.
But the solution described above works very stable on my system, and can easily be modified, as it is only some shellscripting :)


Mark

User avatar
J-Bob
Posts: 282
Joined: Sun 10 Feb 2008, 00:58
Location: Canada
Contact:

Re: howto switch among WMs

#4 Post by J-Bob »

MU wrote:no dotpup, as it is required to tweak some systemfiles.
So only a description, so you can adapt this idea on any pupplett.

WARNING:
remember that you can use "mp filename" to edit files, if X fails to start, when you made a mistake :!:


Edit /usr/X11R7/bin/xwin

around line 17, replace
echo -n "$1" > /etc/windowmanager
with
echo -n "muppywm $1" > /etc/windowmanager

Now create a file (and set it executable!)
/usr/local/bin/muppywm

Code: Select all

#!/bin/ash

$1 &

while [ 1 ]
do

sleep 10000

done
I use "ash" as shell, as it needs less resources than bash.

If you now start X with "xwin jwm", then jwm will not run directly.
Instead, the "endless loop" muppywm is the highest instance that runs.
muppywm now will run jwm as a childprocess.
So if you kill jwm from a rxvt, X will continue to run.

So all we need now, is a grafical tool to kill the running WM, and start another one.
I encountered some timing-problems, so this looks maybe a bit complex.

/usr/local/bin/muppywmchooser

Code: Select all

#!/bin/bash

if [ "$1" == "-restartwm" ];then


	pid=`ps -ax | grep " jwm " |grep -v muppywm|grep -v grep | sed -e "s/^ *//" -e "s/ .*//"`
	if [ "$pid" != "" ];then
		xmessage -bg orange -center -borderless -buttons "" "jwm shuts down, wait......" &
		mpid=$!
		#jwm needs a focus-change to continue, so build and destroy a second dummy-message
		xmessage -bg orange -center -borderless -buttons "" "jwm shuts down, wait......" &
		dpid=$!


		while [ "$pid" != "" ];do 
			pid=`ps -ax | grep " jwm " |grep -v muppywm|grep -v grep | sed -e "s/^ *//" -e "s/ .*//"`
			kill $pid
			kill $dpid
		done
		kill $mpid
	fi

  	icepid=`ps -ax | grep " icewm " |grep -v grep | sed -e "s/^ *//" -e "s/ .*//"`
	kill $icepid
	killall icewmtray

	xmessage -bg orange -center -borderless -buttons "" "rebuilding menus..." &
	pid=$!
	fixmenus
	kill $pid
	wm=`cat /etc/windowmanager | sed "s/^muppywm //"`

	xmessage -timeout 3 -bg orange -center -borderless -buttons "" "starting $wm..." &

	"$wm" &
	exit 0
fi

xmessage -bg orange -center -title "WindowManager" -buttons Icewm:101,jwm:102 Choose your Windowmanager



a=$?

#xmessage $a

if [ "$a" == "101" ];then

	echo "muppywm starticewm">/etc/windowmanager

	#killall icewm
	pid=`ps -ax | grep " icewm " |grep -v grep | sed -e "s/^ *//" -e "s/ .*//"`
	kill $pid
	killall icewmtray

	pid=`ps -ax | grep " jwm " |grep -v muppywm|grep -v grep | sed -e "s/^ *//" -e "s/ .*//"`
	if [ "$pid" != "" ];then
		xmessage -bg orange -center -borderless -buttons "" "jwm shuts down, wait......" &
		mpid=$!
		#jwm needs a focus-change to continue, so build and destroy a second dummy-message
		xmessage -bg orange -center -borderless -buttons "" "jwm shuts down, wait......" &
		dpid=$!


		while [ "$pid" != "" ];do 
			pid=`ps -ax | grep " jwm " |grep -v muppywm|grep -v grep | sed -e "s/^ *//" -e "s/ .*//"`
			kill $pid
			kill $dpid
		done
		kill $mpid
	fi

	xmessage -timeout 3 -bg orange -center -borderless -buttons "" "starting icewm..." &

	starticewm &

	exit 0
fi


if [ "$a" == "102" ];then

	echo "muppywm jwm">/etc/windowmanager

	pid=`ps -ax | grep " icewm " |grep -v grep | sed -e "s/^ *//" -e "s/ .*//"`
	kill $pid
	killall icewmtray

	pid=`ps -ax | grep " jwm " |grep -v muppywm|grep -v grep | sed -e "s/^ *//" -e "s/ .*//"`
	if [ "$pid" != "" ];then
		xmessage -bg orange -center -borderless -buttons "" "jwm shuts down, wait......" &
		mpid=$!
		#jwm needs a focus-change to continue, so build and destroy a second dummy-message
		xmessage -bg orange -center -borderless -buttons "" "jwm shuts down, wait......" &
		dpid=$!


		while [ "$pid" != "" ];do 
			pid=`ps -ax | grep " jwm " |grep -v muppywm|grep -v grep | sed -e "s/^ *//" -e "s/ .*//"`
			kill $pid
			kill $dpid
		done
		kill $mpid
	fi

	xmessage -timeout 3 -bg orange -center -borderless -buttons "" "starting jwm..." &

	sleep 1
	jwm &
	exit 0
fi
If you saved (and made it executable!), you finally must add it to your startmenus.
And you can replace the old "restart wm" entries with new ones, that will run "fixmenus" when you restart one of them.
This could be needed after the installation of a dotpup.
Edit the templates in /etc/xdg/templates, then run "fixmenus" and restart your WM.
for jwm:

Code: Select all

  <Program label="WindowManager" icon="xapp.png">exec muppywmchooser</Program>
 <Program label="Restart JWM" icon="mini-windows.xpm"> muppywmchooser -restartwm</Program>
for icewm:

Code: Select all

	prog "WindowManager" mini-windows muppywmchooser
	restart "Restart IceWM" mini-windows muppywmchooser -restartwm
Now you have a new entry "windowmanager" in jwm and icewm, that displays a dialog with 2 buttons to choose jwm or icewm.
You could enhance it to work with fluxbox and others.

Mark
Just in case you are wondering, Mark. I plan to add this to the second milestone 3.03CE, also called the second collective alpha for 3.10CE

I might do a bit of tweaking to add a bit of "Puppy" branding to it, but i don't see that being a problem.

Post Reply