blogage.de > Forlong > Forlong's Blog > Entry > 06 January 2008 > Compiz-Switch
  De | En | Sign up | Login

Compiz-Switch

Compiz-Switch is a simple program to switch Compiz off and on easily.

If you are looking for a simple yet effective way to switch between Compiz and the window manager of your desktop environment, then this is for you.
Compiz-Switch provides this on a single click.


  • If Compiz is running, it will switch to the default window decorator of your desktop environment.

  • If Compiz is not running, it will be launched immediately.

There is no need to compile anything and the only dependency is a GNOME, KDE or Xfce environment with a running version of Compiz.

Available versions

If you'd like to have a version for your distribution as well, please go here.

Installation

If you are on Ubuntu, all you need to do is download the deb linked above and double-click it afterwards.

Do not just copy & paste the following to your blog/forum – find out why

For other distributions, first download and extract the archive – e.g. for the "source" version, do

wget http://blogage.de/files/3531/download -O- | tar -xzf - 

Then change to the extracted folder (directory depends on the version you downloaded):

cd compiz-switch-0.4.0~source

Now you can choose between the usual way to install and checkinstall. The latter will install a basic deb-package that you can remove via apt-get or Synaptic/Adept. (This should also work for Suse/rpm.)
For Compiz compiled from source it's best to install via make install.

Usual way (make install)

All you need to do is (make sure you are root when not using sudo):

sudo make install
(there's no nee to 'make' anything first)

Do not remove the folder afterwards – you'll need it, in case you want to remove Compiz-Switch again.
In order to do so, navigate to the directory again and run:

sudo make uninstall

Checkinstall

First you need to install checkinstall itself:

sudo apt-get install checkinstall

Then use this command to install:

sudo checkinstall


Usage

After you installed Compiz-Switch it should show up in the menu under:


    GNOME
    Applications → Accessories → Compiz-Switch

    KDE
    K-menu → Utilities → Compiz-Switch

    Xfce
    Applications → Accessories → Compiz-Switch


Panel icon


  • If you want the icon to show up in the panel, all you have to do in GNOME and KDE is drag & drop the icon from the menu to the panel.


  • For Xfce this is unfortunately a little more complicated, because it doesn't support d&d for that. Here's a little workaround:
      First run Applications → Accessories → Appfinder
      Then do a right-click on the panel and choose Add New Item in the context menu and double-click Launcher.
      Now you can drag & drop Compiz-Switch from the Appfinder in the field with the New Item icon.
      Finally remove the New Item entry and choose Close.
    Now you should have the icon in the panel.


Additional options

To get a list of all available options, run:

compiz-switch --help

Kill and restore Screenlets along with Compiz

Version 0.4 supports quitting all running Screenlets when switching off Compiz.

There are two options available how to restore them, when running Compiz again (use only one of them at a time, of course):


  • Restore exactly the Screenlets you were running before
    Add the -s argument when using Comiz-Switch to use this:
    compiz-switch -s


  • Restore only the Screenlets you added to you autostart programs
    (using screenlets-manager) – the argument for that is -sa:
    compiz-switch -sa


compiz-switch-status-thumb

Use the icon as a status icon (experimental)

When adding the -c argument, the icon for Compiz-Switch will change according to the status of Compiz

compiz-switch -c

This seems to work only in the GNOME panel, if you stored a starter for Compiz-Switch there.




You can, of course, use multiple arguments at a time, e.g.
compiz-switch -s -c

Thumbnail?compiz-switch-arguments

Previous Versions


Icon Design

By gavintlgold, also founder of FusionCast.

Trackbacks



No trackbacks, yet.

Comments Help Feed

Thesa (Anonymous)
4 years ago

Great idea!

Some details:

Instead of using "sudo make install", and keep the folder and do "sudo make uninstall", you can use "sudo checkinstall": it'll make a deb package and install it. And to uninstall, just remove the package.
(In this case, to make a valid package, you need to edit the Version settings and set it with a number. This package *must not* be distributed, it doesn't manage dependencies.)

Under my XFCE desktop, your script switch between compiz and... kwin :-( Maybe a problem to detect the current desktop environment ?

adrian (Anonymous)
4 years ago

thanks man. just the thin iv been looking for:)

4 years ago

[quote]Under my XFCE desktop, your script switch between compiz and... kwin :-( Maybe a problem to detect the current desktop environment ?[/quote] That's because I couldn't find a way to detect the DE in use - so instead of that, the program checks which window manager is installed, in that order:
Metacity (GNOME)
Kwin (KDE)
Xfwm (Xfce)

You have obviously kwin installed, that's why it launches that one instead of xfwm4.

I'm working on a workaround and I think I have found one this very minute. Please check again later for an update.

As for checkinstall: I always considered it somewhat hacky but I guess there's no harm adding it to the Install section.

Thanks for the feedback.

Jose (Anonymous)
4 years ago

Cool, i have recorded a video, it's in youtube; it's not very useful but it's something =).

http://www.youtube.com/watch?v=adktPq5_pFA

Jamie A. Thom (Anonymous)
4 years ago

Excellent wee app - works wonderfully with Linux Mint KDE edition 4.0 Daryna.
Great work, thanks!

Yoeri (Anonymous)
4 years ago

I always searched for something like this ... I only miss one feature ... automatically disable compiz when running a laptop on battery and automatically switch compiz on when running on AC.

Fede (Anonymous)
4 years ago

Excelent!
I was looking for this.
Thanks.

Henrique (Anonymous)
4 years ago

Thanks a lot for this useful app!

Jaapz (Anonymous)
4 years ago

Thx for this script! Exactly what ive been looking for, thx!

Jadd (Anonymous)
4 years ago

That is cool. At first, I thought it was a clone of fusion-icon, but now I realise this closes compiz if it's running, and it opens it if it's not, and that's it. Thanks for this.
Can I find a similar script for turning XGL on and off? I've got an ATI graphics card, and this would make running games a lot easier.

amadeus266 (Anonymous)
4 years ago

I wrote my own script for this this but this is a much better package.

Rob Loach (Anonymous)
4 years ago

Excellent application! Try to get this into the compiz package repository!!!

Ryan (Anonymous)
3 years ago

Great little script, thanks for sharing. I noticed that it doesn't seem to work with more than one user running compiz at the same time. To get it to work, I replaced line 36 with this:

COMPIZ_RUNNING=`ps -u $USER | grep $COMPIZ_BIN | awk '{print $1}'`

AFAIK, the $USER environment variable should always be set. I also changed
killall $COMPIZ_RUNNING
to
kill $COMPIZ_RUNNING
in the switch to xfwm4 section, but as I don't have xfce, that is totally untested. I hope this helps anyone that has multiple compiz users on their computer.

myro (Anonymous)
3 years ago

thx man for sharing this.
really usefull script!

Jonny (Anonymous)
3 years ago

i installed with the deb. I'm using eeeXubuntu it works really well. Thanks man!

HeartBurn Kid (Anonymous)
3 years ago

Every time I try to download either the .deb package or the source, I get a 404 error. Am I missing something?

Tripmonkey_uk (Anonymous)
3 years ago

Just what I was looking for and tested in Ubuntu Hardy Heron beta with the stock desktop effects.
Works like a charm :D

I'd second the feature of automatically disabling Compiz when a laptop switches to battery power, but I think that will need to be implemented by Gnome Power Management etc.?

p.s I'll let others know about this on my site soon :)

dima (Anonymous)
3 years ago

Is there a way to make an amd64 version of this?

3 years ago

Yeah, I think it's generally time for an update. I have a working version on my computer with the ability to kill Screenlets with Compiz and restore them when switching to Compiz again.

As far as I know, I just failed to configure this correctly when making the deb package, because the architechture shouldn't be relevant at all.

I'll look into this.

dima (Anonymous)
3 years ago

Thanks :)

Stefan (Anonymous)
3 years ago

On my ubuntu hary installation it switches compiz off, but not on.

3 years ago

I have just uploaded the new version (the deb package should be suitable for all architectures now).
Please try again with this one.

Deeta (Anonymous)
3 years ago

I have the same trouble as Stefan, right after installing (0.4) it would only work to switch compiz on. And now after a reboot it only works as a restart button for metacity. What I noticed though is that the compiz-switch command is still running in the console after the switch is complete. I kinda thought it was supposed to terminate itself and thus be super memory slim ^-^

3 years ago

What's the output when running

compiz-switch -o

in the terminal (twice)?

Deeta (Anonymous)
3 years ago

Basic state after X starts is: Compiz is activated

1st time:
diddl@ubuntu:~$ compiz-switch -o
/usr/bin/compiz-switch: line 233: [: too many arguments
Checking for Xgl: not present.
Detected PCI ID for VGA: Flags: bus master, VGA palette snoop, stepping, fast Back2Back, 66MHz, user-definable features, ?? devsel, latency 0
Flags: bus master, VGA palette snoop, 66MHz, medium devsel, latency 64
01:00.0 0300: 10de:0402 (rev a1) (prog-if 00 [VGA controller])
Checking for texture_from_pixmap: present.
Checking for non power of two support: present.
Checking for Composite extension: present.
Comparing resolution (1680x1050) to maximum 3D texture size (8192): Passed.
Checking for nVidia: present.
Checking for FBConfig: present.
Checking for Xgl: not present.

((at that point I do not get back the console prompt and I do a ctrc-c))

((which then goes on to crash compiz whereupon I go Alt-Tab-1 and kill compiz so that gnome starts metacity as a fallback))

((after switching back I can see this in my console window where i issued ctrl-c))
*** glibc detected *** /usr/bin/compiz.real: double free or corruption (!prev): 0x000000000078f8a0 ***

--------------------------------------
2nd try (after restarting X)
This time I will issue the second compiz-switch -o in a new console window :)

diddl@ubuntu:~$ compiz-switch -o
/usr/bin/compiz-switch: line 233: [: too many arguments
Checking for Xgl: not present.
Detected PCI ID for VGA: Flags: bus master, VGA palette snoop, 66MHz, medium devsel, latency 64
01:00.0 0300: 10de:0402 (rev a1) (prog-if 00 [VGA controller])
Checking for texture_from_pixmap: present.
Checking for non power of two support: present.
Checking for Composite extension: present.
Comparing resolution (1680x1050) to maximum 3D texture size (8192): Passed.
Checking for nVidia: present.
Checking for FBConfig: present.
Checking for Xgl: not present.

((opening 2nd terminal prompt))
diddl@ubuntu:~$ compiz-switch -o
/usr/bin/compiz-switch: line 233: [: too many arguments
Checking for Xgl: not present.
Detected PCI ID for VGA: Flags: bus master, VGA palette snoop, 66MHz, medium devsel, latency 64
01:00.0 0300: 10de:0402 (rev a1) (prog-if 00 [VGA controller])
Checking for texture_from_pixmap: present.
Checking for non power of two support: present.
Checking for Composite extension: present.
Comparing resolution (1680x1050) to maximum 3D texture size (8192): Passed.
Checking for nVidia: present.
Checking for FBConfig: present.
Checking for Xgl: not present.

3 years ago

Thanks Deeta, now I need your output of

ps -o comm= -C compiz.real

when Compiz is active and also when it's not running.

ZOMGxuan (Anonymous)
3 years ago

Just want to confirm the bug by Deeta. When I installed compiz-switch on hardy, the same thing happened. I think this has something to do with Hardy (or gnome) trying to preserve the state it was in (i.e Compiz or No Compiz). So when I using compiz and ran compiz-switch, compiz-switch attempted to change to metacity, but it just lagged a bit (window borders disappeared) and then compiz restarted.

ZOMGxuan (Anonymous)
3 years ago

nice easter egg by the way.

3 years ago

ZOMGxuan, I need the output of the above mentioned command to fix this -- because it works flawlessly on my Hardy install and I'm a little clueless right now, what fails for you guys there.

Deeta (Anonymous)
3 years ago

((when compiz is running after booting))
diddl@ubuntu:~$ ps -o comm= -C compiz.real
compiz.real

((pretty unspectacular.. hope that is what you were looking for))
((switching to metacity by using 'no desktop effects'))

diddl@ubuntu:~$ ps -o comm= -C compiz.real
compiz.real

((same outsput... strange... but yeah compiz seems off, no desktop zoom, no wobbly windows.... ))

((just switched compiz on again and noticed something weird))

diddl@ubuntu:~$ ps -o comm= -C compiz.real
compiz.real
compiz.real

((despite my lack of gnu/linux knowledge I feel the vibe of wonky hardy configuration of my compiz... this means it does not really terminate when I shut compiz down, aye?))

3 years ago

Aha! That is weird and obviously a bug in Hardy.
The question is, whether I should work around it or not...

I will try to reproduce this here somehow.
Thank you very much for the feedback.

@ZOMGxuan: can you confirm that on your system?
And are you using a Nvidia card too?

Deeta (Anonymous)
3 years ago

With the help of the Zorael in the Ubuntu Forums I have created a pretty dirty hack. Not that it will appeal to anyone but me, but at least I can switch compiz off and on now without slowing my system to a crawl :D
Here it is:

#!/bin/bash
while true;
do
if [ "$(pidof compiz.real)" ] && [ "$(pidof metacity)" ];
then
killall --signal=9 compiz.real
echo CompiZombie detected and terminated
sleep 2s
else
sleep 2s
fi
done

3 years ago

Deeta and ZOMGxuan,

can you confirm the latest version (0.4.1) works for you?

s² (Anonymous)
3 years ago

Hi,
thanks for this little app, it's very usefull. I have only one problem, if I use only 'compiz-switch', I have to run it 4 times, to change really from compiz to metacity, and to go back to compiz only once is necessary. If I put the '-o' at the end it works perfectly.

Thanks

dell XPS M1330 + Ubuntu 8.04 LTS + compiz-switch 0.4.1

Deeta (Anonymous)
3 years ago

I still have the same problem with 0.4.1 as with 0.4.0.
(of course I stopped my script before trying :)

The output has a variation in a slightly minor way though. (different line and error message in the beginning)

diddl@ubuntu:~$ compiz-switch -o
/usr/bin/compiz-switch: line 239: [: compiz.real: unary operator expected
Checking for Xgl: not present.
Detected PCI ID for VGA: Flags: bus master, VGA palette snoop, stepping, fast Back2Back, 66MHz, user-definable features, ?? devsel, latency 0
Flags: bus master, VGA palette snoop, 66MHz, medium devsel, latency 64
01:00.0 0300: 10de:0402 (rev a1) (prog-if 00 [VGA controller])
Checking for texture_from_pixmap: present.
Checking for non power of two support: present.
Checking for Composite extension: present.
Comparing resolution (1680x1050) to maximum 3D texture size (8192): Passed.
Checking for nVidia: present.
Checking for FBConfig: present.
Checking for Xgl: not present.
((at that point it again does not return to the command prompt))

3 years ago

Please try again with the latest version. The problem is, I'm tapping around in the dark here as I can't reproduce any of your problems.

I have scrapped the -o argument in the latest version, because s² seems to have problems with it -- and Deeta, trust me the script is not running anymore (you can check that in 'ps -A') once the switch is done (the window manager you switched to takes over).
But to avoid this confusion I tweaked the switch a bit, so now you are able to use the terminal prompt after the switch (it's not visible when switching to Compiz but it works nonetheless).

Deeta (Anonymous)
3 years ago

www=wobbly windows working ^-^
!www= no wobbly windows

((fresh boot: www, so lets try to turn em off))
diddl@ubuntu:~$ compiz-switch
((!www, success... now for trying to turn them on again))
diddl@ubuntu:~$ compiz-switch
/usr/bin/compiz-switch: line 220: kill: compiz.real: arguments must be process or job IDs
((!www, failure :-/, lets confirm it))
diddl@ubuntu:~$ compiz-switch
/usr/bin/compiz-switch: line 220: kill: compiz.real: arguments must be process or job IDs
((!www, failure :-/, yet again ))
diddl@ubuntu:~$ compiz-switch
/usr/bin/compiz-switch: line 220: kill: compiz.real: arguments must be process or job IDs
((!www, failure :-/, yeah I am stupid for trying again ^-^ ))
diddl@ubuntu:~$ pidof compiz.real
6251
diddl@ubuntu:~$ killall -9 compiz.real
diddl@ubuntu:~$ compiz-switch
diddl@ubuntu:~$ Checking for Xgl: not present.
Detected PCI ID for VGA: Flags: bus master, VGA palette snoop, 66MHz, medium devsel, latency 64
01:00.0 0300: 10de:0402 (rev a1) (prog-if 00 [VGA controller])
Checking for texture_from_pixmap: present.
Checking for non power of two support: present.
Checking for Composite extension: present.
Comparing resolution (1680x1050) to maximum 3D texture size (8192): Passed.
Checking for nVidia: present.
Checking for FBConfig: present.
Checking for Xgl: not present.
((www, yay! success... so lets try to turn em off again))
diddl@ubuntu:~$ compiz-switch
diddl@ubuntu:~$ *** glibc detected *** /usr/bin/compiz.real: double free or corruption (!prev): 0x000000000078fd90 ***

diddl@ubuntu:~$ compiz-switch
/usr/bin/compiz-switch: line 220: kill: compiz.real: arguments must be process or job IDs
diddl@ubuntu:~$

Deeta (Anonymous)
3 years ago

@Forlong: I completely understand ^-^ trying to work around some compiz bug which does not even manifest on your machine must be horribly tedious ;-) So a big thanks :D +textual token of appreciation :)

And yeah I trust you that the switch terminated itself :) I just do not know too much about Gnu/Linux and silently assumed until now that 'not returning to prompt'='app still running'

I hope my console output helps to some degree :) (as I do not really know which parts are relevant to you and which are not)

3 years ago

I'm sorry, I did a stupid mistake there. Please try again with the latest version I just uploaded.

Deeta (Anonymous)
3 years ago

you are certainly getting somewhere :D while the reliability of switching on/off is still somewhat fickle it is at least succeeding to switch it on and off now if one keeps pressing the compiz-switch-icon :D

With me It seems that everytime compiz crashes in this way when turned off: "*** glibc detected *** /usr/bin/compiz.real: double free or corruption (!prev): 0x000000000078fd30 ***" one of the Compiz-Zombies is raised.
So what Compiz-Switch 0.4.3 does with my box seems to be the following:

1. if CompizZombie=false and Compiz=ON then activate metacity
no-brainer as this is the normal behavior ^-^

2. if CompizZombie=false and Compiz=OFF then activate compiz
again normal behavior ^-^

3. if CompizZombie=true and Compiz=OFF then kill zombie (but does not activate compiz)
This is what has improved in 0.4.3 for me, while not doing what it is expected to do this prevents undue accumulation of dead Zombies.. err Compiz ;-) and after all when pressing the button again it works. Yay! right direction :D

4. if CompizZombie=true and Compiz=ON then fail to deactivate compiz and tell me
"/usr/bin/compiz-switch: line 224: [: compiz.real: binary operator expected" (when two compiz.real processes present)
or
"/usr/bin/compiz-switch: line 224: [: too many arguments" (when six compiz.real processes were present)

Case four only happens if I use the Appearance Preferences panel in between to toggle compiz instead of using compiz switch.

Jack (Anonymous)
3 years ago

Hello, I don't understand if the effect is 'permanent': does this application allow to switch compiz off and prevent it to be reloaded on next boot? If not, how can I disable compiz being automatically activated on boot?
Many thx

Jack (Anonymous)
3 years ago

Ok, sorry. The answer was much simpler than I thought.
Just delete the file ~/.kde/share/config/compizasWM and compiz won't be loaded at kde start.

hannenz (Anonymous)
3 years ago

very good work! Exactly what i am looking for. I just added functions to kill & restart kiba-dock alongside with compiz, no it's perfect for my needs.

Sam (Anonymous)
3 years ago

Please bare with me here... I'm pretty new to Ubuntu, and Linux. I had the Compiz Switch on my old laptop, and it worked fine... I was running Gutsy. I have Hardy now on my new laptop (Hardy Wubi, if that makes a difference.) The switch will turn off Compiz, but does not turn it back on. I have to go to system/preferences/appearance, and hit normal and all is fine. I like the one button approach though. Any ideas as to why it won't just turn compiz back on?

Thanks,
Sam

sawyer (Anonymous)
3 years ago

this is great! vielen dank!

Luca (Anonymous)
2 years ago

deactivate compiz.. and can't reactivate.. -.-

Suraj Mirpuri (Anonymous)
2 years ago

I have spent a few days writing a script myself... gah i feel so stupid, but anyway, I think mine has its uses as well. for instance, mine can be used better for single applications, and it can be contained in shortcuts for game launchers etc etc

 

http://ubuntuforums.org/showthread.php?t=1207203

 

knock yourselves out, there it is

huwie59 (Anonymous)
2 years ago

Thank YOU!!! This has resolved in 2 minutes something that has been bugging me for weeks.....Txs ;-))

Hasan (Anonymous)
2 years ago

I know the Original Post is quite old, but this still works great on Jaunty. Thank you, Forlong!

Vladimir (Anonymous)
2 years ago

Great! Thanks for this!

I have an old comp with not much RAM and I really need to sometimes turn Compiz on and off in order for certain applications to run smoothly. This is a great help.

The 'compiz-switch -s -c' on the panel works great (Ubuntu/Gnome user here). Thanks again!

Wakou (Anonymous)
2 years ago

Hi guys.. I have posted this in Compiz forum, xfce forum, openSuse Forum, on #IRC and elsewhere... No responses any where :(

 

If I run compix-switch or fusion-icon, and then select xfwm4 from its menu, it refuses to load, terminal gives me these errors:

Code:

* Setting window manager to Xfwm4

** (xfwm4:6218): CRITICAL **: Xfconf could not be initialized

** (xfwm4:6218): WARNING **: Missing data from default files
 * Setting window manager to Xfwm4

** (xfwm4:6230): CRITICAL **: Xfconf could not be initialized

** (xfwm4:6230): WARNING **: Missing data from default files

But If I now run "xfwm4 --replace &" from the terminal, it loads xfwm4 no problem.

(icewm seems to work ok from the fusion-icon menu)

Where do I look for these problems? What exactly is the call that fusion-icon makes when I click a WM in the fusion-icon menu? And where is it?

 

Can anyone point me in the right direction?

I have now uninstalled both fusion-icon and compiz-switch, in case they were out of date or conflicting. If I reinstalll, which first? both or just one?

 

 

DeadVirus (Anonymous)
2 years ago

This is great!!

I tought of doing a script... but then I found this one :D

Thank you very much!

Alex (Anonymous)
2 years ago

Hi,

Thanks for that useful script. Anyhow some strange behavior I experienced. I am working on Debian Lenny and I compiled compiz from source (0.8.4). If I executed compiz-switch -o in the terminal, everything went fine. Executing compiz-switch by clicking on the icon did not work properly (no window decoration compared to the execution in the terminal). The reason was the missing environment variable LD_LIBRARY_PATH=":/usr/local/lib", when compiz-switch was executed from the menu/panel. All other variables were present. Strange!
Maybe that helps somebody.

Alex

Ronk (Anonymous)
one year ago
Hello, under Ubuntu 10.04 Lucid Lynx (Alpha 3) it doesn't work. You can install it, but when you click on it, nothing happens.
Matthew (Anonymous)
one year ago

Confirmed, Ubuntu 10.04 Lucid Lynx LTS Released today

Compiz Switch installs fine but nothing happens when pressed.

Frax (Anonymous)
one year ago

Confirming the Lucid Lynx issue.

john (Anonymous)
one year ago

yes under 10.04 compiz switch doesnt work
one year ago

Sorry, seems like compiz.real doesn't exist anymore on Lucid. Run this to fix the script:

sudo sed 's/\.real//g' -i /usr/bin/compiz-switch
Roberto (Anonymous)
one year ago

It  works, thanks!

Max (Anonymous)
one year ago

Confirming that the fix works on Lucid Lynx

ajgreeny (Anonymous)
one year ago

Thanks for that fix for Ubuntu Lucid.

I was getting very frustrated with it not working to switch off compiz (it worked to switch it on) as I sometimes need to get rid of compiz when playing foobillard (snooker game).  I could do it with terminal, but the desktop icon for compiz-switch was so incredibly useful!!

Thanks again.

Cédric (Anonymous)
one year ago

Hi,

 

This is very interesting application, and as a previous comment, I'm interested in such tool for use on laptop to save energy in battery-mode.

I'm thinking to use your code and integrate it in a more complete applet (allowing to unactivate compiz, cam and put cpu to powersave mode when on battery)

focaccio (Anonymous)
one year ago

works great with ubuntu 10.04 after i applied the script patch...excellent tool...thanks!

btz (Anonymous)
one year ago

yeah after running this script it works fine,thanks

Kacker (Anonymous)
9 months ago

fuckin' awesome. this has got to be the best program on all the panels on my screen. Very utalitarian. 



Add comment


(not required)

Please enter the white text to the text field "code" (spam protection).

K T u Q i 6 G h x