2019 / 08 / 31
2023 / 04 / 07
Set up Manjaro i3

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

linux
i3
manjaro

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

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 ~/bin ~/encrypted ~/tmp

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\] "

Power settings configuration and tray icon

Run xfce4-power-manager-settings and configure to your liking.

Don’t forget to enable the system tray icon and status notifications.

You can also open the dialog with xfce4-power-manager --customize.

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 the /etc/default/grub file changes run:

sudo update-grub

Restart your system now

You should be able to use the fstrim command now:

sudo fstrim / -v
# /: 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:

systemctl status fstrim.service

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

sudo systemctl start fstrim

Change login screen background

Look at the files available in /usr/share/backgrounds/ pick one —or copy one of your own— then set the name for it in /etc/lightdm/lightdm-gtk-greeter.conf. Like this:

[greeter]
background = /usr/share/backgrounds/wallpapers-juhraya/Sunset-Of-The-Gods_by_Isaac-Sloan.jpg

Restore your backup

Mount back and restore backup from FDE drive.

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

Current issues

VLC crashes when playing a video

If you have an Nvidia card and your VLC is opening and crashing —with horrible segfaults— when trying to play a video, try adding this to your ~/.profile:

export LIBVA_DRIVER_NAME=nvidia

You can input that line in a terminal in case you’re launching VLC from the CLI. Otherwise, it’ll be good to go after a computer restart.

Super slow startup time for apps

If apps suddenly takes 20+ seconds to start up after latest update you might need to remove: xdg-desktop-portal-gnome.

Try with:

sudo pacman -Rdd xdg-desktop-portal-gnome

Some good Firefox extensions

  • Dark Reader: Dark mode for every website. Take care of your eyes, use dark theme for night and daily browsing.
  • NoScript Security Suite: The best security you can get in a web browser! Allow potentially malicious web content to run only from sites you trust. Protect yourself against XSS other web security exploits.
  • Privacy Badger: Automatically learns to block invisible trackers.
  • uBlock Origin: Finally, an efficient wide-spectrum content blocker. Easy on CPU and memory.

Set up desktop environment

This is the 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 godot \
blender calibre feh obs-studio openshot xfce4-settings \
aegisub redshift simple-scan thunar noto-fonts-emoji \
colordiff python-gobject python-xdg unzip yt-dlp \
pa-applet pavucontrol lxappearance screen \
qgis python-gdal python-owslib python-psycopg2 python-pygments \
ansible bluez bluez-utils inotify-tools jq \
i3 i3-scrot i3exit dmenu-manjaro rxvt-unicode

Run lxappearance and pick a dark theme so Thunar won’t dazzle you at night. :sunglasses:

If you do a lot of work during nights and get burning eyes/headaches, you should try Redshift, it makes working in low light conditions very comfortable.

Reboot into i3.

To check if pipewire is working, run the following command and check the output:

pactl info
# Server Name: PulseAudio (on PipeWire x.y.z)

Desktop notifications

If you try to use notify-send you’ll see an error about org.freedesktop.Notifications missing or something.

To enable:

sudo pacman -S libnotify notification-daemon

Then add the following configuration to: /usr/share/dbus-1/services/org.freedesktop.Notifications.service:

[D-BUS Service]
Name=org.freedesktop.Notifications
Exec=/usr/lib/notification-daemon-1.0/notification-daemon

You can test it from a terminal with:

notify-send "Hola Desktop" "Probando probando 123"

If your notifications don’t show as expected, there might be a conflict with org.freedesktop.Notifications being defined in some other files.

Find which ones with:

grep -r org.freedesktop.Notifications /usr/share/dbus-1/services/

Example output:

/usr/share/dbus-1/services/org.freedesktop.Notifications.service:Name=org.freedesktop.Notifications
/usr/share/dbus-1/services/org.xfce.xfce4-notifyd.Notifications.service:Name=org.freedesktop.Notifications

I’d replace:

Exec=/usr/lib/xfce4/notifyd/xfce4-notifyd`

With:

Exec=/usr/lib/notification-daemon-1.0/notification-daemon

In /usr/share/dbus-1/services/org.xfce.xfce4-notifyd.Notifications.service.

Terminal configuration

I really like rxvt-unicode. It’s a very nimble terminal.

To change the default terminal —the one you get when you press Super + Enter— add this to your ~/.profile:

export TERMINAL="urxvt"

To set the default terminal when right clicking in Thunar and selecting Terminal use: xfce4-settings-manager.
Default Applications -> Utilities -> Terminal Emulator -> RXVT Unicode

List the fonts available in your system with:

fc-list

You might need those in case you want to use a different font in urxvt.

Dark themes for urxvt

I’ve found that dracula is a pretty good dark theme for a terminal.

Download the Xresources file and rename it to: ~/Xresources.dracula.

You can try solarized too, download Xresources.dark and move to ~/Xresources.dark.

Create a ~/.Xresources file with this content:

!! TERMINAL CONFIG

! fake transparency
URxvt*inheritPixmap: true
URxvt*transparent: true
! URxvt*shading: 0 to 99 darkens, 101 to 200 lightens
URxvt*shading: 13

! fix recent issue with prompt appearing in the middle of the screen
!URxvt.geometry: 80x1

! blinky cursor
URxvt.cursorBlink: true

! small
!Xft.dpi: 120

! medium
!Xft.dpi: 160

! big
!Xft.dpi: 220



!! SCROLL BEHAVIOUR

! 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: 1
URxvt.secondaryScroll: 0

! disable the scrollbar
URxvt*scrollBar: false

! lines buffer
URxvt.saveLines: 4096



!! FONT CONFIG

! set terminal font
URxvt.font: xft:Inconsolata:size=10
!URxvt.font: xft:Fira Code:size=8

! tweak font spacing
URxvt.letterSpace: -1



!! CURSOR CONFIG

! magenta cursor color
URxvt.cursorColor: magenta



!! COLOR THEME

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

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

All the lines with ! at the beginning are comments.

Make changes effective with:

xrdb ~/.Xresources

Then open a new terminal with Super + Enter and voilà. :tada:

Setting up i3

After installing i3 you can select the window manager you want to use from the login screen.

Let’s tweak its config files a lil’ bit so it looks better.

In ~/.config/i3status/config:

# i3status configuration file.
# see "man i3status" for documentation.

# It is important that this file is edited as UTF-8.
# The following line should contain a sharp s:
# ß
# If the above line is not correctly displayed, fix your editor first!

general {
  colors = true
  interval = 5
  color_good = "#2AA198"
  color_bad = "#586E75"
  color_degraded = "#DC322F"
}

order += "memory"
order += "cpu_usage"
order += "load"
order += "disk /"
# order += "disk /home"
order += "wireless _first_"
order += "ethernet _first_"
# order += "battery all"
order += "tztime local"
# order += "ipv6"

memory { format = "  🐏  %used / %total  " }

cpu_usage {
  format = "    %usage  "
}

load {
  format = "    %1min  "
  # max_threshold = 0.3
}

disk "/" {
  # format = " hdd %avail "
  format = "    %avail  "
}

ethernet _first_ {
  # if you use %speed, i3status requires root privileges
  format_up = "    %ip  %speed  "
  format_down = "  No    "
}

wireless _first_ {
  # if you use %speed, i3status requires root privileges
  format_up = "    %ip  %speed  "
  format_down = "  No    "
}

battery all {
  # format = "%status %percentage %remaining %emptytime"
  format = " %status %percentage"
  format_down = "No battery"
  last_full_capacity = true
  integer_battery_capacity = true
  # status_chr = ""
  status_chr = "⚡"
  # status_bat = "bat"
  # status_bat = "☉"
  status_bat = ""
  # status_unk = "?"
  status_unk = ""
  # status_full = ""
  status_full = "☻"
  low_threshold = 15
  threshold_type = time
}

tztime local {
  # format = "%Y-%m-%d %H:%M:%S"
  # format = "%H:%M:%S %Z »«  %A, %d de %B de %Y"
  format = "  %A    %Y / %m / %d       %H: %M: %S      "
}

At the end of ~/.config/i3/config add:

# STUFF TODO
# Delete all references to $ws10
# Comment out the dmenu_run line:
#bindsym $mod+d exec --no-startup-id dmenu_run



# CUSTOM STUFF

# Firefox stealing my focus when saving on VSCode
# while doing Phoenix + LiveView was driving me mad
# this prevents that
focus_on_window_activation urgent
# Other values: smart urgent focus none
# Default: smart

# Start dmenu_recency (a program launcher) launch with `Super+D`
bindsym $mod+d exec --no-startup-id dmenu_recency

# Move to workspace with focused container
bindsym $mod+Ctrl+1 move container to workspace $ws1; workspace $ws1
bindsym $mod+Ctrl+2 move container to workspace $ws2; workspace $ws2
bindsym $mod+Ctrl+3 move container to workspace $ws3; workspace $ws3
bindsym $mod+Ctrl+4 move container to workspace $ws4; workspace $ws4
bindsym $mod+Ctrl+5 move container to workspace $ws5; workspace $ws5
bindsym $mod+Ctrl+6 move container to workspace $ws6; workspace $ws6
bindsym $mod+Ctrl+7 move container to workspace $ws7; workspace $ws7
bindsym $mod+Ctrl+8 move container to workspace $ws8; workspace $ws8
bindsym $mod+Ctrl+9 move container to workspace $ws9; workspace $ws9

# Set shut down, restart and locking features
bindsym $mod+0 mode "$mode_system"
set $mode_system (l)ock, (e)xit, switch_(u)ser, (s)uspend, (h)ibernate, (r)eboot, (Shift+s)hutdown
mode "$mode_system" {
    bindsym l exec --no-startup-id i3exit lock, mode "default"
    bindsym s exec --no-startup-id i3exit suspend, mode "default"
    bindsym u exec --no-startup-id i3exit switch_user, mode "default"
    bindsym e exec --no-startup-id i3exit logout, mode "default"
    bindsym h exec --no-startup-id i3exit hibernate, mode "default"
    bindsym r exec --no-startup-id i3exit reboot, mode "default"
    bindsym Shift+s exec --no-startup-id i3exit shutdown, mode "default"

    # exit system mode: "Enter" or "Escape"
    bindsym Return mode "default"
    bindsym Escape mode "default"
}

# Open specific applications in floating mode
for_window [class="Pavucontrol"] floating enable border normal

# Configure border style <normal|1pixel|pixel xx|none|pixel>
default_border pixel 1
default_floating_border normal

# change borders
bindsym $mod+u border none
bindsym $mod+y border pixel 1
bindsym $mod+n border normal

# Start Applications
#bindsym Print exec --no-startup-id i3-scrot
#bindsym $mod+Print --release exec --no-startup-id i3-scrot -w
#bindsym $mod+Ctrl+Print --release exec --no-startup-id i3-scrot -w -d 5
#bindsym $mod+Shift+Print --release exec --no-startup-id i3-scrot -s
bindsym Insert exec --no-startup-id i3-scrot
bindsym $mod+Insert --release exec --no-startup-id i3-scrot -w
bindsym $mod+Ctrl+Insert --release exec --no-startup-id i3-scrot -w -d 5
bindsym $mod+Shift+Insert --release exec --no-startup-id i3-scrot -s


# Set up workspace default output
workspace 1 output HDMI-1
workspace 2 output HDMI-1

workspace 7 output HDMI-0
workspace 8 output HDMI-0


# To get the right values for your monitors setup, run `xrandr`.

# Two monitor setup
#exec --no-startup-id xrandr --output DP-2 --primary --mode 3440x1440 --pos 0x560 --rotate normal --output DP-0 --mode 2560x1440 --pos 3440x0 --rotate left --output DVI-D-0 --off --output HDMI-0 --off --output HDMI-1 --off
#exec --no-startup-id xrandr --output DP-2 --primary --mode 3840x2160 --pos 0x200 --rotate normal --output DP-0 --mode 2560x1440 --pos 3840x0 --rotate left --scale 1.4x1.4 --output DVI-D-0 --off --output HDMI-0 --off --output HDMI-1 --off --output DP-1 --off
exec --no-startup-id xrandr --output HDMI-1 --primary --mode 3840x2160 --pos 0x840 --rotate normal --output HDMI-0 --mode 3840x2160 --pos 3840x0 --rotate right --output DVI-D-0 --off --output DP-0 --off --output DP-1 --off --output DP-2 --off --output DP-3 --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 2%+
bindsym $mod+Shift+Next exec --no-startup-id amixer -D pulse sset Master 2%-
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

exec --no-startup-id pa-applet
exec --no-startup-id xfce4-power-manager


# 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

dmenu config files

You can see and modify cached entries for dmenu_recency in: ~/.cache/dmenu-recent/recent.

And reset a previous entry run configuration by deleting it from the appropriate file in: ~/.config/dmenu-recent/.

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: 2;
}

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

Dark mode

Click the Preferences button in the main Calibre interface.
Select Look & feel, and then pick Dark in Color palette (needs restart).

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 development tools

Let’s install some useful stuff 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

Tech stack

GRASS for QGIS

To have v.generalize available on QGIS:

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

Misc stuff

Random stuff needed from time to time…

Configure yt-dlp to download mp4 by default

Create a ~/.config/yt-dlp.conf file, and put this content in it:

# Download mp4 version of videos, if available
-f "bestvideo[ext=mp4]+bestaudio[ext=mp4]/best[ext=mp4]/best"

Enable ray tracing for Nvidia cards

If you have an RTX card and want to enable ray tracing in your games, install the following dependencies:

sudo pacman -S nvidia-utils nvidia-settings

Add these env vars to your .bashrc or .profile:

export VKD3D_CONFIG=dxr11,dxr
export PROTON_ENABLE_NVAPI=1
export PROTON_ENABLE_NGX_UPDATER=1

You can use the following commands to get info about your card and current driver:

nvidia-smi

# and/or
nvidia-settings

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.

That’s all for now! :tada:

Resources