LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   How do I set-up to launch my DE with ck and dbus from bash? (http://www.linuxquestions.org/questions/linux-software-2/how-do-i-set-up-to-launch-my-de-with-ck-and-dbus-from-bash-895621/)

xtiansimon 08-04-2011 06:33 PM

How do I set-up to launch my DE with ck and dbus from bash?
 
What I am currently trying to accomplish is to start Xfce or Fluxbox from the command line (and run level 3). I've discovered there are several other packages/apps needed to be launched with either. The normal installed setup is to boot into run level 5, where I get the login screen which has a menu to select the DE/WM of my choice. Presumably this selection also loads the other necessary apps that make any DE a usable system. For example, I've found it necessary to startx & Xfce using the following command placed in ~/.xinitrc

exec ck-launch-session dbus-launch startxfce4

The trouble is startx only works for one DE/WM at a time, and I wish to retain the option to select my DE/WM from a list of options (currently Xfce and Fluxbox).

My first thought: what is the equivalent of the above command I can run from bash prompt? If I had this, I could write an alias to put in .bashrc...

berbae 08-05-2011 04:18 AM

Quote:

Originally Posted by xtiansimon (Post 4434059)
The trouble is startx only works for one DE/WM at a time, and I wish to retain the option to select my DE/WM from a list of options (currently Xfce and Fluxbox).

No you can have in .xinitrc something like :
Code:

select wm in Xfce Fluxbox nothing; do
    case $wm in
        Xfce) echo "exec ck-launch-session dbus-launch startxfce4";;
        Fluxbox) echo "exec ck-launch-session dbus-launch fluxbox";;
        nothing) break;;
    esac
done

Replace the 'echo' by the real command to execute.
So startx will give the choice to launch a WM or another.

xtiansimon 08-08-2011 01:57 PM

@berbae: clever and quick. However it did not work as written. Bash scripting is not my bag--if that is what this is... Will you provide more information and I can research your solution?

berbae 08-08-2011 03:15 PM

I know it doesn't work as written : I wrote the 'echo' command instead of the 'exec ...' command to be executed, just to test the choices. The working writing would be :
Code:

select wm in Xfce Fluxbox nothing; do
    case $wm in
        Xfce) exec ck-launch-session dbus-launch startxfce4;;
        Fluxbox) exec ck-launch-session dbus-launch fluxbox;;
        nothing) break;;
    esac
done

without the 'echo'.

In case of problem, post your entire .xinitrc file, and error messages after you launched startx.

xtiansimon 08-08-2011 11:28 PM

Quote:

Originally Posted by berbae (Post 4437116)
I know it doesn't work as written : I wrote the 'echo' command instead of the 'exec ...' command to be executed, just to test the choices.

Well, you know more about bash scripting than I do. (^_^)

berbae 08-09-2011 07:58 AM

So does it work now ?
And if so, please mark the thread as SOLVED (and click Yes to the 'Did you find this post helpful?' question, thanks).

xtiansimon 08-10-2011 08:31 AM

Its not working. Instead I enter startx command. The screen blanks out from the command line as if something is happening. The command line returns with this printed,
Quote:

1) xfce
2) fluxbox
3) nothing
#?

xwindows is shutting down.
I am not presented with the opportunity to select the window manager. Am I doing something wrong? Am I supposed to pass an argument to the command startx?

berbae 08-10-2011 11:09 AM

In fact that approach doesn't seem to work, sorry.
It's because the .xinitrc script is called by xinit after the X server is launched.
So it cannot be used to run an interactive bash command when the graphical environment is already started.

So you were right to say "startx only works for one DE/WM at a time".

The only way I see now is to create several .xinitrc, with different names of course, for each WM, and pass one as parameter to startx, using a new script, for example named 'startwm', which you run instead of startx :
Code:

#!/bin/bash
# script startwm, to use instead of startx
select wm in Xfce Fluxbox nothing; do
    case $wm in
        Xfce) startx $HOME/.xinitrc-xfce4;;
        Fluxbox) startx $HOME/.xinitrc-fluxbox;;
        nothing) break;;
    esac
done

with $HOME/.xinitrc-xfce4:
Code:

#!/bin/bash
...
exec ck-launch-session dbus-launch startxfce4

and $HOME/.xinitrc-fluxbox
Code:

#!/bin/bash
...
exec ck-launch-session dbus-launch fluxbox

Replace ... with other commands which are present in the original .xinitrc script.

That's something you could try. Tell me if that works.

xtiansimon 08-17-2011 07:47 PM

Kudos! It does indeed work.

All worked as expected save for one bit. When I logout back to runlevel 3, I get "#?" prompt. Its a good thing you added 3, else I'd have been in a loop!

I didn't get to programming via CS, so I'm surprised by your kung-fu. The double ;; and the lack of {} is strange to me. What is this style?


All times are GMT -5. The time now is 01:30 PM.