在Emacs的透明背景在Gnome壳

时间:2022-02-26 21:30:22

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

这个问题与前一个问题的连续性有关:如何使emacs控制台模式继承shell颜色

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:

在Ubuntu 12.10和Gnome Shell 3.6.2上,我正在运行Emacs。关于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. 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).

不幸的是,这为我的emacs窗口中的所有“项目”设置了透明度,包括包含文本的前景。因此,很难阅读Emacs内容。我正在寻找的只是在背景上设置alpha值的方法。通过这种方式,我将能够清楚地看到我的Emacs窗口的内容,并从emacs后面的窗口读取信息(我用非常好的gnome终端成功地做到了这一点)。

2 个解决方案

#1


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.

如果您已设置shell的透明度然后运行emacs -nw -q,则Emacs的默认行为似乎是遵循您的shell设置。如果你的不这样做,那么你可能在某处设置了一些冲突的设置。也许你正在使用一个主题,将默认背景设置为一种颜色?如果是这样,您需要更改该设置。

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 (If you don't know how to do this, then you need to spend more time reading the Emacs manual). That directory should have a themes subdirectory. To modify the theme file, you may need admin privileges.

如果您使用其中一个内置主题(例如adwaita,tango,wo​​mbat等),那些设置了默认背景颜色,它将覆盖alpha框架参数。一种解决方案是找到该主题文件并注释掉设置此默认值的行。我的主题位于/usr/share/emacs/25.3/etc/themes。如果不存在,则切换到暂存缓冲区并评估数据目录变量的值(如果您不知道如何执行此操作,则需要花费更多时间阅读Emacs手册)。该目录应该有一个themes子目录。要修改主题文件,您可能需要管理员权限。

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.

杰夫之前给出的代码应该可行。参见第28.4节:ELisp手册的框架参数。另外,请查看51.1.7:Emacs手册的自定义主题。 Jeff的代码将为Emacs设置框架的透明度。如果您希望它与shell应用程序的透明度不同,那么这很好。如果你只是想让它遵循shell的行为,就像我说的那样,这是默认的。

#2


0  

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

我的工作正常 - 前景在我设置的颜色中可见.Xresources。也许你可以试试,比如:

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. Additionally, I do notice that when my emacs window loses focus, then the foreground also becomes transparent. Perhaps that is what you meant?

我更新了上面的内容,将这两行包含在〜/ .emacs中,因为这些是设置透明度的工作原理。另外,我注意到当我的emacs窗口失去焦点时,前景也变得透明。也许这就是你的意思?

#1


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.

如果您已设置shell的透明度然后运行emacs -nw -q,则Emacs的默认行为似乎是遵循您的shell设置。如果你的不这样做,那么你可能在某处设置了一些冲突的设置。也许你正在使用一个主题,将默认背景设置为一种颜色?如果是这样,您需要更改该设置。

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 (If you don't know how to do this, then you need to spend more time reading the Emacs manual). That directory should have a themes subdirectory. To modify the theme file, you may need admin privileges.

如果您使用其中一个内置主题(例如adwaita,tango,wo​​mbat等),那些设置了默认背景颜色,它将覆盖alpha框架参数。一种解决方案是找到该主题文件并注释掉设置此默认值的行。我的主题位于/usr/share/emacs/25.3/etc/themes。如果不存在,则切换到暂存缓冲区并评估数据目录变量的值(如果您不知道如何执行此操作,则需要花费更多时间阅读Emacs手册)。该目录应该有一个themes子目录。要修改主题文件,您可能需要管理员权限。

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.

杰夫之前给出的代码应该可行。参见第28.4节:ELisp手册的框架参数。另外,请查看51.1.7:Emacs手册的自定义主题。 Jeff的代码将为Emacs设置框架的透明度。如果您希望它与shell应用程序的透明度不同,那么这很好。如果你只是想让它遵循shell的行为,就像我说的那样,这是默认的。

#2


0  

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

我的工作正常 - 前景在我设置的颜色中可见.Xresources。也许你可以试试,比如:

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. Additionally, I do notice that when my emacs window loses focus, then the foreground also becomes transparent. Perhaps that is what you meant?

我更新了上面的内容,将这两行包含在〜/ .emacs中,因为这些是设置透明度的工作原理。另外,我注意到当我的emacs窗口失去焦点时,前景也变得透明。也许这就是你的意思?