On the following platforms,
the user can controls the frame opacity by adding the below lines in InitFile.
;;(set-frame-parameter (selected-frame) 'alpha '(<active> . <inactive>)) ;;(set-frame-parameter (selected-frame) 'alpha <both>) (set-frame-parameter (selected-frame) 'alpha '(85 . 50)) (add-to-list 'default-frame-alist '(alpha . (85 . 50)))
You can use the following snippet after you’ve set the alpha as above to assign a toggle to “C-c t”:
(defun toggle-transparency () (interactive) (let ((alpha (frame-parameter nil 'alpha))) (set-frame-parameter nil 'alpha (if (eql (cond ((numberp alpha) alpha) ((numberp (cdr alpha)) (cdr alpha)) ;; Also handle undocumented (<active> <inactive>) form. ((numberp (cadr alpha)) (cadr alpha))) 100) '(85 . 50) '(100 . 100))))) (global-set-key (kbd "C-c t") 'toggle-transparency)
A general transparency function:
;; Set transparency of emacs (defun transparency (value) "Sets the transparency of the frame window. 0=transparent/100=opaque" (interactive "nTransparency Value 0 - 100 opaque:") (set-frame-parameter (selected-frame) 'alpha value))
Note that unlike other transparency hacks (like the background image hack below), it’s not merely showing your desktop background image, but is true translucency—you can see other windows behind your Emacs window. It’s not terribly useful to show text underneath because it’s hard to read the text in the foreground window. I (AmitPatel) use it to watch TV or movies behind my Emacs.
(set-frame-parameter nil 'alpha nil) should let the window manger handle it again.I would love to hear of a way to do this so that only the background is translucent. Unfortunately, I don’t believe there’s any way that doesn’t involve patching the source or using an OS-specific, obsolete setting. – Quantheory
Just make sure your terminal emulator has enough colors available to look good. Then run ‘emacs -nw’ in a transparent terminal.
Here’s how you would start Emacs in a 256 color xterm:
xterm -tn xterm-256color -e emacs -nw
(Please change the above to use transparent aterm or eterm…)
For me setting the background-colors alpha value just works with Emacs 23.1 on Mac OS X
(set-background-color "ARGBBB000000")This was removed some time ago; it seems that it was only due to disorganization and chance that it was ever included in 23.1 in the first place. See the development discussion. – Quantheory
You can set up a background image in Emacs using the following:
M-x customize-face → default → Background → Value Menu → 1 = Image → File (path)
Then you could Save for Future Sessions to save this configuration in your InitFile.
If you’d rather hack it by hand, something like the following will work:
(custom-set-faces
'(default ((t (:stipple nil :background ((image :type jpeg :file "/Path/to/your/image.png") :origin display) :foreground "white" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 101 :width normal :family "misc-fixed"))))) This doesn’t work for me on GNU Emacs 23.2.1 (i386-mingw-nt5.1.2600). I get (wrong-type-argument stringp ((image :type jpeg :file "...") :origin display)). – AlexSchroeder
On Mac GNU Emacs 23.2.1 I can use: (set-face-attribute ‘default nil :stipple “/Path/to/your/image.jpg”) However, once I set it, I can’t set it again without first setting the stipple to nil. I also get weird drawing artifacts. I suspect this feature isn’t fully baked but I don’t know for sure. --AmitPatel
My understanding is that stippling is not actually supposed to do this. Some, but not all, ports of Emacs use “tiling” instead of stippling, which is the only reason this ever worked for anyone. I wouldn’t count on this continuing to work. As for an actual background image, I don’t know when that’s ever been in the modern incarnation of GNU emacs, although it has probably been in some variants at times. Hard to know unless someone actually mentions what version they were using. – Quantheory
If you use MilesBader transparent Emacs branch (currently only available via arch) you can make the buffer have a variety of different image backgrounds. Example here.
It’s possible to use the wallpaper pixmap directly, but I’d recommend processing the wallpaper image a bit in the Gimp first – in the above example the iamge has been lightened and blurred. This means it won’t distract you from your work.
To get the branch of emacs that supports this, get a copy of tla installed (see gnuarch.org, or use the “tla” package Debian etc) and run:
$ tla register-archive http://arch.sv.gnu.org/archives/emacs
$ tla get emacs@sv.gnu.org/emacs--tiling--0
Then build it in the normal way (hint: enabling gtk2 makes it look nicer too).
I (IvanAndrus) get the following today (June 21, 2008):
$ tla register-archive http://arch.sv.gnu.org/archives/emacs
unable to access URL: /archives/emacs/.listing
webdav error: 301 Moved Permanently
I’d just like to add my ditto to the above error (Feb 20, 2009 ZacharyHamm)
Does anyone know if this is still in development, or perhaps has been merged into EmacsFromCVS?
The correct URL seems to be http://arch.savannah.gnu.org/archives/emacs