Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transparent background in Emacs on Gnome Shell

This question is in the continuity of a previous question here: How make emacs console mode inherit shell colors

On Ubuntu 12.10 and Gnome Shell 3.6.2 I am running Emacs. Following http://www.emacswiki.org/emacs/TransparentEmacs I am able to set alpha transparency on my Emacs X window using:

(set-frame-parameter (selected-frame) 'alpha '(85 50))
(add-to-list 'default-frame-alist '(alpha 85 50))

Unfortunately this set the transparency for all the "items" in my emacs window, including the foreground containing text. As a result it becomes difficult to read the Emacs content. What I am looking for is a way to only set alpha value on the background. In this way, I'll be able to clearly see my Emacs window's content and to read information from windows behind emacs (I am successfully doing that with the very nice gnome terminal).

like image 439
Manuel Selva Avatar asked Feb 13 '13 10:02

Manuel Selva


People also ask

How do I make the background transparent in Emacs?

You can set transparency within Emacs by setting 'alpha frame parameter, This parameter specifies the opacity of the frame, on graphical displays that support variable opacity. It should be an integer between 0 and 100, where 0 means completely transparent and 100 means completely opaque.

How do I make my terminal gnome transparent?

Go to the apps manager and look for “gnome-terminal-transparency”. After doing this the terminal transparency option will be in the “colors” tab in the appearance settings.


1 Answers

It looks like this was asked a while ago, but I don't see where Manuel got a full solution. I had the same issue, and here's what I came up with.

If you have set the transparency of your shell and then run emacs -nw -q, the default behavior of Emacs seems to be to follow your shell settings. If yours doesn't do that, then chances are that you have set some conflicting settings somewhere. Maybe you're using a theme that sets the default background to a color? If so, you need to change that setting.

If you are using one of the built-in themes (e.g. adwaita, tango, wombat, etc), those have set the default background color which will override the alpha frame parameter. One solution is to find that theme file and comment out the line that sets this default. My themes are located at /usr/share/emacs/25.3/etc/themes. If it isn't there, then switch to your scratch buffer and evaluate the value of the data-directory variable. That directory should have a themes subdirectory. To modify the theme file, you may need admin privileges.

The code Jeff gave before should work. See section 28.4: Frame Parameters of the ELisp Manual. Also, check out 51.1.7: Custom Themes of the Emacs Manual. Jeff's code will set the transparency of the frame just for Emacs. This is good if you want it to be different from the transparency of your shell application. If you just want it to follow the behavior of your shell, like I said, that is the default.

like image 144
jsonofspock Avatar answered Sep 27 '22 23:09

jsonofspock