x220

Table of Contents

1 Abstract

In this document I will try to outline my emacs computing environment.

Emacs is a glorified ListProcessor (LISP) Interpreter and as such it is highly extensible, it is NOT "just a text editor".

2 Hardware

2.1 Machine

thinkpad-x220

I've had this notebook since 2015, it has served me quite well through the years and has undergone various upgrades/fixes.

Its a great little (12.5") notebook with an incredible CPU & godlike keyboard that still holds its own today, equipped with a modern 2.5in ssd and some extra RAM and it still runs excellently by 2020 standards.

2.2 Specs

info.png

<2020-08-27 Thu>

3 Software

3.1 Operating System

Debian Stable

Debian is the desired distro for a machine like this where we don't need the latest packages and we just need assured uptime and a lack of headaches, Debian grants that for me personally.

Non-Free repos are required for the x220's wifi card (firmware-iwlwifi) & ttf-mscorefonts-installer is nice for better looking web fonts.

3.1.1 Boot flags

WARNING: This is highly insecure.

GRUB CMDLINE LINUX DEFAULT="text mitigations=off"

On older CPUs such as the x220's this does yield a slight performance bump as the spectre/meltdown cpu mitigations are not applied with these flags.

3.2 DE/WM

This x220 is an emacs computing environment primarily and as such we care very little about the DE/WM that runs on it, therefore the default Debian Gnome (X11 not Wayland) session suffices. (EXWM one day in the far future)

3.2.1 Tools

Most of these tools are centered around window manipulation.

We use rofi for our window launching/switching and a few scripts for centering/growing/shrinking windows on the fly.

  1. Launcher

    Bind this to Alt+Space for fast window searching/application launching.

    rofi -combi-modi window,drun -show combi -modi combi
    
  2. Window Manipulation
    1. Center
      #!/bin/bash
      
      IFS='x' read screenWidth screenHeight < <(xdpyinfo | grep dimensions | grep -o '[0-9x]*' | head -n1)
      
      width=$(xdotool getactivewindow getwindowgeometry --shell | head -4 | tail -1 | sed 's/[^0-9]*//')
      height=$(xdotool getactivewindow getwindowgeometry --shell | head -5 | tail -1 | sed 's/[^0-9]*//')
      
      newPosX=$((screenWidth/2-width/2))
      newPosY=$((screenHeight/2-height/2))
      
      xdotool getactivewindow windowmove "$newPosX" "$newPosY"
      
    2. Grow
      #!/bin/bash
      curr=$(xdotool getwindowgeometry `xdotool getactivewindow` | tail -n1 | sed 's/  Geometry: //g')
      width=`echo "$curr" | cut -dx -f1`
      height=`echo "$curr" | cut -dx -f2`
      add=100
      w=$(expr $width + $add)
      h=$(expr $height + $add)
      
      xdotool windowsize `xdotool getactivewindow` $w $h
      
    3. Shrink
      #!/bin/bash
      curr=$(xdotool getwindowgeometry `xdotool getactivewindow` | tail -n1 | sed 's/  Geometry: //g')
      width=`echo "$curr" | cut -dx -f1`
      height=`echo "$curr" | cut -dx -f2`
      del=100
      w=$(expr $width - $del)
      h=$(expr $height - $del)
      
      xdotool windowsize `xdotool getactivewindow` $w $h
      

3.2.2 Tweaks

Disable animations if using Gnome via tweak-tool.

Disable compositing if using XFCE via Xfwm4 Window Manager Tweaks > Compositor.

3.3 Web Browsing

Eww within emacs for visiting simple webpages and for more complicated webpages Firefox (+ uBlock-Origin HTTPS-Everywhere Privacy-Badger) or Qutebrowser if hjkl movement is desired.

3.4 Packages

3.4.1 Miscellaneous

Some basic packages needed on any install.

sudo apt install bash-completion build-essential imagemagick vim neofetch htop lm-sensors screenfetch scrot ffmpeg wget curl xdotool wmctrl slop wkhtmltopdf tmux ranger

3.4.2 Utilities

Some basic utilities.

mpv nomacs zathura mupdf mupdf-tools qutebrowser telegram-desktop hexchat appmenu-gtk2-module chrome-gnome-shell zathura-ps zathura-djvu zathura-cb ttf-mscorefonts-installer ttf-bitstream-vera obs-studio kolourpaint rofi vrms

3.4.3 TLP

This x220 has a relatively new 6cell battery but it only lasts for around 4 hours whilst using emacs, with TLP this extends to about 5-6 hours depending on brightness/wifi state and etc.

tlp tlp-rdw acpi-call-dkms tp-smapi-dkms powertop menu smartmontools ethtool

3.5 Emacs

emacs.png

3.5.1 Dependencies

sudo apt-get build-dep emacs
sudo apt install imagemagick ripgrep libxpm-dev libjpeg-dev libgnutls28-dev libgif-dev libtiff-dev libacl1-dev libgtk-3-dev libwebkit2gtk-4.0-dev librsvg2-dev libmagickcore-dev libmagick++-dev libgpm-dev libselinux1-dev libm17n-dev libotf-dev libsystemd-dev libtool-bin cmake cmake-extras texlive-extra-utils texlive-latex-extra texlive-latex-recommended pandoc html2ps

3.5.2 Compiling

tar -zxvf emacs-VERSION.tar.gz
cd emacs-*
  • configure:
./configure --disable-silent-rules \
--with-modules --with-file-notification=inotify --with-mailutils \
--with-x=yes --with-x-toolkit=gtk3 --with-xwidgets --with-lcms2 \
--with-imagemagick --with-xml2 --with-json --with-harfbuzz CFLAGS='-O3'
  • compile & install:
time make
sudo make install

Emacs takes 2 minutes to compile on my x220 with its sandybridge i5 and modest 2.5in SSD. On my newer laptop equipped with its 10th gen i5 and nvme ssd emacs compiles in 1 minute & 30 seconds. Not too bad for a 9 year old machine.

3.5.3 Setup

  1. Clone emacs configuration.

    My emacs configuration is based upon https://github.com/snackon/witchmacs with some minor tweaks/updates for emacs-27 (tab-bar-mode) and some personal keybinds.

    git clone https://github.com/diamondbond/emacs ~/.emacs.d
    
  2. Add emacs to your session startup
    1. Gnome

      In gnome simply copy your emacs.desktop to ~.local/share/applications/ and set its exec to Exec=emacs –daemon

      Add emacsdaemon.desktop to tweak-tool's startup applications and uncomment (server-start) from init.el.

    2. XFCE

      Create an autostart script somewhere in your home directory with the following contents:

      #!/bin/sh
      emacs --daemon
      

      Add this script to XFCE's session & startup items.

  3. Starting emacs
    1. emacsclient

      Make sure to create another emacs.desktop within ~.local/share/applications/ with its Exec set to Exec=emacsclient -c -a 'emacs'.

      Launch emacs with this .desktop file as it will connect to the emacs server, this is the recommended way of launching emacs as it allows you to create frames on the fly with a keybind (use the same emacsclient command above) and not have to worry about different emacs sessions.

      If you want to connect to the local emacs server via a terminal run the following command or alias it:

      emacsclient -t
      
  4. Misc
    1. Theme

      M-x package-install modus-operandi (as of emacs 28 this should be redundant as modus-themes are being upstreamed.)

    2. PDF

      For viewing pdfs within emacs we can leverage the pdf-tools package. For external viewing zathura is recommended.

      M-x package-install pdf-tools This will prompt the user to install the pdf-tools backend/dependencies and etc, just hit y.

    3. Term

      EShell is nice but sometimes we need an ncurses compatible terminal which is where vterm comes in.

      VTerm modules need to be compiled so launch vterm with M-x vterm and hit y to compile modules.

4 Conclusion

Overall this hardware combined with Emacs is very comfortable and accomplishes everything one may desire from this sort of setup given reasonable constraints (eg; gaming is limited to M-x tetris).

I recommend anyone who is interested in easy note taking to take a look at emacs org-mode and to start off with an emacs distro such as doom-emacs, it is then suggested to move onto your own configuration or starting off from a slimmer base such as emacs-starterkit or someone's personal emacs configuration of which you can find many available online at github.

Enjoy emacs!

Author: Diamond

Created: 2020-08-28 Fri 11:05

Validate