简体   繁体   English

Gnome Shell上的Emacs中的透明背景

[英]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 这个问题是上一个问题的连续性: 如何使emacs控制台模式继承外壳颜色

On Ubuntu 12.10 and Gnome Shell 3.6.2 I am running Emacs. 在Ubuntu 12.10和Gnome Shell 3.6.2上,我正在运行Emacs。 Following http://www.emacswiki.org/emacs/TransparentEmacs I am able to set alpha transparency on my Emacs X window using: http://www.emacswiki.org/emacs/TransparentEmacs之后,我可以使用以下命令在Emacs X窗口上设置Alpha透明度:

(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. 不幸的是,这为我的emacs窗口中的所有“项目”(包括包含文本的前景)设置了透明度。 As a result it becomes difficult to read the Emacs content. 结果,变得难以阅读Emacs内容。 What I am looking for is a way to only set alpha value on the background. 我正在寻找的是仅在背景上设置alpha值的方法。 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). 这样,我将能够清楚地看到Emacs窗口的内容并从emacs后面的窗口中读取信息(我已经通过非常漂亮的gnome终端成功地做到了这一点)。

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. 如果设置了外壳的透明性,然后运行emacs -nw -q ,则Emacs的默认行为似乎是遵循外壳设置。 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 (eg adwaita, tango, wombat, etc), those have set the default background color which will override the alpha frame parameter. 如果您使用内置主题之一(例如adwaita,探戈,袋熊等),则这些主题已设置了默认的背景颜色,它将覆盖alpha框架参数。 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. 我的主题位于/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. Jeff之前给出的代码应该可以工作。 See section 28.4: Frame Parameters of the ELisp Manual. 请参见《 ELisp手册》的28.4:框架参数 Also, check out 51.1.7: Custom Themes of the Emacs Manual. 另外,请查看Emacs手册的51.1.7:自定义主题 Jeff's code will set the transparency of the frame just for Emacs. Jeff的代码将为Emacs设置框架的透明度。 This is good if you want it to be different from the transparency of your shell application. 如果您希望它与Shell应用程序的透明性不同,那么这很好。 If you just want it to follow the behavior of your shell, like I said, that is the default. 如果您只希望它遵循外壳的行为(如我所说),则为默认设置。

Mine worked fine - the foreground is visible in the color I'd set in .Xresources. 我的工作得很好-用我在.Xresources中设置的颜色可以看到前景。 Perhaps you can try that, something like: 也许您可以尝试一下,例如:

emacs*foreground: gold
emacs*background: black

can go in ~/.Xresources , then use the command 可以进入~/.Xresources ,然后使用命令

$ xrdb ~/.Xresources

before calling emacs with those two lines you gave (in ~/.emacs): 在用您给的这两行(在〜/ .emacs中)调用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. 我更新了上面的内容,在〜/ .emacs中包括了这两行,因为那是设置透明性的原因。 Additionally, I do notice that when my emacs window loses focus, then the foreground also becomes transparent. 另外,我确实注意到,当我的emacs窗口失去焦点时,前景也会变得透明。 Perhaps that is what you meant? 也许那是你的意思?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM