XGL/Alternative Run Methods
From Gentoo Linux Wiki
Contents |
[edit] Adding Compiz to an Existing Gnome Session
Here is a little startscript, which I've placed in /usr/bin/. Useful if you do not always run Xgl. Change or remove the setxkbmap line according to your keyboard layout.
| File: /usr/bin/compizrc |
#!/bin/bash
#
# Start compiz within gnome-session
#
if [ `ps -A -o comm | grep -c '^Xgl$'` == "1" ]; then
DISPLAY=:1 LD_LIBRARY_PATH=/usr/lib/opengl/xorg-x11/lib/ compiz --replace gconf &
DISPLAY=:1 gnome-window-decorator &
# DISPLAY=:1 setxkbmap -model pc105 -layout it -variant basic # Change according to your needs, and uncomment if needed
# Or like that, if you need to switch between layouts.
# setxkbmap -model pc105 -layout "us,ru(winkeys)" -variant winkeys -option "grp:alt_shift_toggle,grp_led:scroll"
else echo "${0}: Error: Compiz and g-w-d not launched. Xgl not running?"
fi
|
| File: /usr/bin/compizrc.modified |
#!/bin/bash
#
# Start compiz within gnome-session
#
if [ `ps -A -o comm | grep -c '^Xgl$'` == "1" ]; then
# For old versions
# DISPLAY=:0 LD_LIBRARY_PATH=/usr/lib/opengl/xorg-x11/lib/ compiz --replace gconf &
# For Compiz-Quinnstorm with csm
DISPLAY=:0 LD_LIBRARY_PATH=/usr/lib/opengl/xorg-x11/lib/ compiz --replace dbus csm &
DISPLAY=:0 dbus-launch cgwd --replace &
# DISPLAY=:0 setxkbmap -model br-abnt2 -layout br -variant br
else echo "${0}: Error: Compiz and cgwd not launched. Xgl not running?"
fi
|
| Code: Make the script executable |
|
chmod 755 /usr/bin/compizrc |
- After logging into GNOME, start System->Settings->Sessions. Here you go to the 3rd tab Startup Programs and press the Add button. Enter the path to your Compiz startscript (e.g., /usr/bin/compizrc).
- After logging out and back in Compiz will start, but you'll see no decorations and effects. Thats because the Compiz gconf tree for the current user has just been created - without any plugins!
- So start your configuration editor and go to apps/compiz/general/allscreens/options and edit the active_plugins key. This should contain the following items in this order: gconf decoration wobbly fade minimize cube rotate zoom scale move resize place menu switcher
- If the key is not there, make it with a type of List
- After restarting your Xgl Server should be accessible with GDM & gnome-session.
[edit] Running Using XSession
You can add another session for Xgl on display :1 (leaving the standard server on :0). It is a 2 step setup and imho the best option, first create a file to start Xgl and second create a new xsession file. This method requires following the previous sections on either GDM or KDM.
Create a new file startxgl.sh in /usr/bin which starts Xgl.
vim /usr/bin/startxgl.sh
You have to make this file executable, otherwise you'll get a blackscreen.
chmod +x /usr/bin/startxgl.sh
And add one of the four options below.
- NVIDIA (using GNOME)
#!/bin/bash Xgl -fullscreen :1 -audit 0 -ac -br -accel glx:pbuffer -accel xv:fbo & sleep 2 && DISPLAY=:1 dbus-launch gnome-session
- NVIDIA (using KDE)
#!/bin/bash Xgl -fullscreen :1 -audit 0 -ac -br -accel glx:pbuffer -accel xv:fbo & sleep 2 && DISPLAY=:1 startkde
- ATI and Intel (using GNOME)
#!/bin/bash Xgl -fullscreen :1 -audit 0 -ac -br -accel glx:pbuffer -accel xv:pbuffer & sleep 2 && DISPLAY=:1 dbus-launch gnome-session
- ATI and Intel (using KDE)
#!/bin/bash Xgl -fullscreen :1 -audit 0 -ac -br -accel glx:pbuffer -accel xv:pbuffer & sleep 2 && DISPLAY=:1 startkde
Create a new xsession file:
| File: /usr/share/xsessions/xgl.desktop |
[Desktop Entry] Encoding=UTF-8 Name=Xgl Comment=Start an Xgl Session Exec=/usr/bin/startxgl.sh Icon= Type=Application |
Now you will be able to select a new Xgl session via GDM or KDM's option menu.
The benefit is that it will not replace your normal XOrg server. So when you "break" your Xgl you can return to the normal XOrg server.
[edit] Alternative: Xsession (Modifying startx)
Copy /usr/bin/startx to /usr/bin/startxgl and change the following line towards the end of the file:
| File: /usr/bin/startxgl |
xinit $clientargs -- $serverargs -deferglyphs 16 & to xinit $clientargs -- /usr/bin/Xgl :1 $serverargs -ac -accel xv -accel glx:pbuffer -deferglyphs 16 & |
Instructions should then be followed depending on your chosen window manager and desktop environment. See Beryl or Compiz for more information.
XSESSION code> in /etc/rc.conf code>[edit] Xfce4
[edit] With xfce4-session
xfce4-session is installed by default as part of the xfce4 meta-package. If you installed xfce4 this way, the following will work.
First, it is necessary to create a script that will start Compiz and gnome-window-decorator with the correct libraries and switches.
| File: /usr/bin/compizrc |
LD_LIBRARY_PATH=/usr/lib/opengl/xorg-x11/lib compiz --replace gconf & gnome-window-decorator |
| Code: Make the script executable |
chmod 755 /usr/bin/compizrc |
Now, edit the xfce4-session settings to point to this rather than xfwm4.
| File: /etc/xdg/xfce4-session/xfce4-session.rc |
[Failsafe Session] Count=4 Client0_Command=compizrc Client0_PerScreen=False Client1_Command=xfce4-panel Client1_PerScreen=True Client2_Command=xftaskbar4 Client2_PerScreen=True Client3_Command=xfdesktop Client3_PerScreen=False |
~/.config/xfce4-session/xfce4-session.rc code> file. Note also that you may need to delete content of the ~/.cache/sessions code> directory, if you still have xfwm4 rather than Compiz running.
Finally, create a script to start Xgl with Xfce4.
| File: /usr/bin/startxgl for NVIDIA |
#!/bin/bash Xgl -ac -accel xv:fbo -accel glx:pbuffer & xfce4-session |
| File: /usr/bin/startxgl for ATi |
#!/bin/bash Xgl -ac -accel xv:pbuffer -accel glx:pbuffer & xfce4-session |
| Code: Make the script executable |
chmod 755 /usr/bin/startxgl |
You will notice that xfce4-panel is now transparent, just like if you were using xfwm4's compositor. The pager will be distorted, but otherwise everything works beautifuly. Windows even minimize to the correct spot on the taskbar.
[edit] Without xfce4-session
If you compiled a minimal Xfce (without xfce4-session, xffm4, etc.), then you can use this altered startxgl script from the gnome script above:
#!/bin/bash echo ">Starting XGL at Display: $1" echo "========= XGL ============" Xgl :$1 -ac -accel xv -accel glx:pbuffer & sleep 3 echo "======= COMPIZ ===========" DISPLAY=:$1 LD_LIBRARY_PATH=/usr/lib/opengl/xorg-x11/lib/ compiz --replace switcher decoration wobbly fade minimize cube rotate zoom scale move resize place & sleep 3 echo "======= XFCE ============" DISPLAY=:$1 xfce-mcs-manager DISPLAY=:$1 gnome-window-decorator & DISPLAY=:$1 xftaskbar4 & DISPLAY=:$1 xfdesktop & DISPLAY=:$1 exec xfce4-panel
Again, xfce4-panel will be transparent as if you had the X.org composite extension turned on (but you don't) or if you use xfce4-svn, and the pager will be distorted. Everything else should be fine.
[edit] With startxfce4
To do it the old fashioned, or 'normal' way via startx/startxfce4 I did the following. First, startxfce4 shouldn't be called I don't think. just use an .xinitrc in your homedir and startx.
| File: ~/.xinitrc |
#!/bin/sh /usr/bin/startxfce4 |
Now as root, we create compizrc code>, like above. Note however that for me, it worked best/only without the DISPLAY variable.
| File: /usr/bin/compizrc |
#!/bin/bash LD_LIBRARY_PATH=/usr/lib/opengl/xorg-x11/lib/ compiz --replace gconf > ~/compiz.log 2>&1 & sleep 1; gnome-window-decorator > ~/gnome-window.log 2>&1 & |
Obviously the output redirections are optional (but handy for debugging). The sleep 1; might also be removed to speed things up. If things go TO fast however, you might get in trouble though. Don't forget to chmod 755 /usr/bin/compizrc
Lastly we need to use this new compizrc code> instead of the default xfce4 window manager.
Again, as root edit /etc/xdg/xfce4-session/xfce4-session.rc and replace xfwm4 code> with compizrc code>
| File: /etc/xdg/xfce4-session/xfce4-session.rc (old) |
Client0_Command=xfwm4 |
| File: /etc/xdg/xfce4-session/xfce4-session.rc (new) |
Client0_Command=compizrc |
Now only one thing is left, start Xgl. As above you can copy startx in /usr/bin/startx to /usr/bin/startxgl and make the following change:
| File: /usr/bin/startxgl (old) |
|
xinit $clientargs -- $serverargs -deferglyphs 16 & |
| File: /usr/bin/startxgl (new) |
|
xinit $clientargs -- /usr/bin/Xgl -ac -accel xv -accel glx:pbuffer $serverargs -deferglyphs 16 & |
Client0_Command code> depend on wether startx or startxgl is beeing used as 3D apps don't appear to work as they should and switching back to the 'old way' is required.Edit: it seams that when using the startxfce4 script, the /etc/xdg/xfce4-session/xfce4-session.rc file (and the .xinitrc code>) get ignored thus starting a non Xgl desktop. Making 'switchin code>' not needed. startxfce4 for oldschool, startxgl for new style
[edit] Entrance
- Emerge latest entrance:
echo "=x11-misc/entrance-0.9.0.007 ~x86" >> /etc/portage/package.keywords emerge -av entrance
- Use the ecore_config utility to change the xserver string (choose according to your video card):
# ATI ecore_config -k "/entranced/xserver" -s "/usr/bin/Xgl -ac -accel xv:pbuffer -accel glx:pbuffer -nolisten tcp" -c /etc/entrance_config.cfg # NVIDIA ecore_config -k "/entranced/xserver" -s "/usr/bin/Xgl -ac -accel xv:fbo -accel glx:pbuffer -nolisten tcp" -c /etc/entrance_config.cfg
- Restart entrance.
[edit] Qingy
It is quite easy to change Qingy to start Xgl instead of a regular X server. All you need to do to make it start Xgl is change 2 lines in /etc/qingy/settings
| File: /etc/qingy/settings |
... # x_server = "/usr/X11R6/bin/XFree86" x_server = "/usr/bin/Xgl" # x_args = "-nolisten tcp" x_args = "-ac -accel xv -accel glx:pbuffer -nolisten tcp" ... |
Now Qingy should start Xgl instead of regular X. To make KDE and GNOME load Compiz you need to export a variable. KDEWM for KDE and WINDOW_MANAGER code> for GNOME. It is easiest to do this in /etc/X11/Sessions.
You need to have followed the instructions for adding plugins to gconf-editor. Then make a /usr/bin/compizrc as shown and chmod +x it.
| File: /usr/bin/compizrc |
#!/bin/bash LD_LIBRARY_PATH=/usr/lib/opengl/xorg-x11/lib compiz --replace gconf & sleep 2 gnome-window-decorator & setxkbmap -model itouch -layout gb & ## Change/Remove as appropriate |
Then edit the appropriate file (or both) in /etc/X11/Sessions
For KDE:
| File: /etc/X11/Sessions/kde-3.5 |
#!/bin/sh export KDEWM="/usr/bin/compizrc" exec /usr/kde/3.5/bin/startkde |
Or for GNOME add this to the top of the file :
| File: /etc/X11/Sessions/Gnome |
#!/bin/sh export WINDOW_MANAGER="/usr/bin/compizrc" ... |
For Xfce4 edit /etc/xdg/xfce4-session/xfce4-session.rc as shown in a previous section.
Hopefully Qingy should now start Xgl and Compiz instead of X and some other WM.
[edit] KDE users general startup script
This is a very simple startup script for ( nVidia or ATI ) + beryl ( and probably compiz ) users.
| File: ~/startxgl.sh |
Xgl :$1 -ac -accel xv:fbo -accel glx:pbuffer & # replace with # Xgl -br -ac -accel glx:pbuffer -accel xv:pbuffer # for ATI DISPLAY=:$1 beryl-xgl --replace & DISPLAY=:$1 dbus-launch emerald & # If you are not using be beryl , but using compiz (vanilla) , this is the part where you launch it . Try # compiz --replace gconf & # sleep 3 # gtk-window-decorator --replace & DISPLAY=:$1 startkde & # This is where you start KDE # KWin will detect that another window manager is already running so it will not start. DISPLAY=:$1 xterm & # you should always keep an xterm open # Feel free to comment the lines that you don't approve |
launch it with
~/startxgl 1 code>
Also this script gets useful whenever you want to test or debug Xgl . Most likely for people who don`t wanna mess with KDM.
