8.2 KiB
StumpWM — Theme
StumpWM — Theme
Theme
As in the modeline file, the first thing we’ll 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!
There’s a quickfix available while we wait for clx-truetype
to be once
again available: clone it in quicklisp’s 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)
In order for it to work, install quicklisp and don’t forget to run
(ql:add-to-init-file)
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 doesn’t 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, let’s 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 I’ve had no luck loading one.
Loading more than one font to use some fallback fonts also doesn’t seem to work, unlike specified in the documentation (I wanted to use a CJK font, but it doesn’t appear to work), we need to manually change the font used which isn’t very user-friendly, especially if you might have CJK characters appear in otherwise regular text.
Something that didn’t click immediately for me (and I think StumpWM’s
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 aren’t fallback fonts. They are additional
fonts you can switch to manually through the use of ^f<n>
(<n>
being
the desired’s 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. That’s 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 I’ve 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 don’t like borders on my windows, but in case I want to get them back, they’ll 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)
Let’s also set the colours of the message and input windows:
(set-fg-color phundrak-nord4)
(set-bg-color phundrak-nord1)
As I said, I don’t like borders, so I’ll remove them. I’ll still keep the window’s title bar available when it’s 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, let’s 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, let’s enable our gaps:
(when *initializing*
(swm-gaps:toggle-gaps))