« Back to article list

Beautiful Animated Wallpaper in Emacs

Table of Contents

The preceding was achieved with a combination of:

Setup

Install StumpWM, Emacs, Compton (most installs of this will include transset or transset-df) and URxvt.

Picking your scenery

After you've done the first step, find a nice looping video you like (https://www.youtube.com/watch?v=5N2ySHlCjms is what I'm using) and run it in window 0 of StumpWM (if you can't find a means to persist a nice looping video or gif to disk, you may want to try out livewallpaper or electricsheep in your window 0 slot).

If using a movie or gif, run it in loop with mpv:

mpv -loop --no-keepaspect --geometry=1920x1024 Rain\ and\ Thunder\ with\ animation.-5N2ySHlCjms.webm

Also, ensure you have a background image set that more or less works with the theme you go with (I used a rain background).

Updating your WM on the fly!

Now, you'll need to update your StumpWM (luckily, you can evaluate new code on the fly in your ~/.stumpwmrc through a slime server + slime-connect in Emacs.

Define the following (or something close to it) and evaluate it in your slime REPL:

(define-key *root-map* (kbd "e") "working-emacs-ss")
(define-key *root-map* (kbd "s-e") "working-emacs")
(defcommand working-emacs-ss () ()
  "Run or raise emacs."
  (run-or-raise "aterm -title myemacs -e sh -c 'emacs -nw'"
                '(:title "myemacs"))
  (pull-window (nth 0 (sort-windows (current-group))))
  (pull-hidden-other)
  )

(defcommand working-emacs () ()
  "Run or raise emacs as the only window."
  (pull-window (nth 0 (sort-windows (current-group))))
  (only)
  (run-or-raise "aterm -title myemacs -e sh -c 'emacs -nw'"
                '(:title "myemacs")))

In my case, I chose to compile a version of URxvt from source, and used the aterm name, as it's the easiest way to have a custom URxvt + the OS one installed without conflicts - in your case, use whatever editor you like.

This custom StumpWM command will ensure that anytime you switch to Emacs (via your StumpWM escape key combo + define-key binding, it will pull in the window 0 behind your active Emacs window).

Now, you'll need to redefine a few built in StumpWM functions so you can avoid having window 0 pop up as you navigate your windows in the normal manner.

(defun other-hidden-window (group)
  "Return the last window that was accessed and that is hidden."
  (let ((wins (remove-if
               (lambda (w)
                 (or (eq (frame-window (window-frame w)) w)
                     (eq (nth 0 (sort-windows group)) w)))
               (group-windows group))))
    (first wins)))

Compositing it all together now

At this point, all that's left to do is run Compton:

compton --no-fading-openclose --sw-opti

(with your preferred options)

and then set the alpha transparency on your aterm/Emacs session:

transset-df -a 0.9 # then click on Emacs

Voila!

Congrats, you can now have a peaceful coding/browsing/(whatever in the world you feel like doing in Emacs) session with a super slick animated background.

Oh, and if you're interested in how I recorded the video, you can do the same with ffmpeg (no fancy screen capture software needed) by doing:

ffmpeg -f x11grab -s 1920x1024 -i :0.0+0,40 -c:v libx264 -preset ultrafast -crf 0 /tmp/emacs.mkv
ffmpeg -i /tmp/emacs.mkv /tmp/emacs.mp4 #or whatever output you want - mp4 is about 1/100th the size

What did you think?

Let me know! m @ ahungry dot com (put it together :p )

Or hit me up on on Twitter @ahungry

comments powered by Disqus