LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   switching DE/WM without killing X (https://www.linuxquestions.org/questions/linux-newbie-8/switching-de-wm-without-killing-x-865606/)

InvRa 02-28-2011 07:48 PM

switching DE/WM without killing X
 
hello guys i have been using fluxbox and openbox in slackware and i have seen that the fluxbox menu by default it has a menu entry that lets tyou switch from fluxbox to openbox,twm,kde and so on with a simple click. i was wondering if there is a way of adding an option like that in openbox menu. the flusbox menu entryes for switching WM/DE look like this:
Code:

[submenu] (Window Managers)
      [restart] (openbox) {openbox-session}
      [restart] (mwm) {mwm}
      [restart] (twm) {twm}
      [restart] (compiz) {compiz}
      [restart] (kde) {startkde}
      [restart] (fvwm) {fvwm}
      [restart] (xfce4) {startxfce4}
      [restart] (fvwm2) {fvwm2}
      [restart] (blackbox) {blackbox}
      [restart] (windowmaker) {wmaker}
[end]


Mol_Bolom 02-28-2011 10:22 PM

Looks like it is possible. Have a look at openbox's wiki.
Restart section of Openbox's wiki.
Code:

Restart
Restarts Openbox. This starts a new copy of Openbox, and can be used to upgrade to a newly installed version without logging out of your X session. It can also be used to start another window manager.
Option        Default Value        Description
<command>        ""        A string which is the command to be executed as the new window manager, along with any arguments to be passed to it.
Example:
<keybind key="W-F12">
  <action name="Restart"/>
</keybind>
<keybind key="W-F11">
  <action name="Restart"><command>firebox</command></action>
</keybind>


InvRa 03-01-2011 09:40 AM

so to start another WM like fluxbox from openbox? what would the command be

Mol_Bolom 03-01-2011 01:56 PM

Quote:

Originally Posted by MystKid (Post 4275235)
so to start another WM like fluxbox from openbox? what would the command be

Note the next line from your first post.

Code:

    [restart] (twm) {twm}
Now look at the Openbox configure lines.

Code:

<keybind key="W-F11">
  <action name="Restart"><command>firebox</command></action>
</keybind>

So adding a window manager in a menu would be basically the same.

Code:

<menu>
    <item label="Menu item name here">
          <action name="Restart"><command>window manager program name here</command></action>
    </item>
</menu>

I'll test it on my openbox and report back here.
<Edit> Yep, that's it. Just add something like that into the menu xml file in ~/.config/openbox, or wherever else your configurations might be.

InvRa 03-01-2011 02:48 PM

<item label="FluxBox">
<action name="Restart">
<command>
fluxbox
</command>
</action>
this is what i tryed and nothing happens when i click on it

InvRa 03-01-2011 02:55 PM

<menu>
<item label="fluxbox">
<action name="Restart"><command>fluxbox</command></action>
</item>
</menu>
both of these didnt work

Mol_Bolom 03-01-2011 09:02 PM

Huh. Odd. I tried it with...
Code:

<item label="Start Echinus Window Manager">
        <action name="Restart">
                <command>echinus</command>
        </action>
</item>

Just before the Reconfigure men item.

Try adding the path and see if that works. For Slackware on my system it would be something like...

Code:

<item label="Start Echinus Window Manager">
        <action name="Restart">
                <command>/usr/bin/fluxbox</command>
        </action>
</item>

If that doesn't work, then try to give me some more information, such as where your menu.xml file is located, if the console shows any errors ( Most systems that's CTL+ALT+F1 ), if there is a menu item for Fluxbox, version of openbox your using, or any other information you can think of that might be helpful.

InvRa 03-02-2011 10:55 AM

ok i have tryed that and it actually loads fluxbox but it loads it on top of openbox so i still have the openbox tint2 panel loaded.

Mol_Bolom 03-02-2011 11:25 AM

Quote:

Originally Posted by MystKid (Post 4276509)
ok i have tryed that and it actually loads fluxbox but it loads it on top of openbox so i still have the openbox tint2 panel loaded.

Yeah, I noticed this as well last night when I opened openbox before shutting down the computer.

Might be possible to run a script instead. One that would kill tint2's process.

Code:

# kill $(ps -C tint2 -o pid=)
Though, I am not a guru when it comes to "kill", so you might use "ps -C tint2" in a terminal a few times to make sure it only prints tint2's information. If it does, then a simple script could be written to kill tint2 and run fluxbox. Going to try a couple of things myself and see what happens...

Mol_Bolom 03-02-2011 11:55 AM

Ok, I wrote a script for only killing the process (using lxpanel rather than tint2, but I'm sure it should work as well). Then I added in two commands instead of only one.

Code:

<item label="Start Echinus Window Manager">
        <action name="Execute">
                <command>sh ~/scripts/killit.sh lxpanel</command>
        </action>
        <action name="Restart">
                <command>echinus</command>
        </action>
</item>

The first <action> runs the command sh with arguments "~/scripts/killit.sh" and "lxpanel", which will kill lxpanel.
The second <action> then exits openbox and restarts into echinus.

Here's the script I wrote. (Again, I'm no expert with kill and ps, so be sure to read and understand the man pages before attempting this.
If anyone who is experienced with running ps and kill in this way and happens to be reading this, please chime in with some helpful hints).

Code:

#!/bin/bash

if [ "$1" = "" ]
then
        echo "Can not do\n"
else
        PROCESS=$(ps -C $1 -o pid=)
        if [ "$PROCESS" = "" ]
        then
                echo "No process $1."
        else
                kill $PROCESS
        fi
fi

Also, it may be more prudent "not" to leave this so ambiguous. Instead have the script kill tint2 explicitly.

Code:

#!/bin/bash
kill $(ps -C tint2 -o pid=)

This way it kills only tint2, and there can be no accidents with running the script with something else.


All times are GMT -5. The time now is 12:13 AM.