This is a collection of useful references, snippets, and information that I found useful when tinkering with Arch Linux.

Network

Wi-Fi Connection

Using iwd

  1. Make sure that iwd is running:

    $ sudo systemctl status iwd

    If not, start the service by running:

    $ sudo systemctl enable iwd
    $ sudo systemctl start iwd
  2. Start the interactive prompt:

    $ sudo iwctl
  3. Find the name of the wireless device by listing all devices:

    [iwd]# device list

    If the device is turned off, turn it on:

    [iwd]# device [DEVICE_NAME] set-property Powered on
  4. Initiate a scan for networks:

    [iwd]# station [DEVICE_NAME] scan

    then list all available networks:

    [iwd]# station [DEVICE_NAME] get-networks
  5. Connect to the desired network:

    [iwd]# station [DEVICE_NAME] connect [SSID]

    Enter the passphrase (if prompted) to the network.

Using NetworkManager(nmcli)

  1. Install networkmanager package if NetworkManager is not installed.

    $ sudo pacman -S networkmanager
  2. Start / enable NetworkManager.service.

    $ sudo systemctl start NetworkManager.service
    $ sudo systemctl enable NetworkManager.service
  3. List nearby Wi-Fi networks:

    $ nmcli device wifi list

    Connect to a Wi-Fi network:

    $ nmcli device wifi connect [SSID] password [PASSWORD]

    Connet to a Wi-Fi network (input password through STDIN):

    $ nmcli device wifi connect [SSID] --ask

    Disconnect an interface:

    $ nmcli device disconnect ifname [INTERFACE]

    Get a list of connections with their names, UUIDs, types and backing devices:

    $ nmcli connection show

    Turn of Wi-Fi:

    $ nmcli radio wifi off
Using iwd as the Wi-Fi Backend
  1. Install iwd.

    $ sudo pacman -S iwd
  2. Create the following configuration file:

    /etc/NetworkManager/conf.d/wifi_backend.conf
    [device]
    wifi.backend=iwd

Battery

Check Battery Status

  1. Install tlp.
    $ sudo pacman -S tlp
  2. Run the following command.
    $ sudo tlp-stat -b

Input Devices

Keyboard Input Remapping

Dual Function Keys

  1. Run the following command and find out the name of the keyboard.

    $ libinput list-devices | grep "^Device"
  2. Create a new configuration:

    /etc/interception/udevmon.d/[KEYBOARD_NAME].yaml
    - JOB: "intercept -g $DEVNODE | dual-function-keys -c </path/to/dual-function-keys.yaml> | uinput -d $DEVNODE"
      DEVICE:
        NAME: <keyboard name>

    When using a wireless keyboard however, setting the name sometimes does not work. In this case, set the name to .*, which processes every input.

  3. Create a yaml file (conventionally resides in /etc/interception/dual-function-keys) that contains the configuration for Dual Function Keys itself. I use the following configuration:

    /etc/interception/dual-function-keys
    TIMING:
      TAP_MILLISEC: 1000
      DOUBLE_TAP_MILLISEC: 0
      SYNTHETIC_KEYS_PAUSE_MILLISEC: 0
    MAPPINGS:
      # Esc and LCtrl with CapsLock
      - KEY: KEY_CAPSLOCK
        TAP: KEY_ESC
        HOLD: KEY_LEFTCTRL

    However, pressing the key will still send the original key on press, and this may interfere with programs such as (neo)vim. To prevent this, add HOLD_START: BEFORE_CONSUME_OR_RELEASE.

Using evremap

  1. Install evremap from AUR:

    $ paru -S evremap-git
  2. Enable / start the system service:

    $ sudo systemctl enable evremap.service
    $ sudo systemctl start evremap.service
  3. Edit the service file to point to your config. First check the path of the service:

    $ systemctl status evremap.service

    Then edit the file to point to your config:

    /usr/lib/systemd/system/evremap.service
    ...
    ExecStart=bash -c "/usr/bin/evremap remap /etc/evremap.toml -d 0"
    ...
  4. Configure remapping to your taste:

    # The name of the device to remap.
    # Run `sudo evremap list-devices` to see the devices available
    # on your system.
    device_name = "[DEVICE_NAME]"
     
    # If you have multiple devices with the same name, you can optionally
    # specify the `phys` value that is printed by the `list-devices` subcommand
    # phys = "usb-0000:07:00.3-2.1.1/input0"
     
    # Configure CAPSLOCK as a Dual Role key.
    [[dual_role]]
    input = "KEY_CAPSLOCK"
    hold = ["KEY_LEFTCTRL"]
    tap = ["KEY_ESC"]
     
    [[remap]]
    input = ["KEY_LEFTMETA"]
    output = ["KEY_LEFTALT"]
     
    [[remap]]
    input = ["KEY_LEFTALT"]
    output = ["KEY_LEFTMETA"]
     
    [[remap]]
    input = ["KEY_RIGHTMETA", "KEY_K"]
    output = ["KEY_UP"]
     
    [[remap]]
    input = ["KEY_RIGHTMETA", "KEY_L"]
    output = ["KEY_RIGHT"]

Korean (Hangul) Input

This only works for hyprland. Source

  1. Install kime from AUR.

    $ paru -S kime-bin
  2. Add the following configuration:

    hyprland.conf
    # Execute kime
    exec-once = kime
     
    # Set envvars for kime
    env = XDG_CURRENT_DESKTOP,Hyprland
    env =GTK_IM_MODULE,kime
    env = QT_IM_MODULE,kime
    env = XMODIFIERS,@im=kime
     
    # Set ralt, rctrl to hangul and hanja
    input {
        ...
        kb_options = korean:ralt_hangul,korean:rctrl_hanja
    }

Miscellaneous

Run Fetch Script on Terminal Launch

$ function fish_greeting
    neofetch
end
$ funcsave fish_greeting

Source

According to the official docs, fish_greeting is executed only when an interactive fish starts.

OBS Virtual Camera

  1. Install the v4l2loopback-dkms package.

    $ sudo pacman -S v4l2loopback-dkms
  2. Load the kernel module.

    $ sudo modprobe v4l2loopback
  3. To reload the module, first unload the module.

    $ sudo modprobe -r v4l2loopback
  4. For Chromium / WebRTC based applications, set option exclusive_caps=1.

    $ sudo modprobe v4l2loopback exclusive_caps=1

GPG waiting for lock ... Error

  1. Locate all files with .lock or .lck extension inside ~/.gnupg.

    $ ls -l ~/.gnupg/*/*.l{o,}ck
  2. Remove any lock files found.

Changing the default browser

  1. To get the current default web browser:

    xdg-settings get default-web-browser
  2. To set the default web browser:

    xdg-settings set default-web-browser [BROWSER]

    for example,

    xdg-settings set default-web-browser librewolf.desktop

    Source

Keyboard Backlight / Brightness

  1. Install brightnessctl:
    $ sudo pacman -S brightnessctl

Keyboard Backlight

  1. Get the maximum brightness level (obtain the vendor name using ls in the directory):
    $ cat /sys/class/leds/[VENDOR]::kbd_backlight/max_brightness
    Or alternatively:
    $ brightnessctl --device='[VENDOR]::kbd_backlight' info
    Then set the brightness using brightnessctl:
    $ brightnessctl --device='[VENDOR]::kbd_backlight' set [BRIGHTNESS]
    Make sure to set the brightness level below the max level.

Brightness

  1. Same process as keyboard backlight, but use the path
    $ cat /sys/class/backlight/[VENDOR]/max_brightness
    instead.

Clipboard

Piping Command Outputs to Clipboard

Wayland
  1. Install wl-clipboard:

    $ sudo pacman -S wl-clipboard
  2. To copy:

    $ echo foo | wl-copy
  3. To paste:

    $ wl-paste
    foo
X Window System
  1. Install xclip:

    $ sudo pacman -S xclip
  2. Add aliases. In bash:

    .bash_aliases
    ...
    alias setclip="xclip -selection c"
    alias getclip="xclip -selection c -o"
    ...

    In fish:

    config.fish
    ...
    abbr setclip "xclip -selection c"
    abbr getclip "xclip -selection c -o"
    ...
  3. To copy:

    $ echo foo | setclip
  4. To paste:

    $ getclip
    foo

Source

MacOS
  1. To copy:

    $ echo foo | pbcopy

    To copy the contents of a file, this also works (so that you don’t have to use cat):

    $ pbcopy < file.txt
  2. To paste:

    $ pbpaste
    foo

Access System Clipboard in (Neo)Vim

I use hyprland, so this only works for Wayland.

  1. Install wl-clipboard:
    $ sudo pacman -S wl-clipboard
  2. Add the following line to init.vim:
    set clipboard+=unnamedplus
    Or to init.lua for neovim:
    vim.opt.clipboard:append("unnamedplus")

Change Acceleration Profile for ThinkPad Trackpoints

Change libinput acceleration profile for ThinkPad’s trackpoint from adaptive to flat. This only works for hyprland. Source

hyprland.conf
device {
    name = tpps/2-ibm-trackpoint
    accel_profile = flat
}

Extract data.tar.gz(or .xz) from .deb

Use ar from binutils. binutils is in the base-devel group, so it should be already installed. Source

$ ar x <deb-file$ data.tar.gz

Desktop Entries

Desktop entries for applications (.desktop files) usually reside in /usr/share/applications/ or /usr/local/share/applications/.

Modify environment variables

To set environment variables, edit the Exec= line to first use env. For example:

/usr/share/applications/steam.desktop
...
Exec=env GDK_SCALE=2 /usr/bin/steam-runtime %U
...