Compton (shadow effects and more)

← Go back to Tips and Tricks

Compton is a standalone lightweight compositor for X (the graphic server on Linux systems). It provides 2D graphical acceleration and this allow us to drop shadows under the windows, make elements fade as they (dis)appear, draw (semi)transparent menus and notifications, etc.




Installation:
  • We're going to installing Compton from a PPA (ensuring latest version in our system). Open LXTerminal and type the following commands:

    sudo add-apt-repository ppa:richardgv/compton
    sudo apt-get update && sudo apt-get install compton
  • Now, if we want it to execute on every startup, edit the session file (open LXTerminal and paste "sudo leafpad /etc/xdg/lxsession/Lubuntu/autostart" without the quotes)



    ...and add the following line:

    @compton -c -r 16 -l -24 -t -12 -G -b
    Don't forget to include the "@" symbol, or it won't work. These parameters are my Compton configuration. If you want to use your own, but you don't know how they work, you can read this guide (sorry, only Spanish, Google translated here)

  • And we're over! Now re-login onto your Lubuntu desktop (or execute "compton -c -r 16 -l -24 -t -12 -G -b && exit" at LXTerminal for immediate testing!

Additional notes:

  • Devin shows how to install Compton on Precise Pangolin and solve the dependency on package libconfig9. Just go here, download and install it.
  • Van Long solved the shadow problem using Conky (the famous resource meter). Just edit "~/.config/compton.config" and add this line:

    shadow-exclude = [ "g:si:Noti" ];


← Go back to Tips and Tricks

35 comments:

  1. this is the guide I wrote a while ago. You may want to use it to improve this guide!

    http://www.linuxdistrocommunity.com/forums/thread-584-post-3398.html

    ReplyDelete
  2. Wow, firsr, congratulations for this new section. Its a good idea.

    Well, i have a problem with compton, the inactive opacity dont work, please can you help me?

    This is my conf:
    @compton -cCGfF -i 0.6 -e 0.6

    Lubuntu 12.04

    ReplyDelete
  3. Jojo, sorry for answering so late. I'm not really sure why it doesn't work, but try to use the -cC option (and others) separatedly:

    compton -cC -G -fF -i 0.6 -e 0.6 -b

    or just try specifying options in a more human-readable format using the ~/.compton.conf file, as explained here:

    https://wiki.archlinux.org/index.php/Compton

    ReplyDelete
  4. thanks at last compton work in my laptop.

    Thank you!

    ReplyDelete
  5. Hello ! Compton is very light for Lubuntu, but I have a little problem (It's a live session, for testing ):
    http://pix.toile-libre.org/upload/original/1356632200.png
    How to disable the shadows from the cairo dock's desklets ? Thank for your help and sorry for my bad english (I'm French)

    ReplyDelete
  6. It's easy, at least with Conki. You must add this:
    --shadow-exclude ’g:e:cairo-dock'

    to the command line. You must specify the window class, I think it's "Cairo-dock" (that's how Compiz names it).

    Also, you can add any program yuo want to exclude, like weather widgets or such.

    I hope this is usefu. Don't worry about your english, it's great. I'm spanish, btw ;)

    ReplyDelete
  7. Thanks ! But it doesn't work. I think that 'Cairo-dock' is only the windows class of the dock. The desklets have an other name. I will find it.

    ReplyDelete
  8. Will compton be included in Raring by default or including in the repositories?

    that would be nice to not have to install ppa's to have the fastest Windows manager around.
    Thanks

    Taiebot

    ReplyDelete
  9. I would like to see this included on the next release (13.04). Then we would have the option to enable accelerated compositing. I would like the added eye candy. By the way are those icons that are displayed on the file browser coming to the Lubuntu Box Theme? I like the Space Invaders one :)

    ReplyDelete
  10. Yes, it's a (more or less) updated screenshot. Expect more changes. Box is evolving a lot!

    ReplyDelete
  11. Hi,

    I can't make comtpon work with a config file on startup.

    Do you know where I could get some help to try to resolve that ?

    Thanks :)

    ReplyDelete
  12. You don't need to specify any, if you put already in ~/home but you call for another using "compton --config path/to/yourfile". You can copy the default config file Be sure to use the last compilation provided in the PPA mentioned above.

    If you still have problems tell me and we'll look for a solution.

    ReplyDelete
  13. Thanks :)

    So my problem was that with "@compton --config ~/.config/compton.conf -b" in "/etc/xdg/lxsession/Lubuntu/autostart" file didn't run compton.

    If I have only "@compton -b", compton runs, but makes shadow on lxpanel, while it shouldn't, as I have "" in my ".config/compton.conf" file.

    If I run "compton -b" in a terminal, I have the wanted behavior (no shadow on lxpanel) : here it seems to respect my compton.conf file.

    Any idea ?

    ReplyDelete
  14. Oops, I made a mistake :
    I have "no-dock-shadow = true;" in my compton.conf file.

    Thanks !

    ReplyDelete
  15. lxpanel could be a dock, or not (depending on its settings). Anyway you should try "--shadow-exclude ’g:e:lxpanel'" (without the double quotes, of course) to get rid of the panel shadow. Try and let me know the result.

    ReplyDelete
  16. I added "--shadow-exclude ’g:e:lxpanel'" in my compton.conf file, I still have shadow on lxpanel.

    Moreover, in lxpanel settings, I do have "considered as a dock" or something like that.

    What is weird, it is that if I run "compton -b" manually, it does respect my compton.conf file by not drawing shadow on lxpanel.

    ReplyDelete
  17. To use a config file for Compton decorator the formula "compton --config ~/.config/compton.conf -b" is not usable. The problem is the incorrect syntax of the path to your config file. The "~/" formula is a bash syntax, which is not understandable for Compton. So when you set the path to your config file you have to use the full path eg. "compton --config /home/yourname/.config/compton.conf
    -b" which is now understandable for Compton. And to autorun Compton you should make a "compton.desktop" file in "/etc/xdg/autostart/" as root. The content of the file is:

    [Desktop Entry]
    Encoding=UTF-8
    Type=Application
    Name=compton
    Name[en_US]=compton
    Exec=compton --config /home/yourname/.config/compton.conf -b
    Comment[en_US]=
    StartupNotify=true

    ReplyDelete
  18. Thanks for the tut. I just dumped xcompmgr for compton on Lubuntu 13.10 and started with your settings. I got the shadows removed from the dock with "-C" but am going to fiddle with the shadowing effects( don't much care for the shadowed edges on the windows). This helped: https://github.com/chjj/compton/blob/master/man/compton.1.asciidoc
    Thanks again!!

    ReplyDelete
  19. Just a little addendum to my previous post for Lubuntu 13.10 users to autostart compton: you have to edit the following file: "/home/yourname/.config/lxsession/Lubuntu/autostart" (without quotes of course)
    @compton --config /home/yourname/.config/compton.conf -b

    In my case using Nvidia Proprietary driver v304 Compton crashes at startup, but using v319 everithing goes well.

    ReplyDelete
  20. You will be happy with the new beta 331. It's extremely stable and it works fine with Compton.

    ReplyDelete
  21. Lots of Windows XP migrations happening these days - desperately needing Compton for 14.04 Trusty:

    http://ppa.launchpad.net/richardgv/compton/ubuntu/dists/trusty/main/binary-i386/Packages 404 Not Found

    Any news on a fix?

    ReplyDelete
  22. I guess Richard is doing it as fast as he can. In the meantime use the Saucy package. It still works: https://launchpad.net/~richardgv/+archive/compton/+packages

    ReplyDelete
  23. This comment has been removed by the author.

    ReplyDelete
  24. Hi, thanks for this!

    A little tip:

    For quick disabling compton while gaming/watching videos etc, you can use keyboard shortcuts:

    run "leafpad ~/.config/openbox/lubuntu-rc.xml" without the quotes,

    scroll to "< chainQuitKey>C-g< /chainQuitKey>", (without the space after <)

    below it, copy+paste

    < !-- Start keybindings for composite switching -->
    < keybind key="W-c">
    < action name="Execute">
    < command>compton -c -C -r 16 -l -24 -t -12 -G -b< /command>
    < /action>
    < /keybind>
    < keybind key="W-S-c">
    < action name="Execute">
    < command>killall compton< /command>
    < /action>
    < /keybind>
    < !-- End keybindings for desktop switching -->

    WARNING: delete the space AFTER EVERY < (smaller than) symbol!
    I can't paste it here whole cause blogger starts to use those tags and half the comment disappears.

    And your done! Use Super (windows key)+c to start compton, and super+shift+c to end it.

    Note: replace the command after the first < command> tag with your own, the one I used here uses shadows, but also disables them on panels/docks.

    ReplyDelete
  25. I've tried this, but it doesn't work... I'm running Lubuntu 14.04

    ReplyDelete
  26. @Alessio, what do you mean? Have you tried autostart compton (without any parameters) at "Default applications for LXSession"?

    ReplyDelete
  27. @Rafael, yes, now it starts automatically, but what does your
    "compton -c -r 16 -l -24 -t -12 -G -b" do exactly ?
    I cannot see any difference.. only the terminal now is transparent ;)

    ReplyDelete
  28. Those modifiers on the command make a wide and deeper shadow, like the one on ElementaryOS. The default is a little thinner. You can read the documentation at the guide mentioned: http://gespadas.com/xcompmgr-compton

    ReplyDelete
  29. The issue is that the numbers in the command string should not have negatives in front of them.

    compton -c -r 16 -l 24 -t 12 -G -b

    Huge difference...

    ReplyDelete
  30. Two questions.

    1. Is there a way of specifying opacity for a particular application, such as terminal for example, and not affecting all others.

    2. Apparently compton treats screenlets as inactive windows, and shadows and dims them accordingly. Is there anyway of solving this problem?

    ReplyDelete
  31. There's no way to set per window transparency or shadow, for the moment. About the screenlets, the best idea is make compton ignore them, so the included shadows in PNGs look fine. The problem is each screenlet has a unique window x-class name.

    ReplyDelete
  32. Thanks.
    The compton.conf line "shadow-exclude = [ "g:si:conky" ];" worked like a charm.
    Nevertheless, the inactive-dim effect is still there. Is there any way of getting rid of it?

    ReplyDelete
  33. van long's link (in the first comment) should be https://bbs.linuxdistrocommunity.com/showthread.php?tid=584

    ReplyDelete
  34. Nice tip. Here my tip.
    This is how you can get composition in Lubuntu 14.04:
    1.sudo apt-get install compton (without add PPA)
    2. Go to Applications menu, Preferences, Default Applications for Lxsession.
    3.Go to autostart, add another startup process compton -b
    4. Next, edit ~/.config/compton.conf (make a backup if needed).
    5. Copy and pas my configuration:
    # Shadow
    shadow = true;
    no-dnd-shadow = true;
    no-dock-shadow = true;
    clear-shadow = true;
    shadow-radius = 12;
    shadow-offset-x = -15;
    shadow-offset-y = -15;
    # shadow-opacity = 0.7;
    # shadow-red = 0.0;
    # shadow-green = 0.0;
    # shadow-blue = 0.0;
    shadow-exclude = [ "g:si:xfce4-noti","g:si:conky" ];
    # shadow-exclude = "n:e:Notification";
    shadow-ignore-shaped = false;

    # Opacity
    menu-opacity = 1;
    inactive-opacity = 1;
    frame-opacity = 1;
    inactive-opacity-override = true;
    alpha-step = 0.06;

    # Fading
    fading = true;
    fade-delta = 40;
    fade-in-step = 0.4;
    fade-out-step = 0.4;
    # no-fading-openclose = true;

    # Other
    mark-wmwin-focused = true;
    mark-ovredir-focused = true;
    use-ewmh-active-win = false;
    detect-rounded-corners = true;
    detect-client-opacity = true;
    refresh-rate = 0;
    vsync = "none";
    dbe = false;
    paint-on-overlay = false;
    sw-opti = false;
    unredir-if-possible = false;

    # Window type settings
    wintypes:
    {
    tooltip = { fade = true; shadow = false; opacity = 0.85; };
    };

    ReplyDelete
  35. Thanks, Mindaugas for your config file. I'll check this shadows on my laptop :)

    ReplyDelete