Transparent background in Emacs on Gnome Shell
Asked Answered
B

2

10

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).

Bitternut answered 13/2, 2013 at 10:27 Comment(0)
I
1

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.

Ireland answered 14/4, 2018 at 13:7 Comment(0)
H
-1

Mine worked fine - the foreground is visible in the color I'd set in .Xresources. Perhaps you can try that, something like:

emacs*foreground: gold
emacs*background: black

can go in ~/.Xresources, then use the command

$ xrdb ~/.Xresources

before calling emacs with those two lines you gave (in ~/.emacs):

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

I updated the above to include those two lines in ~/.emacs, because those are what set the transparency to work. Additionally, I do notice that when my emacs window loses focus, then the foreground also becomes transparent. Perhaps that is what you meant?

Halm answered 18/6, 2013 at 5:22 Comment(1)
Thanks for the answer but this doesn't solve my issue but just changes the foreground and background specified. What I want is transparent background only.Bitternut

© 2022 - 2024 — McMap. All rights reserved.