12

I've been looking for themes which are transparent, but I didn't find any. Is there someone who uses a transparent theme?

0

3 Answers 3

17

I found a solution, and no longer I need transparent theme.

The solution is :

;; set transparency
(set-frame-parameter (selected-frame) 'alpha '(85 85))
(add-to-list 'default-frame-alist '(alpha 85 85))
3
  • 1
    how do you put this into emacs? for someone new to emacs is this in a file somewhere or at a command?
    – Vass
    Commented Sep 11, 2016 at 21:34
  • 8
    Unfortunately, this doesn't just change the background, but also makes text transparent as well.
    – Jake
    Commented Dec 13, 2016 at 17:23
  • Can you comment on what this code does, exactly? Why are there two parameters? Commented Mar 4, 2022 at 9:12
8

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. It can also have a nil value, which tells Emacs not to set the frame opacity (leaving it to the window manager).

To prevent the frame from disappearing completely from view, the variable frame-alpha-lower-limit defines a lower opacity limit. If the value of the frame parameter is less than the value of this variable, Emacs uses the latter. By default, frame-alpha-lower-limit is 20.

The alpha frame parameter can also be a cons cell (‘active’ . ‘inactive’), where ‘active’ is the opacity of the frame when it is selected, and ‘inactive’ is the opacity when it is not selected.

but more general solution is to use your compositor manager.

For example with Compton you can change Emacs’ (or any window) opacity with following change in Compton’s config (i.e. ~/.config/compton.conf file):

opacity-rule = [ "90:class_g = 'Emacs'", # 10% of transparency
                 "90:!focused && class_g = 'Conkeror'"] # as a bonus

Solution will vary between operating systems and windowing systems ergo I’m providing this answer only FWIW.

0

The current answers here are a bit outdated so I'll post more current information. The other methods will result in a blurred background, but the text will be blurred as well, impacting readability. I presume this is generally not desirable.
Fortunately, as of Emacs 29, there is a method to blur only the background and leave the text opaque: using the frame parameter alpha-background instead of the more general frame parameter (mentioned in this question's other answers), alpha. To do this, simply run (set-frame-parameter nil 'alpha-background X), where 'X' is whatever transparency percentage you desire.

Like all Emacs configuration, you must add it to your .emacs file for it to persist between sessions. The previously linked wiki page provides ELisp code for this (it's identical to the code Vivian posted 9 years ago aside from the frame parameter*):

(set-frame-parameter nil 'alpha-background 70)
(add-to-list 'default-frame-alist '(alpha-background . 70))

and it worked nicely for me.

Some prerequisites for usage of the above:

  • If you're on Wayland, you'll have to have the pure GTK (PGTK) package installed, claims the wiki. However, I found it worked out of the box for me using the normal Emacs package in the official Arch repository.
  • Again, you must have Emacs version 29 or later

*the writer of the wiki article also has favoured the use of '`nil`' over '`(selected-window)`', but a quick `C-h f set-frame-parameter` will reveal that `set-frame-parameter` defaults to the selected frame if it supplied `nil` as an argument.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.