September 17, 2019

Terminals in 2019

Modern terminals

Most recent terminal emulators have removal of cruft as a goal. Having used the oldest of the modern terminal emulators, rxvt-unicode for almost 10 years, the pain points were:

  • implementing functions based on selections (send to pastebin, google) is idiosyncratic
  • the font handling niggles (antialias support, configuration)
  • configuration across Xdefaults, i3, alternatives

The last point is unavoidable but to address the first two, I decided to use st combined with mtm for multiplexing.

Pros

  • Dead simple, all code <5kloc
  • uses fontconfig
  • packaged for debian as stterm
  • Active development

Cons

  • Unicode box alignment issues
  • Some interaction with mtm for scrollback

mtm

mtm can be found at https://github.com/deadpixi/mtm. I did not package it for Debian as I kept the install local to my user for testing.

make terminfo-install is required to install the terminfo entries into ~/.terminfo.

st

exec stterm \
     -a \
     -f "Ubuntu Mono derivative Powerline:style=Regular:pixelsize=14:antialias=true" \
     -T $(hostname) \
     -e mtm -t mtm-256color -c x
#    -f "Go Mono:style=Regular:pixelsize=9:antialias=true" \
#    -a 

This is installed as ~/bin/st.sh. i3/sway uses this script to lauch terminals.

Test with,

curl https://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-demo.txt

Sway

Setting up the terminals led me to finally moving to Wayland on the venerable weyl. However, sway is not in Debian yet. At the time of writing 1.1.1-1 was in experimental but 1.2 has been out for a month. I would have to setup a pipeline.

Building

First, you need wlroots:

cd ~/src/debian
git clone https://salsa.debian.org/swaywm-team/wlroots
curl -L https://github.com/swaywm/wlroots/archive/0.7.0.tar.gz -o wlroots_0.7.0.orig.tar.gz
cd wlroots
debuild -uc -us
cd ..
sudo dpkg -i libwlroots3_0.7.0-1_amd64.deb libwlroots-dev_0.7.0-1_amd64.deb

Then you can get sway

cd ~/src/debian
git clone https://salsa.debian.org/swaywm-team/sway
curl -L https://github.com/swaywm/sway/archive/1.2.tar.gz -o sway_1.2.orig.tar.gz
cd sway
debuild -uc -us

Marvel at the compile blazing along (ccache ftw) but seriosuly the text just flies. CPU usage is fine. Now, we hit the first hiccup:

../sway/ipc-json.c:92:9: error: macro "__DATE__" might prevent reproducible builds [-Werror=date-time]
   92 |  sscanf(SWAY_VERSION, "%u.%u.%u", &major, &minor, &patch);
      |         ^~~~~~~~~~~~

Some hacking later, we produce the hack that lets us proceed.

cat debian/patches/0003-Make-reproducible.patch
--- a/meson.build
+++ b/meson.build
@@ -134,7 +134,7 @@ if git.found()
 	git_commit_hash = run_command([git.path(), 'describe', '--always', '--tags'])
 	git_branch = run_command([git.path(), 'rev-parse', '--abbrev-ref', 'HEAD'])
 	if git_commit_hash.returncode() == 0 and git_branch.returncode() == 0
-		version = '"@0@ (" __DATE__ ", branch \'@1@\')"'.format(git_commit_hash.stdout().strip(), git_branch.stdout().strip())
+		version = '"@0@ (branch \'@1@\')"'.format(git_commit_hash.stdout().strip(), git_branch.stdout().strip())
 	endif
 endif
 add_project_arguments('-DSWAY_VERSION=@0@'.format(version), language: 'c')

This is committed to the reproducible branch. Packages are built and installed.

Configuration

cd ~/dotfiles
cp -r i3 sway
cd sway/.config
mv i3 sway

Some light config file editing based on the example config file in /etc/sway/config. Sway does not use /etc/default/keyboard so it is necessary to add a section to config:

input "1:1:AT_Translated_Set_2_keyboard" {
    xkb_model pc105
    xkb_layout us
    xkb_variant ,nodeadkeys
    xkb_options ctrl:nocaps,compose:menu
}

It is also necessary to install xwayland else nothing is displayed. Also remember to chmod u+s /usr/bin/sway.

QT5 supports Wayland.

export QT_QPA_PLATFORM=wayland

Alternatively, add -platform wayland to the command line invocation.

Problems

There does not seem to be any easy way of configuring xmodmap. This is needed to move the PageUp/Down keys.

stterm runs within xwayland and nice fonts look like crap. kitty, from the repo isn’t much better. This appears to be a sway bug.

Only applets supporting StatusNotifierItem are shown in swaybar. This lets out wicd and even nm.

Emacs gets some ugly, unstyled scrollbars.

Going back to i3.

Powered by Hugo & Kiss.