i3 Desktop Part 6: Hardware Menus

Hardware controls can make a minimal desktop difficult to use.

Changing Wi-Fi from a terminal is acceptable occasionally. Doing it daily is not. Switching audio outputs with raw commands is possible. Remembering the exact command when headphones fail to become default wastes attention. Monitor layout is worse because the command changes depending on connected devices.

This setup uses small menus around tools I would use manually anyway.

The tools are:

  • xrandr for monitor layout and scaling
  • setxkbmap and IBus sync for keyboard layout
  • nmcli for network
  • bluetoothctl for Bluetooth
  • wpctl for PipeWire audio

The menus do not hide the system. They make the common path quick.

Monitor layout

.local/bin/i3-monitor-layout handles display arrangements.

It supports:

  • auto or docked
  • laptop only
  • external only
  • extend right
  • mirror
  • list outputs
  • open display scaling

The auto layout is important. On startup, i3 runs i3-monitor-layout auto --quiet. If an external display is connected, it makes that the primary output and keeps the internal display to the left. If no external display is connected, it uses laptop only.

This covers the two states I use most: undocked and docked.

The script reapplies the wallpaper after changing layout. This avoids a broken look after xrandr rearranges outputs.

Display scaling

.local/bin/i3-monitor-scaling is separate because layout and scale are different problems.

It applies scaling to all active displays or a selected output. The menu offers common UI sizes: 100, 125, 150, 175, 200 percent, plus smaller UI options and a custom percent.

It converts UI percent into an xrandr scale value. For example, a 150 percent UI means an xrandr scale of 100 / 150.

It has a status view that reads xrandr transform output and reports the current UI scale. This prevents display scaling from becoming invisible state.

Keyboard layout

The keyboard layout script exists because I move between the laptop keyboard and an external keyboard.

.local/bin/i3-keyboard-layout switches between:

  • UK English for the laptop
  • US English for the external keyboard

It saves the selected layout in .config/i3/keyboard-layout and reapplies it on i3 reload. It also syncs IBus where possible and hides the IBus tray indicator.

This removes a constant irritation. The keyboard layout becomes an explicit desktop state rather than something I manually fix after noticing a quote key is wrong.

Network

The network menu wraps nmcli.

It can show status and control Wi-Fi connections. It can open the NetworkManager connection editor. It can also enable or disable all network connections.

For new Wi-Fi connections, it scans, shows SSIDs with signal and security, prompts for a password through rofi when needed, and then calls nmcli device wifi connect.

The status bar uses the same idea. It finds the primary connected device, filters out loopback, bridges, veth devices, Docker-style interfaces, and similar noise, then shows the connection name and IP address. If a VPN or WireGuard connection is active, it appends VPN.

Bluetooth

The Bluetooth menu wraps bluetoothctl.

It can show controller status and control Bluetooth power. It can connect, disconnect, scan, and pair devices. It can make the adapter pairable and discoverable. It can also open blueman-manager for the full graphical interface.

Pairing is a flow where I do not want to remember the exact sequence every time. The script powers on Bluetooth, starts the agent, scans for ten seconds, lets me pick a device, pairs, trusts, and connects.

This is a good use of a script. It captures a workflow, not a new abstraction.

Audio

Audio uses PipeWire through wpctl.

The menu can switch output devices, switch input devices, mute output, mute input, adjust volume, open pavucontrol, and show current status.

The status script parses wpctl status to list sinks and sources, marking the current default device. Selecting a device calls wpctl set-default. Volume keys call wpctl set-volume, and the volume block in the bar refreshes immediately.

This keeps audio control keyboard-first but still gives me a fallback path when devices appear with unhelpful names.

The pattern

These scripts are not large, and that is the point.

Each one wraps an existing Linux command-line tool with:

  • a rofi menu
  • a direct command mode for keybindings
  • dunst feedback
  • a status action
  • a small amount of state when needed

This makes hardware controls feel integrated into i3 without depending on a full desktop settings daemon.