config.phundrak.com/docs/stumpwm/theme.org

8.2 KiB
Raw Blame History

StumpWM — Theme

StumpWM — Theme

Theme

As in the modeline file, the first thing well do is to load our colours.

(load "~/.stumpwm.d/colors.lisp")

We can now go onto more serious business.

Fonts

This gave me quite the headache when I tried to set this up: in order to use TTF fonts (note: it is not possible to use OTF fonts, see below), we need to use the ttf-fonts module which relies on the clx-truetype library. A few years back, it should have been possible to get it installed with a call to src_lisp[:exports code]{(ql:quickload :clx-truetype)}, but it is no longer available! Theres a quickfix available while we wait for clx-truetype to be once again available: clone it in quicklisps local projects. You will obviously need to have quicklisp installed (for that, follow the official instructions), then execute the following shell commands:

cd ~/quicklisp/local-projects/
git clone https://github.com/lihebi/clx-truetype.git

This will make clx-truetype available to quicklisp, and you can run again

(ql:quickload :clx-truetype)
without an issue (running it again is necessary to install its dependencies).

In order for it to work, install quicklisp and dont forget to run

(ql:add-to-init-file)
so it is loaded each time you start your Lisp interpreter. SBCL should be your CommonLisp interpreter of choice since StumpWM is generally compiled with it. The main advantage is also that SBCL supports multithreading, unlike CLisp. In case StumpWM doesnt find your font, spin up SBCL and execute the following lines:

(ql:quickload :clx-truetype)
(xft:cache-fonts)

If you want a list of font families available, you can execute the following:

(clx-truetype:get-font-families)

If you want to know the subfamilies of a certain family, you can execute this:

(clx-truetype:get-font-subfamilies "Family Name")

Now that this is out of the way, lets add two lines so we can use TTF fonts:

(ql:quickload :clx-truetype)
(load-module "ttf-fonts")

The documentation says we should be able to also use OTF fonts, but so far Ive had no luck loading one.

Loading more than one font to use some fallback fonts also doesnt seem to work, unlike specified in the documentation (I wanted to use a CJK font, but it doesnt appear to work), we need to manually change the font used which isnt very user-friendly, especially if you might have CJK characters appear in otherwise regular text.

Something that didnt click immediately for me (and I think StumpWMs documentation on this could be improved) is that set-font can be used to set either one main font for StumpWM, as one might guess reading the documentation — or you can set a list of them! And this is great, since my main font does not support some characters I regularly have in my windows title, such as CJK characters! However, be aware the second font and further arent fallback fonts. They are additional fonts you can switch to manually through the use of ^f<n> (<n> being the desireds font index in the 0-indexed font list). But if a font cannot render a character, it will simply display an empty rectangle instead of falling back to another font. Thats annoying… Here is my list of fonts I want loaded:

Family Subfamily Size
Unifont-JP Regular 10
DejaVu Sans Mono for Powerline Book 8.5
siji Medium 10
FantasqueSansMono Nerd Font Mono Regular 9.5
(format "(set-font `(%s))"
        (mapconcat (lambda (font)
                    (let ((family    (nth 0 font))
                          (subfamily (nth 1 font))
                          (size      (nth 2 font)))
                      (format ",%s" `(make-instance 'xft:font
                                                    :family ,(format "\"%s\"" family)
                                                    :subfamily ,(format "\"%s\"" subfamily)
                                                    :size ,size
                                                    :antialias t))))
                  fonts
                  "\n            "))

The code equivalent of this table can be seen below:

(set-font `(,(make-instance 'xft:font :family "Unifont-JP" :subfamily "Regular" :size 10 :antialias t)
            ,(make-instance 'xft:font :family "DejaVu Sans Mono for Powerline" :subfamily "Book" :size 8.5 :antialias t)
            ,(make-instance 'xft:font :family "siji" :subfamily "Medium" :size 10 :antialias t)
            ,(make-instance 'xft:font :family "FantasqueSansMono Nerd Font Mono" :subfamily "Regular" :size 9.5 :antialias t)))

As far as I know, Unifont is the only font Ive tested that displays monospaced Japanese characters in StumpWM. I tried DejaVu, IBM Plex, and a couple of others but only this one works correctly. DejaVu is here for the Powerline separator. If you know of another monospaced font that displays Japanese characters, or even better CJK characters, please tell me! My email address is at the bottom of this webpage.

Colors

We can now set a couple of colors for StumpWM. Not that we will see them often since I dont like borders on my windows, but in case I want to get them back, theyll be nice to have.

(set-border-color        phundrak-nord1)
(set-focus-color         phundrak-nord1)
(set-unfocus-color       phundrak-nord3)
(set-float-focus-color   phundrak-nord1)
(set-float-unfocus-color phundrak-nord3)

Lets also set the colours of the message and input windows:

(set-fg-color phundrak-nord4)
(set-bg-color phundrak-nord1)

As I said, I dont like borders, so Ill remove them. Ill still keep the windows title bar available when its floating, and this is also where I can set the format of its title: its number as well as its name, limited to thirty characters.

(setf *normal-border-width*       0
      ,*float-window-border*       0
      ,*float-window-title-height* 15
      ,*window-border-style*       :none
      ,*window-format*             "%n:%t")

I also have a StumpWM fork that introduces two new variables for customizing which-key keybindings. I submitted a pull request, so it might come one day to StumpWM.

(setf *key-seq-color* "^2")
(setf *which-key-format* (concat *key-seq-color* "*~5a^n ~a"))

Message and Input Windows

The Input windows as well as the message windows should both be at the top of my screen. And I believe a padding of five pixels for the message windows is good.

(setf *input-window-gravity*     :top
      ,*message-window-padding*   10
      ,*message-window-y-padding* 10
      ,*message-window-gravity*   :top)

Gaps Between Frames

I love gaps. When I was using i3, I used the i3-gaps package, not just plain i3. In Awesome, I still have gaps. And in StumpWM, I shall still use gaps. In order to use them, lets load a module dedicated to gaps in StumpWM:

(load-module "swm-gaps")

Now that this is done, I can now set some variables bound to this package.

(setf swm-gaps:*head-gaps-size*  0
      swm-gaps:*inner-gaps-size* 5
      swm-gaps:*outer-gaps-size* 40)

Finally, lets enable our gaps:

(when *initializing*
  (swm-gaps:toggle-gaps))