27/01/2007 very small change ==> added the -L option to stat, line 317 ( -L, --dereference: follow links)
09/11/2006, a little fix, so that launching specific programs for a given application now works correctly , interesting info here
09/04/2006, corrected wrong behaviour with the XPLAYER feature, see this post for more info, don't forget to update your sudoers file (see there)
08/24/2006, the Xserver to use is now set to /usr/bin/Xorg instead of /usr/bin/X (since /usr/bin/X can be either Xorg or Xgl), download it here, info here
08/22/2006 --> minor release, grab it here, info here
***
Since 08/13/2006 xlaunch is available through the xgl-coffee overlay, it is -* keyworded so you need to do: echo 'x11-misc/xlaunch -*' >> /etc/portage/package.keyword before merging it.
***
08/08/2006 --> You can now choose a name when creating a link for a program that isn't in your PATH, see here to know why it can be usefull, and here for a bit more details on this.. :/
08/01/2006 (last update before my holidays:) ) --> added some functionnalities, see here for more details
07/31/2006(in the evening..) --> now, if you want to launch something wich isn't in your path, you don't need anymore the --path option, but you can still use it:), see
I also added a function for a repetitive task (in the code, not when you run it)
07/31/2006(early in the morning) --> corrected and modified some comments, there are no need to update the script, if you already have it.
07/30/2006 added a link to download this growing script, some cleaning in it,and xlaunch now unset two variables that could (in special conditions) prevent it from working as expected, see there for more details
07/27/2006 big changes in xlaunch script, which is now far more user friendly, make this post reflect the changes, see here for more details
- I - Why could you be interested in this script?
II - eh, this looks quite long to set it up
III - The xlaunch script- a) Background
b) HowTo use it - The new way - The link trick
c) Making your multimedia keys working
d) Using XPLAYER
IV - Why it is so good?- a) wine
b) xqf
c) Differents settings for each app
d) You tell me?
- a) Background
I - Why could you be interested in this script?
- Hi, I wrote i little script, xlaunch, which, among other things that I will explain, launch an program on an other DISPLAY.
For those who are not yet familiar with this, here is some of the reasons why you could want/need that:
- * You can now switch from a fullscreen app (eg: a game) to your desktop within a couple of second, with CTRL+ALF+F$. This is actually the first reason why I want to do this script (I needed something like alt+tab that works within a game)
* For XGL users, this means, they can launch an opengl program (like googleearth, or a game), since IIRC it's not yet possible to use an opengl app directly in XGL. It doesn't have to be an fullscreen application, since it can also launch a Window Manager with the program.
* You can use your multimedia/fun keys (on your keyboard/remote control..) inside a fullscreen app, which normaly grabs everythings from your input devices. This is handy since you can now control e.g.: your music, volume and so on, inside the game (no need to go back to your destop).
* If you want to (easy to enable) you can create a game user, it will be used to launch the program if it's a game. There are mainly three reasons for that:- * Many games can manage different profile, and if they are several users who can play on your computer, there will be a "~/.game_name" directory in each user's home, and some users will probably download files already downloaded by others. So if you enable this feature, it will launch games as a specific user (I'll call it XPLAYER).
* Same comment applies to wine users, they will have to install a given game only one time, in XPLAYER's home.
* I like to believe, that if there's a bug in my game, (like those ), it adds a bit of security, since it's run with a user, belonging to only video,audio and games groups.
* The only two downsides I can think of, is that an other user could delete your profile, so XPLAYER is only usable on a personnal computer, where there is a minimum of trust between users
, and that different users may have different keybindings(a different xbindkeysrc file)
* If your ~/.Xauthority file (or XPLAYER's one if you use it) doesn't have the needed cookie corresponding to a given display, it will create it for you, and keep it for later use. - * Many games can manage different profile, and if they are several users who can play on your computer, there will be a "~/.game_name" directory in each user's home, and some users will probably download files already downloaded by others. So if you enable this feature, it will launch games as a specific user (I'll call it XPLAYER).
- * You can now switch from a fullscreen app (eg: a game) to your desktop within a couple of second, with CTRL+ALF+F$. This is actually the first reason why I want to do this script (I needed something like alt+tab that works within a game)
- Actually, it's never been long to configure, there was, at the beginning, only one link to do, yep one thing that's all. But I just explain how to do a lot of things, and why blah,blahblah instead of just making a listing of the needed command (actually it wouldn't be a listing, since there's only one command.. ( ln ).
Keep in mind that I'm also explaining here howto use some of xlaunch functionnalities that you probably don't need. Do you need to have special keybindings to control e.g. your music within a game? do you need to set your mouse sensitivity? ..? I personnally do.
Anyway, now it's easier than ever. If you're in a hurry, and want to try it now, just copy&paste the script xlaunch(from III - b), chmod it) and run it with the name of the program you want as an argument (eg: xlaunch quake3-bin ).
Later when you'll have a bit more time then run xlaunch --help to have a brief view of what xlaunch can also do. But the help is quite short, so if you need anything, you're welcomed to read the following
- a) Background
[The only thing really needed is that the application, you want to launch with xlaunch, appears in your PATH]
This is no longer needed since version 20060727 : if you want to launch a program that doesn't appear in your PATH (for instance, something compiled in your HOME or whatever) then you can use the --path option for xlaunch, e.g.: xlaunch --path path/to/cool_prog
And since version 20060731-r1, xlaunch path/to/program is enough
But you'll find everything easier if you have a directory, which is in your PATH, where you put all your scripts. If you don't have one yet, let's create it:
As root:(and chmod and chown it to your need, eg: chown your_user_name_here:users /home/scripts , and chmod 755 /home/scripts )Code: Select all
mkdir /home/scripts
Now we need to add this directory to your path, there are two ways for doing this:
Either you do it manually with echo PATH=\"\$PATH:/home/scripts\" >> ~/.bashrc (as your normal user)
Or (the prefered way since, it will also add /home/scripts to every user,but root, PATH)Code: Select all
if [ "$EUID" = "0" ] || [ "$USER" = "root" ] ; then PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${ROOTPATH}" else PATH="/usr/local/bin:/usr/bin:/bin:${PATH}" finow source it, to have the new $PATH in your env:Code: Select all
if [ "$EUID" = "0" ] || [ "$USER" = "root" ] ; then PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${ROOTPATH}" else PATH="/usr/local/bin:/usr/bin:/bin:/home/scripts:${PATH}" fiCode: Select all
source /etc/profile
b) The script xlaunch
Download it *here* and save it as /home/scripts/xlaunch
b) HowTo use it -The new way - The link trickCode: Select all
chmod 755 /home/scripts/xlaunch chown your_name_here:users /home/scripts/xlaunch
First I have to say the script itself is IMO well commented, thus, if you want to modify someting, it should be pretty easy to find your way out.
The new way: you no longer have to do some linking in order to use it. A quick look into xlaunch --help will tell you that you can now runand it will launch quake3 on an other DISPLAY, with you mouse settings, keybindings and so on. It works since quake3 is in my path. but if it wasn't(and if I have enough right to execute it), then I still can runCode: Select all
xlaunch quake3 +connect 213.246.38.167:27019(it also work with relative path, ie: assuming you were in /usr/game, xlaunch -p bin/quake3 +connect 213.246.38.167:27019 would work.)Code: Select all
xlaunch -p /usr/games/bin/quake3 +connect 213.246.38.167:27019
Note: since version 20060731-r1, you actually don't need to use the --path option, xlaunch path/to/program is enough (with relative or absolute path))
So as you can see there is, there is no longer anything to do before using it. But, honestly, even if possible, I still prefer launching :instead of the previous ones, it just seems more obvious to me. I've modified xlaunch so that it is now able to create the link for you.Code: Select all
xquake3 +connect 213.246.38.167:27019
(keep on reading for more details
)
* Fullscreen application:
new way if the user who wants to create link(s) has write access to the directory where xlaunch is, then he just need to runButIf he doesn't have write access to this directory, then he can specify the directory where he wants these links to be created:Code: Select all
xlaunch --addlink quake3-bin quake3-cpma Created link for quake3-bin : xquake3-bin --> xlaunch in /home/scripts Created link for quake3-cpma : xquake3-cpma --> xlaunch in /home/scriptsCode: Select all
xlaunch --addlink ~/tmp quake3-bin quake3-cpma Created link for quake3-bin : /home/truc/tmp/xquake3-bin --> /home/scripts/xlaunch Created link for quake3-cpma : /home/truc/tmp/xquake3-cpma --> /home/scripts/xlaunch
And if, in this example, /home/scripts or /home/truc/tmp is in your PATH, then you can now run the command: xquake3-cpma ...
tip: since version 20060801, if you would like to create a 'magic link' for a program that is note in your path, you just need to specify the directory of the program:
xlaunch --addlink path/to/program1 /PaTh/To/program2 ..
see here and also here for more detail on this.
If you're not satisfied with this you can still do it the old way:Note the 'x' before the name of the executable.Code: Select all
cd /home/scripts ln -s xlaunch xquake3-bin
Now, if you issue xquake3-bin, it will launch quake3-bin on an other DISPLAY. If you want it also configure your mouse or whatever you can do with xset, modify your keymaps, set your WM independant keybindings.
* Windowed application:
You can also launch a program, that is not supposed to be run fullscreen(eg: some strategic games have several windows). To achieve this, you can modify xlaunch. Let say I want to launch The Gimp (which comes with the gimp command) on an other display.And you'll find that you miss a window manager (at the very least to have window borders, and to be able to move windows).Code: Select all
xlaunch gimp
So, in xlaunch in this in the case loop:you have to add the gimp caseCode: Select all
case "${FULL_PROG_NAME##*/}" in xlaunch) echo "The program can't call itself. Exiting!" # Well, actually it can, but it will exit later, so exiting now.. exit 2 ;; *) xinit "${FULL_PROG_NAME}" $* -- $Xserver :$DISPLAY_TO_USE $serverargs &>/dev/null & ;; esacWhere you replace WindowManager with the WM of your choice. Note that if you have an other non fullscreen application, that you would like to run with the same WM, instead of adding a new case, just replace gimp) with gimp|other_app).Code: Select all
case "${FULL_PROG_NAME##*/}" in gimp) xinit "${FULL_PROG_NAME}" $* -- $Xserver :$DISPLAY_TO_USE $serverargs &>/dev/null & DISPLAY:$DISPLAY_TO_USE WindowManager & xlaunch) echo "The program can't call itself. Exiting!" # Well, actually it can, but it will exit later, so exiting now.. exit 2 ;; *) xinit "${FULL_PROG_NAME}" $* -- $Xserver :$DISPLAY_TO_USE $serverargs &>/dev/null & ;; esac
Note: that you can do that even if you're launching someting that doesn't appear in your path, (your specifying the full/relative path (with for example: xlaunch --path path/to/program or xlaunch path/to/program), if your path is like very/long/path/to/program, you just have to add the case 'program' in the loop
c) Making your multimedia keys working
I'm personnally using xmodmap and xbindkeys ( check this out: HOWTO Use Multimedia Keys). But if you're using an other daemon than xbindkeys, it shouldn't be that hard to modify xlaunch.
One thing you need to know, is that when your program runs in fullscreen mode, it usually grabs every keys from your input devices, this means, that daemons like xbindkeys won't get any event from them. Fortunately, there's a trick:
In the settings of the application/game, turn off fullscreen (yes do it:) ) . the good news, is that you launch this app on an other DISPLAY without any window manager running on it, this means the window of your app/game won't have any border at all, and if your game use the same resolution as the Xserver does, then it's just fullscreen. The app/game runs in window mode, but it's like fullscreen
.
You may wonder why it is so cool? only because now, the program doesn't grab everything from your input devices now. and now xbindkeys can receive some events.
Note that for games using the quake3 engine(quake3 itself, enemy-territory, tremulous and so on..), you need to bring down the console, otherwise, even with fullscreen off, they grab everythings. (once the console is down, you can use your special keys).
d) Using XPLAYER
As I try to say in part I, there are, in my opinion, many advantages to use a default user XPLAYER, which(?) will be used to launch games. If you want to try it out, here is how you can do:
First we need to uncomment the XPLAYER variable in xlaunch in order to enable it.
Then we need to create that user, I've chosen xplayer, you can use something else, but then don't forget to modify the XPLAYER variable in xlaunch
as root run:(if you previously modified /etc/profile as suggested, then xplayer has already /home/scripts in its PATH, otherwise issue echo "PATH=\"$PATH:/home/scripts\"" >> /home/xplayer/.bashrc )Code: Select all
adduser -m -g games -G audio,video,cdrom xplayer # then we su to xplayer, to copy what we need su - xplayer
Now, if you have one or several of these files: ~/.Xresources ~/.Xdefaults ~/.Xmodmap ~/.xbindkeysrc in your main user's HOME directory, then copy them to xplayer's HOME.
!!!Be sure to be xplayer when copying this( to avoid permission problem)... Same comment applies to the following.!!!
If it's not the first time you play, (is it?
) You should already have some directories in your HOME created by the games ( like ~/.q3a ~./etwolf or even ~/.wine )
=> Copy( or move them..). them from your home to xplayer's home. (once I copied wine directory, I ran (as xplayer) winecfg, I don't know if it's really needed, but it worked:) )
Now we need to configure sudo (app-admin/sudo):
login as root, thenandCode: Select all
visudo
this line has change with version 20060904, be sure to have the right one now:You can also want to add this line your_main_user_name ALL=(root) NOPASSWD: /bin/su - xplayer (so you'll be able to login as xplayer without any password, if you wanted to modify something in its home)Code: Select all
Cmnd_Alias XLAUNCH = /bin/su - xplayer -l -c FULL_PROG_NAME=* /home/scripts/xlaunch * %games ALL=(root) NOPASSWD: XLAUNCH
- a) wine
One of the things I particularly like with it is that I can use it for whatever I want, even launching a game via wine. e.g.: I have warcraft3 and The Frozen Throne, this is what you need to launch them with xlaunch:
create those two little scriptsandCode: Select all
#!/bin/sh cd ~/.wine/drive_c/Program\ Files/Warcraft\ III exec `wine Warcraft\ III.exe -opengl` exit 0since they are games:Code: Select all
#!/bin/sh cd ~/.wine/drive_c/Program\ Files/Warcraft\ III exec `wine Frozen\ Throne.exe -opengl` exit 0And, as I said , programs need to appear in your PATH, since /home/scripts is in your PATH, then warcraft3 and frozenthrone are in too. Then all you have to do now is to follow II ) b) HowTo use it - The new way -The link trick :Code: Select all
chgrp games /home/scripts/{warcraft3,frozenthrone} chmod 0750 /home/scripts/{warcraft3,frozenthrone}
(because /home/scripts is in my PATH, this means warcraft3 and frozenthrone too)Code: Select all
cd /home/scripts xlaunch --addlink warcraft3 xlaunch --addlink frozenthrone
And when you want to play, just issue either xwarcraft3, or xfrozenthrone, and it will launch the game on an other display, su to XPLAYER, if you wanted to, and so forth and so on.
I don't have WoW, but, I think the same could be done, you just have to adapt the wow script from the warcraft3 one
b) xqf
One other thing I like, is that there are no special trick to make xqf working with you game, in Preferences --> Game --> invoking --> in "command-line" change the command_for_the_game with xcommand_for_the_game (erm.. don't forget to do the symlink before
)
eg: for enemy-territory, do the symlink (xlaunch -a et), and in XQF, instead of et in the "Command Line" put xet, and now you can use XQF as you normally do, and when you join a game, in will launch it on an other display.
Note: you can also put xlaunch et in the "Command Line" field, but who would want that? :/
c) Differents settings for each app
It's also possible to set differents settings for a given program, let's for example you want to run a fullscreen program in a lower resolution than your desktop is, I explain here(second part of the post) how you can do this.
I also explain in this post how you can set other things since it might not be obvious for every one .(happy reading)
d) You tell me?:)
I'd be glad to know if:- * You read this entire post
* You are interested in xlaunch
* You have any constructive comments (I'd also be happy to know what they are...)
* If I made any bashism in the script. I'd like xlaunch to run even if bash is not the default shell
* I made typo, grammar mistakes(?) (I'm sure I did since english is not my first language), I'd be happy to learn and to correct them
- * You read this entire post





