Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,19 @@ Then follow prompts:
```
Configure git? [y/N]
Generate SSH key? [y/N]
/home/holmen1/repos/dotfiles/install/bsdinstall/packages/besk/pkglist.txt
Install yay? [y/N]
/home/holmen1/repos/dotfiles/install/archinstall/packages/x1/pkglist.txt
Install pkglist? [y/N]
/home/holmen1/repos/dotfiles/install/archinstall/packages/x1/foreignpkglist.txt
Install foreignpkglist? [y/N]
Build xmonad? [y/N]
Install xmonad? [y/N]
Build st? [y/N]
Install st? [y/N]
Build xkb keymap? [y/N]
Link dotfiles? [y/N]
Enable system monitoring? [y/N]
Run tests? [y/N]
Enable services? [y/N]
Run tests? [Y/n]
```


Expand Down
18 changes: 0 additions & 18 deletions dotfiles/keyd/default.conf

This file was deleted.

81 changes: 0 additions & 81 deletions dotfiles/nvim/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,85 +349,4 @@ bear -- make
:LspStart
```

## TODO: Home-Row Digits (Linux & FreeBSD)

Explore setting up a "Num Layer" to type digits without reaching for the top row on a standard Swedish layout. The goal is to use the Spacebar as a dual-function "Tap-Hold" key: tap it for a normal `Space`, but hold it down with the thumb to activate a temporary number layer (e.g., mapping `j, k, l` to `4, 5, 6` like a physical numpad).

**Using `keyd` (Linux & FreeBSD)**

`keyd` intercepts input at the kernel level (`evdev`) and works identically on both platforms with the same config file.

Install:
```bash
# Arch
sudo pacman -S keyd
sudo systemctl enable --now keyd

# FreeBSD
sudo pkg install keyd
sudo sysrc keyd_enable=YES
sudo service keyd start
```

Config file:
- Linux: `/etc/keyd/default.conf`
- FreeBSD: `/usr/local/etc/keyd/default.conf`

```ini
[ids]
*

[main]
# Tap space for space, hold space to activate the 'num_layer'
space = overload(num_layer, space)

[num_layer]
u = 7
i = 8
o = 9
j = 4
k = 5
l = 6
m = 1
, = 2
. = 3
n = 0
```

Reload after editing:
```bash
sudo keyd reload
```

> Note: VT switching is not supported on FreeBSD with `keyd`.
---

## FreeBSD Keyboard Recovery (if you lose input at login)

If you cannot type at the FreeBSD login prompt (before X11), you may have a misconfigured keyboard layout or key remapping daemon (e.g., keyd). To recover:

1. **Reboot and enter single-user mode** from the boot menu.
2. At the prompt, remount filesystems:
```
mount -u /
mount -a
```
3. Check `/etc/rc.conf` for any `keymap` lines. Comment them out or set to a known working value (e.g., `keymap="us"`).
4. Check for recent changes to `/etc/sysctl.conf` or `/etc/ttys` that might affect keyboard input.
5. If you enabled keyd at the system level, disable it:
```
service keyd stop
sysrc keyd_enable=NO
```
6. Reboot and test keyboard input at the login prompt.

Once you regain access, reapply changes one at a time to identify the cause. If you use a non-US layout, set it only after confirming basic input works.

**How to proceed after recovery:**

1. Confirm you can log in and type at the console.
2. Re-enable your desired keyboard layout (e.g., Swedish) in X11 only (e.g., via `setxkbmap se` in `.xinitrc`).
3. If using keyd, test its config with the default US layout first, then add custom mappings for your layout as needed.
4. Make incremental changes and reboot or restart X to test each step.
5. Document any changes that cause issues for future reference.
1 change: 1 addition & 0 deletions dotfiles/x/.xinitrc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ esac

# Set keymap (don't background - fast and should complete before apps start)
setxkbmap se
echo "se" > "$HOME/.cache/xkb-layout" # Cache current layout for dmenu status script

# Set the default X cursor to the usual pointer
xsetroot -cursor_name left_ptr &
Expand Down
29 changes: 29 additions & 0 deletions dotfiles/x/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# X

X11 session startup via `~/.xinitrc`.

---

## Files

| Path | Purpose |
|------------|----------------------------------|
| `.xinitrc` | X session startup — env, apps |

---

## Startup sequence

1. Check essential programs (`xmonad`, `xterm`)
2. Set `EDITOR`, `TERMINAL`, `BROWSER`
3. Apply base keyboard layout (`setxkbmap se`)
4. Start `xsetroot`, `feh`, `dunst`, `xcompmgr`, `xbindkeys`
5. `exec xmonad`

---

## Keyboard customisation

Extended key behaviour (CapsLock→Control/Escape, Super→num-layer) lives in
`dotfiles/xkb/` and is applied by running `~/.local/bin/apply-keys.sh` manually.
See [xkb/README.md](../xkb/README.md) for details.
Binary file added dotfiles/xkb/.config/xkb/keymap-bsd.xkb
Binary file not shown.
Binary file added dotfiles/xkb/.config/xkb/keymap-linux.xkb
Binary file not shown.
133 changes: 133 additions & 0 deletions dotfiles/xkb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# XKB

X11 keyboard customisation using **XKB** and **xcape**.

## Key behaviour

| Key | Tap | Hold |
|----------|---------|-------------|
| CapsLock | Escape | Control |
| Super | — | Num-layer |

## Custom symbol mappings

| Key | L1 | L2 | L3 | L4 |
|-----|-----|-----|-----|----|
| u | u | U | 7 | — |
| i | i | I | 8 | — |
| o | o | O | 9 | — |
| å | [ | ] | — | — |
| s | s | S | $ | — |
| j | j | J | 4 | ( |
| k | k | K | 5 | ) |
| l | l | L | 6 | — |
| ö | ⌫ | : | = | — |
| ä | ↑ | \| | / | — |
| n | n | N | 0 | — |
| m | m | M | 1 | — |
| , | , | ; | 2 | — |
| . | . | : | 3 | — |

### Num-layer

Level 3 (Super held) maps row keys to numpad grid:
```
u i o → 7 8 9
j k l → 4 5 6
m , . → 1 2 3
n → 0
```

### XKB Levels

Each key can have up to 8 levels, defined as `[ level1, level2, level3, level4, ... ]`:
- **Level 1**: normal tap
- **Level 2**: Shift+key
- **Level 3**: Super+key (via `lv3:lwin_switch`)
- **Level 4**: Super+Shift+key

Example: `key <AD07> { [ u, U, 7 ] };` means: normal=`u`, Shift=`U`, Super=`7`.

---

## Files

| Path | Purpose |
|----------------------------------------|--------------------------------------|
| `.config/xkb/keymap.xkb` | Compiled keymap (generated by build) |
| `apply-keys.sh` | Loads keymap + starts xcape |

See [install/build/xkb/README.md](../../install/build/xkb/README.md) for build details.

---

## Installation (Arch Linux)

```sh
sudo pacman -S xorg-setxkbmap xorg-xkbcomp xcape
```

Symlink `dotfiles/xkb/` files to `$HOME`, build the keymap once, then `apply-keys.sh` runs on every X startup via `~/.xinitrc`:

```sh
# Once (or whenever symbols/local changes)
install/build/xkb/build-xkb.sh

# On every X startup — called automatically by ~/.xinitrc
~/.local/bin/apply-keys.sh
```

---

## How it works

### CapsLock → Control / Escape

`ctrl:nocaps` (built-in XKB option) replaces CapsLock with `Control_L`.
xcape then synthesises `Escape` when `Control_L` is released without a chord:

```sh
xcape -e 'Control_L=Escape'
```

### Super → Num-layer

`lv3:lwin_switch` (built-in XKB option) makes the left Super key the
**level-3 activator** — the same mechanism as AltGr.
`~/.config/xkb/symbols/local` assigns digits at level 3 for the numpad cluster.

### XKB Levels

Each key has multiple levels — outputs defined as `[ level1, level2, level3, ... ]`:
- **Level 1**: unshifted (normal tap)
- **Level 2**: Shift+key
- **Level 3**: level-3 activator held (AltGr by default, Super in this config)
- **Level 4**: level-3 + Shift

Example: `key <AD07> { [ u, U, 7 ] };` means: normal=`u`, Shift=`U`, Super=`7`.

### Load (`apply-keys.sh`)

Run on every X startup via `.xinitrc`:

1. `xkbcomp keymap.xkb $DISPLAY` loads the pre-compiled keymap — no setxkbmap, no sed
2. `xcape` is restarted to synthesise Escape on CapsLock tap

---

## Lessons learned

**Shift modifier stays active in apps**: If a key at level 2 (Shift+key) produces a keysym like `Up`, the app still sees `Shift+Up` instead of bare `Up`. Put frequently-used, modifier-sensitive keys at level 1.

Example: `ö → Up` at L1 scrolls fine; at L2 it would send `Shift+Up`, which most apps don't recognize as scroll.

---

## Debugging

```sh
setxkbmap -query # current options
xkbcomp -xkb "$DISPLAY" - | grep -A4 'key <LWIN>' # check Super mapping
xkbcomp -xkb "$DISPLAY" - | grep -A4 'key <AD07>' # check u/7 mapping
xev | grep -A2 KeyPress # watch raw events
```
1 change: 0 additions & 1 deletion dotfiles/xmonad/.gitignore

This file was deleted.

35 changes: 21 additions & 14 deletions dotfiles/xmonad/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,39 @@ This repository contains a custom configuration for the [XMonad](https://xmonad.

## Shortcuts

| Key Combination | Action |
|------------------------|----------------------------------------|
| Key Combination | Action |
|------------------------|---------------------------------------|
| `Mod + Enter` | Launch terminal |
| `Mod + H` | Help menu |
| `Mod + Q` | Close the focused window |
| `Mod + Space` | Rotate through available layouts |
| `Mod + Shift + Space` | Reset the layout to default |
| `Mod + N` | Resize/refresh windows |
| `Mod + Tab` | Move to the next workspace |
| `Mod + Shift + Tab` | Move focus to the previous window |
| `Mod + J` | Move focus to the next window |
| `Mod + K` | Move focus to the previous window |
| `Mod + Shift + Return` | Swap the focused window with master |
| `Mod + Tab` | Next workspace |
| `Mod + Shift + Tab` | Previous workspace |
| `Mod + [1..4]` | Switch to workspace N |
| `Mod + Shift + [1..4]` | Move window to workspace N and follow |
| `Mod + E` | Launch file manager (lf) |
| `Mod + B` | Launch browser |
| `Mod + Space` | Rotate through available layouts |
| `Mod + H` | Shrink the master area |
| `Mod + L` | Expand the master area |
| `Mod + ,` | Increment master windows |
| `Mod + .` | Decrement master windows |
| `Mod + X` | Logout menu |
| `Mod + M` | VPN menu |
| `Mod + Shift + Return` | Swap the focused window with master |
| `Mod + S` | Screenshot to `~/Downloads` |
| `Mod + Shift + S` | Capture a selected area screenshot to `~/Downloads` |
| `Mod + W` | Launch browser |
| `Mod + Shift + S` | Screenshot selected area |
| `Mod + W` | Browser scratchpad toggle |
| `Mod + P` | htop scratchpad toggle |
| `Mod + V` | VPN menu |
| `Mod + Z` | XKB layout menu |
| `Mod + X` | Logout menu |
| `Mod + A` | Launch dmenu |
| `Mod + Shift + Q` | Quit xmonad |
| `Mod + M` | Help menu |


## Requirements

- [Xmobar](https://xmobar.org/)
- [Xmobar](https://xmobar.org/) NOT USING
- [st - simple terminal](https://st.suckless.org/)
- [Brave](https://brave.com/linux/)
- thunar fileexplorer
Expand Down
Loading