conformal / spectrwm

A small dynamic tiling window manager for X11.
ISC License
1.33k stars 97 forks source link

cannot set terminal font (with spaces?) in spectrwm.conf #139

Closed mschilli87 closed 8 years ago

mschilli87 commented 8 years ago

I use spectrwm in Ubuntu 14.04 & Gentoo in combinations with the suckless terminal st (stterm in Ubuntu).

To change the font settings for stterm post-compilation, I use the command line flag -f:

stterm -f FreeMono:style=Regular:pixelsize=14:antialias=true

I configured this for spectrwm as follows:

program[terminal] = stterm -f FreeMono:style=Regular:pixelsize=14:antialias=true
bind[terminal]  = MOD+Shift+Return

This worked fine for years.

Now I made some changes to my vim settings including setting up a more fancy status bar that required me to use one of the patched powerline fonts.

First I tried to get it work manually and it turned out

stterm -f "Anonymice Powerline:style=Regular:pixelsize=14:antialias=true"

did the trick: I got a terminal window in which could open vim to see the nice new status bar.

I adjusted my spectrwm.conf accordingly:

program[terminal] = "Anonymice Powerline:style=Regular:pixelsize=14:antialias=true"
bind[terminal]  = MOD+Shift+Return

However, opening a terminal from spectrwm now results in some really ugly default font.

I can reproduce the same effect by running

stterm -f thisfontdoesnotexist:style=Regular:pixelsize=14:antialias=true

Surprisingly, if I copy/paste the command from my spectrwm.conf to the (ugly font) terminal opened by spectrwm using the very same command, it opens another terminal window that has the desired font.

So somehow, spectrwm doesn't seem to find the font while my zsh running in the stterm does.

I thought this might be due to the patched fonts install script installing the font for my user only (to ~/.local/share/fonts) which spectrwm might not check. So I created a directory powerline in /usr/share/fonts & moved the fonts there by

sudo mkdir /usr/share/fonts/powerline && \
sudo mv ~/.local/share/fonts/* /usr/share/fonts/powerline/

I ran fc-cache to be sure and fc-list | grep "Anonymice Powerline" returns the following entries:

/usr/share/fonts/powerline/Anonymice Powerline Bold Italic.ttf: Anonymous Pro for Powerline,Anonymice Powerline:style=Bold Italic
/usr/share/fonts/powerline/Anonymice Powerline.ttf: Anonymous Pro for Powerline,Anonymice Powerline:style=Regular
/usr/share/fonts/powerline/Anonymice Powerline Bold.ttf: Anonymous Pro for Powerline,Anonymice Powerline:style=Bold
/usr/share/fonts/powerline/Anonymice Powerline Italic.ttf: Anonymous Pro for Powerline,Anonymice Powerline:style=Italic

As it used to work with the FreeMono font but fails with the Anonymice Powerline font and only from spectrwm I suspect a problem with how to escape the space in the font name.

I tried to escape with single quotes:

program[terminal] = 'Anonymice Powerline:style=Regular:pixelsize=14:antialias=true'
bind[terminal]  = MOD+Shift+Return

And I tried to escape by backslash:

program[terminal] = Anonymice\ Powerline:style=Regular:pixelsize=14:antialias=true
bind[terminal]  = MOD+Shift+Return

In both cases I get the ugly default font when launching the terminal from spectrwm even though both,

stterm -f 'Anonymice Powerline:style=Regular:pixelsize=14:antialias=true'

and

stterm -f Anonymice\ Powerline:style=Regular:pixelsize=14:antialias=true

have the desired effect for the 2nd terminal when I copy/paste them into the 1st terminal (the one with the ugly fonts that was openend by spectrwm).

As of now the best 'solution' seems to be to alias

 stterm -f "Anonymice Powerline:style=Regular:pixelsize=14:antialias=true" &;disown && exit

in my .zshrc so I can quickly replace a window opened by spectrwm by one that uses the proper font.

Do you have any idea what I am doing wrong?

This was done on my Ubuntu machine were I have spectrwm 1.0.0-1 installed.

LordReg commented 8 years ago

spectrwm 1.0.0 doesn't handle quotes or escaped spaces when parsing spawn command arguments. Spawn parsing was improved in 2.4.0. Your terminal spawn command should work in the current release (3.0.2):

program[terminal] = stterm -f "Anonymice Powerline:style=Regular:pixelsize=14:antialias=true"
bind[terminal]  = MOD+Shift+Return
mschilli87 commented 8 years ago

Thanks for the fast reply.

As spectrwm 2.4.0 is not available in Ubuntu 14.04, I hacked around this issue by masking the offending space:

sudo  ln -s /usr/share/fonts/powerline/Anonymice\ Powerline.ttf /usr/share/fonts/powerline/AnonymicePowerline.ttf

This allowed me to use the following configuration:

program[terminal] = AnonymicePowerline:style=Regular:pixelsize=14:antialias=true
bind[terminal]  = MOD+Shift+Return

Now everything works as expected.