lobo_tuerto's notes
for greatly improving DX
Blog
Notes
About

Set up Manjaro i3

Imagine no longer having to minimize, maximize, resize or rearrange any windows, ever, again. Thx i3wm. ❤️

📅Date31 August 2019Updated28 August 2021
🏷️
i3linuxmanjaro

If you still don’t know what i3 is, please have a look at this.

Table of contents

Prerequisites

Create a live USB for Manjaro Linux —instructions here.
Then install it.

Offline set up

Things to do before connecting to the network.

Create common directories:

mkdir -p ~/tmp ~/encrypted

Make some ~/.bashrc additions:

alias ll="ls -lhF"
alias la="ls -lahF"

export HISTCONTROL=ignoredups:ignorespace
export PATH=~/bin:$PATH

export PS1="\[\e[37;1m\]\t . \[\033[01;32m\][\u@\h\[\033[01;37m\] \W\[\033[01;32m\]]\$\[\033[00m\] "

Make some ~/.profile additions:

export CALIBRE_USE_SYSTEM_THEME=1

Mount back and restore backup from FDE drive.

Set up UFW

Let’s enable a firewall:

sudo ufw enable
sudo systemctl enable --now ufw.service

Set up Google Public DNS

If you don’t like using your ISP’s DNS servers, right click the nm-applet icon at the bottom right of the screen.

Select Edit Connections…, then Wired connection 1, then click on the little gear icon.

Click on the IPv4 Settings tab.
Then on Method pick: Automatic (DHCP addresses only).

On DNS servers enter:

8.8.8.8, 8.8.4.4

Then click on the IPv6 Settings tab.
On Method pick: Automatic, addresses only.

On DNS servers enter:

2001:4860:4860::8888, 2001:4860:4860::8844

Click on Save and close the Network Manager screen.

SSH key (optional)

To create a new SSH key in ~/.ssh:

ssh-keygen -t rsa -b 4096 -C "user@some-host"

SSH service (optional)

To be able to SSH into your machine you need to enable the service for it:

sudo systemctl enable --now sshd.service

Then allow incoming SSH connections through the firewall:

sudo ufw allow SSH

Now you can ssh-copy-id a key from somewhere else.

To harden the security uncomment and modify the following lines in /etc/ssh/sshd_config:

PermitRootLogin no
PasswordAuthentication no

Whenever the /etc/ssh/sshd_config file is modified, we need to restart the SSH service with:

sudo systemctl restart sshd.service

GRUB adjustments

Let’s tweak some stuff in our grub file.
Open it with:

sudo nano /etc/default/grub

A noisy startup

To see the terminal output when booting up, remove quiet from the GRUB_CMDLINE_LINUX_DEFAULT line.

Set up dm-crypt + TRIM support

When using FDE (Full Disk Encryption) with an SSD that has TRIM support, add allow-discards to GRUB_CMDLINE_LINUX_DEFAULT like this:

GRUB_CMDLINE_LINUX_DEFAULT="cryptdevice=UUID=SOME-ID:luks-SOME-ID:allow-discards root=/dev/mapper/luks-SOME-ID resume=/dev/mapper/luks-SOME-ID"

The point of insertion is just before root=....

Whenever we change the /etc/default/grub file we should run:

sudo update-grub

Restart your system now

You should be able to use the sudo fstrim / -v command, and see an output like:

/: 439.1 GiB (471479136256 bytes) trimmed

Let’s activate a service that’ll run it weekly for us:

sudo systemctl enable --now fstrim.timer

See the service status with:

sudo systemctl status fstrim.service

If we want, we can run the service immediately with:

sudo systemctl start fstrim

Finally, let’s get rid of unnecessary software:

sudo pacman -Rns palemoon-bin deluge

i3 config changes

Next, let’s tweak the ~/.i3/config file a little bit.

I usually like to put $mod+9 to good use by having an extra workspace instead of just using it for locking the screen —you can still do that with $mod+0 l.

I also comment out a couple of things that aren’t worth it.
There are some additions in there, like setting up a two monitor desktop environment.

# Start Applications
#bindsym $mod+F2 exec palemoon
# ...
#bindsym $mod+Shift+h exec xdg-open /usr/share/doc/manjaro/i3_help.pdf
# ...


# Workspace names
# ...
set $ws9 9

# switch to workspace
# ...
bindsym $mod+9 workspace $ws9

# Move focused container to workspace
# ...
bindsym $mod+Ctrl+9 move container to workspace $ws9

# Move to workspace with focused container
# ...
bindsym $mod+Shift+9 move container to workspace $ws9; workspace $ws9


# Lock screen
#bindsym $mod+9 exec --no-startup-id blurlock

# Autostart applications
# ...
#exec --no-startup-id nitrogen --restore; sleep 1; picom -b
#exec --no-startup-id manjaro-hello
# ...
#exec --no-startup-id pamac-tray
#exec --no-startup-id clipit
# ...
exec --no-startup-id xautolock -time 120 -locker blurlock
# ...


# CUSTOM STUFF

# Set up workspace default output
workspace 1 output DP-0
workspace 7 output DP-2

# Two monitor setup
exec --no-startup-id xrandr --output DP-0 --primary --mode 3440x1440 --pos 0x560 --rotate normal --output DP-2 --mode 2560x1440 --pos 3440x0 --rotate left --output DVI-D-0 --off --output HDMI-0 --off --output HDMI-1 --off

# One monitor setup
#exec --no-startup-id xrandr --output HDMI-0 --primary --mode 2560x1440 --pos 0x0 --rotate normal --output HDMI-1 --off --output DVI-D-0 --off --output DP-1 --off --output DP-2 --off

# Wallpapers
exec_always --no-startup-id feh --recursive --randomize --bg-fill ~/.wallpapers

# Bind volume related keys
bindsym $mod+Shift+Prior exec --no-startup-id amixer -D pulse sset Master 5%+
bindsym $mod+Shift+Next exec --no-startup-id amixer -D pulse sset Master 5%-
bindsym $mod+Shift+Delete exec --no-startup-id amixer -D pulse sset Master toggle

# Desktop stuff
#exec --no-startup-id /usr/lib/geoclue-2.0/demos/agent
#exec --no-startup-id redshift-gtk
exec --no-startup-id redshift -x && redshift -O 4500
exec --no-startup-id blueman-applet


# NO LONGER USED
#bindsym XF86AudioMute exec --no-startup-id amixer -D pulse sset Master toggle

# Bind clementine player related keys
#bindsym $mod+Prior exec --no-startup-id clementine --prev
#bindsym $mod+Next exec --no-startup-id clementine --next
#bindsym $mod+Home exec --no-startup-id clementine --play
#bindsym $mod+End exec --no-startup-id clementine --stop
#bindsym $mod+Delete exec --no-startup-id clementine --play-pause

Change login screen background

Look at the files available in /usr/share/backgrounds/ pick one —or copy one of your own— then change the name for that in /etc/lightdm/slick-greeter.conf.

Online set up

Things to do after connecting to the Internet.

Update and synchronize the system clock:

sudo timedatectl set-ntp true
timedatectl status

Mirror list and system update

Update the repositories mirror list:

sudo pacman-mirrors -c United_States,Canada

To update the mirror list with the fastest on a global scale:

sudo pacman-mirrors --geoip

You can tweak the ranked mirror list by:

sudo nano /etc/pacman.d/mirrorlist

Adjust to your heart’s content, then update the packages lists and download any pending updates.

sudo pacman -Syy
sudo pacman -Su

Install common desktop software

First, let’s get a decent browser:

sudo pacman -S firefox

# Set it as the default browser
#xdg-settings set default-web-browser firefox.desktop

To change the default browser, in your ~/.profile:

#export BROWSER=/usr/bin/palemoon
export BROWSER=/usr/bin/firefox

My default list of software I usually require at one point or another:

sudo pacman -S gnote nethogs transmission-gtk nmap \
darktable gimp inkscape krita libreoffice-fresh \
blender calibre feh obs-studio openshot xfce4-settings \
aegisub clementine redshift simple-scan thunar noto-fonts-emoji \
colordiff python-gobject python-xdg unzip youtube-dl \
pa-applet pavucontrol pulseaudio pulseaudio-bluetooth \
qgis python-gdal python-owslib python-psycopg2 python-pygments \
ansible bluez bluez-utils inotify-tools

Let’s upgrade ALSA to PulseAudio:

install_pulse

Besides that, here are some comments:

  • If you miss the cozy space of a file manager in i3, you can have a good one with Thunar.
  • Redshift is good! Don’t know what it is? Have a look here.
  • You can set the default terminal with: xfce4-settings-manager.
    Default Applications -> Utilities -> Terminal Emulator -> RXVT Unicode

Configure Calibre styling

Let’s tweak Calibre a little bit now.

Open any book, then right click anywhere to make the main menu appear.

Go into Preferences -> Styles and paste this in the box:

body {
  line-height: 1.5;
}

Go into Preferences -> Colors and pick: Sepia dark or System.
Also set Override all book colors to In dark mode.

For adding visual cues about book progress:

Go into Preferences -> Headers and footers

For the Header:

  • Left: Top level section
  • Middle: Current section

For the Footer:

  • Left: Progress
  • Middle: Pages in chapter
  • Right: Position in book

To increase the font size a bit:
Go into Font size and click on the desired font size (20px).

To specify the number of pages per screen:
Go into Preferences -> Page layout
Change the values in Portrait and/or Landscape

Network printing with CUPS

To enable CUPS:

sudo pacman -S cups
sudo systemctl enable --now cups.service

Access http://localhost:631 and add your printer.

For me using the driverless option works just fine —then driverless, cups-filters

Software developement stuff

Now let’s install some useful tools that every software developer worth their salt should have. 😛

Set up z

With Git installed by default, let’s bring z to easily navigate directories on the CLI:

git clone https://github.com/rupa/z ~/z
echo ". ~/z/z.sh" >> ~/.bashrc
exec $SHELL

Its usage is super simple, after cding into various directories:

cd ~/development/web/project1
cd ~/development/mobile/client33

You can now cd into those directories from anywhere on the CLI with:

z project1
z client33

Stuff to install and set up

GRASS for QGIS

To have v.generalize available on QGIS:

cd ~/tmp
git clone https://aur.archlinux.org/grass.git
cd grass/
makepkg -si

Godot engine

Fancy some gamedev?

cd ~/tmp
git clone https://aur.archlinux.org/godot.git
cd godot/
makepkg -si

Git diff colors

Default terminal colors for Git diffs in Manjaro i3 suck:

Default diff colors

To change the colors and update Urxvt’s default behavior add these lines at the end of your ~/.Xresources file:

! CUSTOM STUFF

! do not scroll with output
URxvt*scrollTtyOutput: false

! scroll in relation to buffer (with mouse scroll or Shift+Page Up)
URxvt*scrollWithBuffer: true

! scroll back to the bottom on keypress
URxvt*scrollTtyKeypress: true

! scrollback buffer in secondary screen
URxvt.secondaryScreen: true
URxvt.secondaryScroll: false

! magenta cursor color
URxvt.cursorColor: magenta

! load solarized dark theme
#include "Xresources.dark"

Now, download Xresources.dark from this GitHub repo and put it inside your $HOME directory.

To make changes effective:

xrdb ~/.Xresources

Finally, close your current terminal and open a new one.
Now your Git diffs will look like this:

New diff colors

VirtualBox

You’ll need to enable CPU Virtualization in your BIOS.

sudo pacman -S virtualbox virtualbox-guest-iso

You’ll be presented with some options:

:: There are 11 providers available for VIRTUALBOX-HOST-MODULES:
:: Repository extra
   1) linux316-virtualbox-host-modules  2) linux414-virtualbox-host-modules  3) linux419-virtualbox-host-modules
   4) linux44-virtualbox-host-modules  5) linux49-virtualbox-host-modules  6) linux51-virtualbox-host-modules
   7) linux52-virtualbox-host-modules  8) linux53-virtualbox-host-modules
:: Repository community
   9) linux419-rt-virtualbox-host-modules  10) linux52-rt-virtualbox-host-modules  11) virtualbox-host-dkms

Enter a number (default=1):

Pick the host modules that match your kernel version.
You can find out which kernel version you have with:

uname -a

Once you are done with the installation get into your VM and you can adjust the screen size with:

xrandr --output Virtual1 --mode 1920x1200

Using VirtualBox in i3 can be daunting, but it works really well.
You can resize floating dialogs by pressing the right mouse button and dragging from a corner.

Misc stuff

Random stuff that we might need at one point or another…

Chromecast & Videostream

Add the Videostream for Google Chromecast extension.

You need to set up a couple of rules if you have a Chromecast and want to cast videos from your PC:

For a specific IP

Assuming your Chromecast is on 192.168.1.66 you’d need to add these:

sudo ufw allow from 192.168.1.66 to any port 5556
sudo ufw allow from 192.168.1.66 to any port 5558

For any IP in the subnet 192.168.1.x

If your Chromecast changes IP frequently —because you disconnect it or otherwise— it might be easier to allow all devices on your subnet:

sudo ufw allow from 192.168.1.0/24 to any port 5556
sudo ufw allow from 192.168.1.0/24 to any port 5558

Here are some examples of how these rules apply given some CIDR notations:

192.168.1.0/24 => 192.168.1.x
192.168.0.0/16 => 192.168.x.x
192.0.0.0/8 => 192.x.x.x

That’s all for now! 🎉


Got comments or feedback?
Follow me on
rev-3b8671f