Page 1 of 5 123 ... LastLast
Results 1 to 10 of 43

Thread: How-to run Multiple (Virtual) X sessions

  1. #1
    Join Date
    Apr 2006
    Location
    Montana
    Beans
    Hidden!
    Distro
    Kubuntu Development Release

    Thumbs down How-to run Multiple (Virtual) X sessions

    Bodhi's VirtualX script.


    This is a bash script which will give you a GUI to start virtual X sessions without going through KDM, GDM, XDM, etc.

    This is an adaptation from my work with dual monitors....

    What is a virtual X session? Just as you can have multiple terminals (tty1, tty2....,tty6)
    You can have multiple instances of X (Ctrl-Alt-F7, Ctrl-Alt-F8, Ctrl-Alt-F9).

    Yes, but doesn't that slow down your computer? NOT THAT MUCH

    Yes, but why you ask?

    Are you the type that runs gnome, but are interested in trying an alternate desktop?

    This script allows yo to stay logged in gnome, all applications running, and start a second X session, say Fluxbox, Openbox, IceWM, or XFCE.

    Otherwise you have to log-out, choose a new session in GDM, log in. This stops all your gnome programs.

    With this script you can explore AND keep gnome running as "home base"

    Features:
    1. You may select to run fluxbox, gnome, KDE, icewm, openbox, or xfce.
    2. NO ADDITIONAL SCRIPTS.
    3. To change between X Sessions Ctrl-alt F7 ; Ctrl-Alt-F8 ; Ctrl-Alt-F9, etc.


    That is correct. I consolidated a number of start scripts into this bash script.

    The upside is there is now only one configuration file for your virtual X setup and configuration.

    The downside is you will need to understand this file if you want to tweak my setup (you know you do....)

    I tried to comment the script so as to make this as painless as possible.


    Dependencies:

    EDIT:
    Thanks to compwiz18:
    Quote Originally Posted by compwiz18 View Post
    Howdy. Just thought that it might be worth noting that on a fresh install, dialog is not installed by default. I had to run sudo apt-get install dialog to make the program run, otherwise it just exits.
    Absolute dependency:
    dialog
    Code:
    sudo aptitude update
    sudo aptitude install dialog
    I advise these packages:
    fbsetbg to set background image (openbox, Fluxbox, IceWM [Although IceWM has themes])
    numlockx - Turns on number lock (on the number pad)
    xscreensaver - Screen saver.

    Options:
    rox (see below)

    To play a sound at start of window manager:
    Install mpg123 or mpg321

    Syntax: mpg321 -a hw:y,z /path_to/sound.mp3
    hw:y,z is your soundcard
    hw:0,1 or hw:1,0 or hw:2,0


    CONFIGURATION

    1. Save this script as /usr/bin/virtualX
    Code:
    sudo gedit /usr/bin/virtualX
    Copy and paste this script:
    #!/bin/sh

    # Variables
    # widowmanager=Desktop/Window manager
    # tempfile1=tempfile1

    ################################################## ###########################
    ## Default Screen ##
    ################################################## ###########################

    # GDM starts at boot on screen 0

    # Fluxbox = 1
    # Gnome = 2
    # IceWM = 3
    # KDE = 4
    # Openbox = 5
    # xfce = 6

    ################################################## ###########################
    ## Select Desktop/Window manager ##
    ################################################## ###########################

    dialog --backtitle "Welcome to bodhi's virtual X script" --title "Desktop Environment" --menu "Please select a desktop environment" 13 175 7 \
    "fluxbox" "Fluxbuntu <http://community.fluxbuntu.org>" \
    "gnome" "Ubuntu" \
    "icewm" "<http://en.wikipedia.org/wiki/IceWM>" \
    "kde" "Kubuntu" \
    "openbox" "<http://www.icculus.org/openbox/2/>" \
    "xfce" "Xubuntu" 2>~/tempfile1

    return_value=$?

    windowmanager=`cat ~/tempfile1`

    case $return_value in

    0)
    rm ~/tempfile1 & rm windowmanager
    clear
    echo -e '\E[32m'"bodhi.zazen"
    tput sgr0

    case $windowmanager in

    fluxbox)
    # Start xsreensaver & numlockx
    DISPLAY=:1.0 /usr/bin/xscreensaver &
    DISPLAY=:1.0 /usr/bin/numlockx on &

    # PLAY a sound
    # Use a CLI player
    # Example:
    # sleep -3 & mpg321 -a hw:1,0 /path/sound.mp3 &

    # Start rox
    #DISPLAY=:1.0 rox --pinboard=Default &

    exec /usr/bin/startx /usr/bin/fluxbox -- :1 2> /dev/null &
    exit ;;

    gnome)
    # Start xsreensaver & numlockx
    DISPLAY=:2.0 /usr/bin/xscreensaver &
    DISPLAY=:2.0 /usr/bin/numlockx on &

    # PLAY a sound
    # Use a CLI player
    # Example:
    # sleep -3 & mpg321 -a hw:1,0 /path/sound.mp3 &

    # Start Gnome
    /usr/bin/startx /usr/bin/gnome-session -- :2 2> /dev/null &
    exit ;;

    kde)
    # Start xsreensaver & numlockx
    DISPLAY=:3.0 /usr/bin/xscreensaver &
    DISPLAY=:3.0 /usr/bin/numlockx on &

    # PLAY a sound
    # Use a CLI player
    # Example:
    # sleep -3 & mpg321 -a hw:1,0 /path/sound.mp3 &

    # Start KDE
    /usr/bin/startx -- :3 2> /dev/null &
    exit ;;

    icewm)
    # Start xsreensaver & numlockx
    DISPLAY=:4.0 /usr/bin/xscreensaver &
    DISPLAY=:4.0 /usr/bin/numlockx on &

    # PLAY a sound
    # Use a CLI player
    # Example:
    # sleep -3 & mpg321 -a hw:1,0 /path/sound.mp3 &

    # Start rox
    # rox --pinboard=Default &

    # Start IceWM
    exec /usr/bin/startx /usr/bin/icewm-session -- :4 2> /dev/null &
    exit ;;

    openbox)
    # Start xsreensaver & numlockx
    DISPLAY=:5.0 /usr/bin/xscreensaver &
    DISPLAY=:5.0 /usr/bin/numlockx on &

    # To set background image, uncomment the following lines and set the path to an image
    # DISPLAY=:5.0 fbsetbg -f /home/picture.jpg &

    # PLAY a sound
    # Use a CLI player
    # Example:
    # sleep -3 & mpg321 -a hw:1,0 /path/sound.mp3 &

    # Start rox Rox does not work so well with Openbox....
    # rox --pinboard=Default &

    # Start Openbox
    exec /usr/bin/startx /usr/bin/openbox -- :5 2> /dev/null &
    exit ;;

    xfce)
    # Start xsreensaver & numlockx
    DISPLAY=:6.0 /usr/bin/xscreensaver &
    DISPLAY=:6.0 /usr/bin/numlockx on &

    # PLAY a sound
    # Use a CLI player
    # Example:
    # sleep -3 & mpg321 -a hw:1,0 /path/sound.mp3 &

    # Start rox
    # rox --pinboard=Default &

    # Start XFCE
    exec /usr/bin/startx /usr/bin/xfce4-session -- :6 2> /dev/null &
    exit ;;
    esac ;;

    1)
    clear
    echo -e '\E[31m' "Cancel"
    tput sgr0
    sleep 2
    clear
    exit ;;
    255)
    clear
    echo -e '\E[31m' "Esc"
    tput sgr0
    sleep 2
    clear
    exit ;;
    esac

    rm windowmanager
    clear
    echo -e '\E[32m'"bodhi.zazen"
    tput sgr0
    Save and exit gedit.

    Now make it executable:
    Code:
    sudo chmod a+x /usr/bin/virtualX
    2. Enable script for use within X.

    Note: by default, in Ubuntu you can use this script in tty1
    Code:
    Ctrl-alt-F1
    login
    virtualX
    To enable this script for use within an X session (gnome):
    Code:
    sudo gedit /etc/X11/Xwrapper.config
    Change:
    allowed_users=console
    To:
    Code:
    allowed_users=anybody
    Documentation

    After this edit you can use this script from tty1 or in a terminal in gnome (or any window manager).

    Now, to run this script, open a terminal and type virtualX.

    3. Shortcut:
    Start this script with
    Code:
    bash virtualX
    Watch the capital X at the end.....

    4. Add a menu item/launcher/desktop shortcut.
    Create a menu item, launcher, or desktop icon.
    Name =virtualX
    Command= bash virtualX


    5. KDE:
    This script starts KDE with just startx.

    Thus edit your .xinitrc

    #!/bin/sh

    #
    # ~/.xinitrc
    #
    # Executed by startx (run your window manager from here)
    #

    exec startkde

    6. Rox: Rox works well with fluxbox, icewm, xfce. It will allow desktop icons very easily.
    See here for configuration:

    Fluxbuntu Rox

    Debian Rox

    Note: Rox does not work so well with openbox.

    Most of all, have fun !
    Last edited by bodhi.zazen; October 6th, 2006 at 12:03 AM. Reason: Update dependencies
    There are two mistakes one can make along the road to truth...not going all the way, and not starting.
    --Prince Gautama Siddharta

    #ubuntuforums web interface

  2. #2
    Join Date
    Nov 2005
    Location
    UK
    Beans
    458
    Distro
    Xubuntu 8.10 Intrepid Ibex

    Re: How-to run Multiple (Virtual) X sessions

    Hi bhodi, thanks for the excellent "HowTo". It's not running on my system though for some reason. Just exits (Cleanly i might add) both in a terminal window & a tty1 etc......

    Also, what i was going to say (but forgot to mention the other day) was that i "Can't" switch back & forth when doing the one line command that we talked about..... when i switch back to my normal session (CTL-ALT-F7) then go back to tty1, it's no longer running as an xsession.

    I'll keep playing with this script & see if i can sort out what's wrong.
    Registered Linux user: #413753 | Ubuntu user: #7595
    | Tiny Me | antiX | Zenwalk |

  3. #3
    Join Date
    Apr 2006
    Location
    Montana
    Beans
    Hidden!
    Distro
    Kubuntu Development Release

    Re: How-to run Multiple (Virtual) X sessions

    Quote Originally Posted by DJiNN View Post
    Hi bhodi, thanks for the excellent "HowTo". It's not running on my system though for some reason. Just exits (Cleanly i might add) both in a terminal window & a tty1 etc......

    Also, what i was going to say (but forgot to mention the other day) was that i "Can't" switch back & forth when doing the one line command that we talked about..... when i switch back to my normal session (CTL-ALT-F7) then go back to tty1, it's no longer running as an xsession.

    I'll keep playing with this script & see if i can sort out what's wrong.
    Thank you thank you for your response, I will look at the script again tonight.

    I ran the script last night before posting but I was not able to replicate your issues (on my Ubuntu box).

    When you find the script exits cleanly, is this for all window managers or do some work for you?

    Just to ask the obvious, you must have the window manager installed for this script it to launch it (ie this script does not run xfce if xfce is not installed).

    Since you have *box do openbox and/or fluxbox work?

    As to changing from tty1 to F7 or F8 I could do all this with no problems. I can even close the terminal in which I run the script and the window manager I started with the script continues to run.

    At any rate to trouble shoot the script remove the "2> /dev/null" from the end of the line(s) with the relevant window manager(s) and you should then see error messages (as well as other text) in the terminal.
    There are two mistakes one can make along the road to truth...not going all the way, and not starting.
    --Prince Gautama Siddharta

    #ubuntuforums web interface

  4. #4
    Join Date
    Nov 2005
    Location
    UK
    Beans
    458
    Distro
    Xubuntu 8.10 Intrepid Ibex

    Re: How-to run Multiple (Virtual) X sessions

    Quote Originally Posted by bodhi.zazen View Post
    Thank you thank you for your response, I will look at the script again tonight.

    I ran the script last night before posting but I was not able to replicate your issues (on my Ubuntu box).
    Hi bodhi..... just ran the script on my FluxBox (You know, the server install?) and it ran fine, and gave me a choice etc (Which is really cool by the way, well done.... ) So i chose "OpenBox" because i know that i have that installed on this machine. It ran fine, but when i swapped back to CTRL-ALT-F7 then went back to OB again, it had exited, giving the errors as lines 109 & 110 - that i neither have xscreensaver or xnumlock installed. Are these pre-requisites (Do they "Have" to be installed) or is it a choice thing? No worries, because i can install them, it's just that i never really use either, especially the numlock thing. Sad as it may be, i NEVER ever use the keypad on the right of the keyboard..... for anything!

    When you find the script exits cleanly, is this for all window managers or do some work for you?
    I don't even get that far on the Ubuntu machine..... no choices at all, i just run it & it exits without even bringing up a "Choice" as it were. In fact, the first time that i saw the choices was just now when i ran it on the Flux machine.

    Just to ask the obvious, you must have the window manager installed for this script it to launch it (ie this script does not run xfce if xfce is not installed).
    I can imagine that, that's why i ran OpenBox to try it out on the Flux machine, because it's installed on that machine, but XFCE isn't.

    On the Ubuntu machine, it's actually "Xubuntu" so i don't know if that will make a lot of difference as to how the script works etc, but i would have imagined that if it runs OK on the Server install with Flux, then it would run OK on XFCE.....? (Or is that just "Wishful thinking"? )

    Since you have *box do openbox and/or fluxbox work?
    OpenBox works fine on the Fluxbox machine (Apart from the fact that it still exits when i come out of it & go back to CTRL-ALT-F7. On the Ubuntu (Xubuntu) machine, nothing works at all...... I don't even get a screen with choices on it.

    As to changing from tty1 to F7 or F8 I could do all this with no problems. I can even close the terminal in which I run the script and the window manager I started with the script continues to run.
    Hmmm, i've tried it on both machines here & it doesn't do that. I can get it to run on this (Flux) machine, and choose a "VirtualX" environment, but as soon as i exit & go back to it, it's stopped with the screensaver & numlock errors that i mentioned earlier.

    Ah, hold on..... BREAKING NEWS!!! Heehee...... i've just checked, and for some reason (On the Flux machine at any rate) it's firing the virtual X's up & it is keeping them there, but i have to get to them by doing CTRL-ALT-F8 or F9 or F10 etc...... it's not putting them on CTRL-ALT-F1, F2 etc. So yes, they're still running but not where i thought they were..... Any ideas?

    But nothing works at all on the Xubuntu machine..... YET!!
    Last edited by DJiNN; October 5th, 2006 at 05:06 PM.
    Registered Linux user: #413753 | Ubuntu user: #7595
    | Tiny Me | antiX | Zenwalk |

  5. #5
    Join Date
    Nov 2005
    Location
    UK
    Beans
    458
    Distro
    Xubuntu 8.10 Intrepid Ibex

    Re: How-to run Multiple (Virtual) X sessions

    Me again..... just been playing around on the Flux machine & this really works well...!! I've currently got Fluxbox (Main X server) running with both OpenBox & IceWM running at the same time.... all in 512mb or RAM on an old PIII 700Mhz machine..... amazing! & all desktops are really responsive & work really well.

    But i still can't get a peep from the main (Xubuntu) machine..... it just won't run the virtualX script either from a terminal or a tty sccreen..... weird.

    Anyway, just wanted to let you know..... & say "Thanks" for a great script. I'll keep on playing & keep you posted with how it goes.
    Registered Linux user: #413753 | Ubuntu user: #7595
    | Tiny Me | antiX | Zenwalk |

  6. #6
    Join Date
    Apr 2006
    Location
    Montana
    Beans
    Hidden!
    Distro
    Kubuntu Development Release

    Re: How-to run Multiple (Virtual) X sessions

    Quote Originally Posted by DJiNN View Post
    Hi bodhi..... just ran the script on my FluxBox (You know, the server install?) and it ran fine, and gave me a choice etc (Which is really cool by the way, well done.... ) So i chose "OpenBox" because i know that i have that installed on this machine. It ran fine, but when i swapped back to CTRL-ALT-F7 then went back to OB again, it had exited, giving the errors as lines 109 & 110 - that i neither have xscreensaver or xnumlock installed. Are these pre-requisites (Do they "Have" to be installed) or is it a choice thing? No worries, because i can install them, it's just that i never really use either, especially the numlock thing. Sad as it may be, i NEVER ever use the keypad on the right of the keyboard..... for anything!
    No you do not have to run either xscreensaver or numlock X. You in fact do not need to do anything, all that will happen is that your error messages will persist.

    To fix, edit the script and comment out (or delete) the xscreensaver and numlockx lines like this:
    Code:
    fluxbox)
    # Start xsreensaver & numlockx
    # DISPLAY=:1.0 /usr/bin/xscreensaver &
    # DISPLAY=:1.0 /usr/bin/numlockx on &
    
    # PLAY a sound
    # Use a CLI player
    # Example:
    # sleep -3 & mpg321 -a hw:1,0 /path/sound.mp3 &
    
    # Start rox
    #DISPLAY=:1.0 rox --pinboard=Default &
    
    exec /usr/bin/startx /usr/bin/fluxbox -- :1 2> /dev/null &
    exit ;;
    If you like, you could enable rox while you are there........ I do not recall if you use rox.

    Quote Originally Posted by DJiNN View Post
    I don't even get that far on the Ubuntu machine..... no choices at all, i just run it & it exits without even bringing up a "Choice" as it were. In fact, the first time that i saw the choices was just now when i ran it on the Flux machine.
    Not sure what is at issue with xubuntu. I can tell you the script was written for Arch and then adapted to Ubuntu. It does not run (well) on Zenwalk either. Of course, it could be adapted....

    Quote Originally Posted by DJiNN View Post
    Ah, hold on..... BREAKING NEWS!!! Heehee...... i've just checked, and for some reason (On the Flux machine at any rate) it's firing the virtual X's up & it is keeping them there, but i have to get to them by doing CTRL-ALT-F8 or F9 or F10 etc...... it's not putting them on CTRL-ALT-F1, F2 etc. So yes, they're still running but not where i thought they were..... Any ideas?
    LOL DJiNN X runs virtual on higher sessions, ie Ctrl-alt-F7, Ctrl-Alt-F8, ... You could change this behavior by editing some system files. If that is what you would like I would need to do a little research on Ubuntu.

    Quote Originally Posted by DJiNN View Post
    Me again..... just been playing around on the Flux machine & this really works well...!! I've currently got Fluxbox (Main X server) running with both OpenBox & IceWM running at the same time.... all in 512mb or RAM on an old PIII 700Mhz machine..... amazing! & all desktops are really responsive & work really well.
    It is amazing how little this technique saps resources. I have been trying to teach this, but people have been afraid of the configuration files and CLI interface, thus the script.

    Quote Originally Posted by DJiNN View Post
    But i still can't get a peep from the main (Xubuntu) machine..... it just won't run the virtualX script either from a terminal or a tty sccreen..... weird.
    Did you enable the script?
    Code:
    sudo chmod a+x /usr/bin/virtualX
    Also, did you try adding my shortcut to your fluxbox menu? It also works like a charm

    Last edited by bodhi.zazen; October 5th, 2006 at 06:33 PM.
    There are two mistakes one can make along the road to truth...not going all the way, and not starting.
    --Prince Gautama Siddharta

    #ubuntuforums web interface

  7. #7
    Join Date
    Nov 2005
    Location
    UK
    Beans
    458
    Distro
    Xubuntu 8.10 Intrepid Ibex

    Re: How-to run Multiple (Virtual) X sessions

    Quote Originally Posted by bodhi.zazen View Post
    No you do not have to run either xscreensaver or numlock X. You in fact do not need to do anything, all that will happen is that your error messages will persist.

    To fix, edit the script and comment out (or delete) the xscreensaver and numlockx lines like this:
    Code:
    fluxbox)
    # Start xsreensaver & numlockx
    # DISPLAY=:1.0 /usr/bin/xscreensaver &
    # DISPLAY=:1.0 /usr/bin/numlockx on &
    
    # PLAY a sound
    # Use a CLI player
    # Example:
    # sleep -3 & mpg321 -a hw:1,0 /path/sound.mp3 &
    
    # Start rox
    #DISPLAY=:1.0 rox --pinboard=Default &
    
    exec /usr/bin/startx /usr/bin/fluxbox -- :1 2> /dev/null &
    exit ;;
    If you like, you could enable rox while you are there........ I do not recall if you use rox.
    I do use Rox (& also Thunar quite a bit at the moment) & i have already commented out the screensaver etc on every line..... The script actually "Runs" but just exits straight away & doesn't do anything.

    One thing that did happen, was when i commented out the lines with sccreensaver etc, it started throwing up a "bad token" error, somewhere around line 90.... icewm) I looked but i still can't find anything that's obvious.

    Not sure what is at issue with xubuntu. I can tell you the script was written for Arch and then adapted to Ubuntu. It does not run on Zenwalk either.
    hmmm, it's strange that it should work on Ubuntu but not on Xubuntu isn't it? There could be something missing perhaps.... I'm not running Zen at the moment as you know, but once i learn a bit more about this script & what each line means & does (I know some but not all,.... yet) then i'll perhaps re-do a version for Zen...... just to try it out more than anything else.

    LOL DJiNN X runs virtual on higher sessions, ie Ctrl-alt-F7, Ctrl-Alt-F8, ... You could change this behavior by editing some system files. If that is what you would like I would need to do a little research on Ubuntu.
    LOL!! It's very strange how it does it..... (Well, to me anyway) ... so i effectively have all of my tty screens (1-6) and then my virtualX's are running on 8,9,10 etc..... with, of course, CTRL-ALT-F7 bringing my main desktop & environment back.

    I don't actually mind it at all..... just strange that it happens that way.

    It is amazing how little this technique saps resources. I have bee trying to teach this, but people have been afraid of the configuration files and CLI interface, thus the script.
    This is one of the things that amazes me, and also one of it's strengths i think. This script, with time & development, could turn out to be a really beneficial little tool. (That's a subtle hint to keep on working on it by the way....)

    Did you enable the script?
    Code:
    sudo chmod a+x /usr/bin/virtualX
    Also, did you try adding my shortcut to your fluxbox menu? It also works like a charm
    I did enable the script and it works fine on the Flux system, but still nothing on this one (Xubuntu). It runs..... but just exits straight away.

    I shall keep going though....... i really love the ability to be able to run several X's at once..... & would even consider doing another server install just to get the ability on this machine as well.
    Registered Linux user: #413753 | Ubuntu user: #7595
    | Tiny Me | antiX | Zenwalk |

  8. #8
    Join Date
    Nov 2005
    Location
    UK
    Beans
    458
    Distro
    Xubuntu 8.10 Intrepid Ibex

    Re: How-to run Multiple (Virtual) X sessions

    Another update.....

    It seems that using the CLI command
    Code:
    /usr/bin/startx /usr/bin/openbox -- :2
    as you told me earlier, does work on the xUbuntu system, but as on the other system, it puts the virtualX on CTRL-ALT-F8/F9 etc. It doesn't touch tty 1 or 2 etc.

    So now i can swap between these virtual X's, but they're just in a different place to where i was previously looking.

    I personally think this is a great step forward for me, for while it may not be working quite as it should, at least it "IS" working & i can do what i set out to do, which is run several Virtual X environments at the same time.

    Now i've just got to find out...A why it's doing this (ie: using different screens to the ones that it's supposed to be using) and B how i can get the script working on the xUbuntu machine.

    It's all good fun though......
    Registered Linux user: #413753 | Ubuntu user: #7595
    | Tiny Me | antiX | Zenwalk |

  9. #9
    Join Date
    May 2006
    Beans
    Hidden!
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: How-to run Multiple (Virtual) X sessions

    Howdy. Just thought that it might be worth noting that on a fresh install, dialog is not installed by default. I had to run sudo apt-get install dialog to make the program run, otherwise it just exits.

  10. #10
    Join Date
    Nov 2005
    Location
    UK
    Beans
    458
    Distro
    Xubuntu 8.10 Intrepid Ibex

    Re: How-to run Multiple (Virtual) X sessions

    Quote Originally Posted by compwiz18 View Post
    Howdy. Just thought that it might be worth noting that on a fresh install, dialog is not installed by default. I had to run sudo apt-get install dialog to make the program run, otherwise it just exits.
    THAT'S IT!!! Thanks ever so much for that....... It now works perfectly on both machines. I don't think i would have found that one, for sure.

    I have 3 different VX's running on this machine, and i'm just about to go to tty1 & run it from there.... just to see what happens.

    Thanks once again..... You've saved me many hours of trial & error, with the emphasis on "error".
    Registered Linux user: #413753 | Ubuntu user: #7595
    | Tiny Me | antiX | Zenwalk |

Page 1 of 5 123 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •