Skip to content

Instantly share code, notes, and snippets.

@dattasaurabh82
Last active December 16, 2025 02:31
Show Gist options
  • Select an option

  • Save dattasaurabh82/1bae6c1c6185f022b4f516ab4ee424f2 to your computer and use it in GitHub Desktop.

Select an option

Save dattasaurabh82/1bae6c1c6185f022b4f516ab4ee424f2 to your computer and use it in GitHub Desktop.
Raspberry Pi Tmux Dashboard on Boot

Raspberry Pi Tmux Dashboard on Boot

Auto-launch a tmux monitoring dashboard on Raspberry Pi boot (headless/CLI). Press any key within 10 seconds to skip and drop to shell.

Note

I use this for a pi that I carry on-site, either when I'm teaching or on a client side, where I need a MQTT broker and also where wifi setup shoudl be easy (So, my pi is running: headless pi wifi configurator)

Screenshot 2025-12-15 at 23 04 10

PXL_20251216_005818270 PORTRAIT

Note

If you are interested in the 3D printed parts, you can find them here in printables



Layout

┌─────────────┬─────────────┐
│  app log    │             │
│  (tail -f)  │    htop     │
├─────────────┤ (full right)│
│ mosquitto   │             │
│   log       │             │
└─────────────┴─────────────┘

Requirements

Installation

1. Create the boot script:

sudo nano /home/pi/rpi-dashboard-boot.sh

Paste the script below, then:

sudo chmod +x /home/pi/rpi-dashboard-boot.sh

Then, test it by running manually:

./rpi-dashboard-boot.sh

2. Add to shell config (choose your shell):

Fish Shell

nano ~/.config/fish/config.fish

Add at the end:

# Auto-launch dashboard on TTY login
if status is-login; and status is-interactive; and test -z "$TMUX"; and tty | grep -q tty
    /home/pi/rpi-dashboard-boot.sh
end

Bash

nano ~/.bash_profile

Add at the end:

# Auto-launch dashboard on TTY login
if [[ -z "$TMUX" ]] && [[ $(tty) == /dev/tty* ]]; then
    /home/pi/rpi-dashboard-boot.sh
fi

Zsh

nano ~/.zprofile

Add at the end:

# Auto-launch dashboard on TTY login
if [[ -z "$TMUX" ]] && [[ $(tty) == /dev/tty* ]]; then
    /home/pi/rpi-dashboard-boot.sh
fi

3. Reboot and enjoy.

The Script

#!/bin/bash
# rpi-dashboard-boot.sh

TIMEOUT=10
SESSION=dashboard
LOG_DIR="/home/pi/rpi-wifi-configurator/logs"

# Countdown with keypress detection
echo ""
echo "╔════════════════════════════════════════════════════════════╗"
echo "║  Press any key within ${TIMEOUT} seconds to skip dashboard...    ║"
echo "╚════════════════════════════════════════════════════════════╝"
echo ""

for i in $(seq $TIMEOUT -1 1); do
    printf "\r  Launching dashboard in %2d seconds... " "$i"
    read -t 1 -n 1 key
    if [ $? -eq 0 ]; then
        echo ""
        echo "Key pressed! Dropping to shell..."
        exit 0
    fi
done

echo ""
echo "Starting dashboard..."

# Kill existing session
tmux kill-session -t $SESSION 2>/dev/null

# Find latest log file
LATEST_LOG=$(ls -t "$LOG_DIR"/log_*.log 2>/dev/null | head -n 1)
if [ -z "$LATEST_LOG" ]; then
    LOG_CMD="echo 'No log files found'; $SHELL"
else
    LOG_CMD="tail -f '$LATEST_LOG'"
fi

# Create tmux session with 3 panes
tmux new-session -d -s $SESSION
tmux split-window -h -t $SESSION
tmux split-window -v -t $SESSION:0.0

# Pane 0: app log (top-left)
# Pane 1: mosquitto (bottom-left)  
# Pane 2: htop (full right)
tmux send-keys -t $SESSION:0.0 "$LOG_CMD" C-m
tmux send-keys -t $SESSION:0.1 'sudo tail -f /var/log/mosquitto/mosquitto.log' C-m
tmux send-keys -t $SESSION:0.2 'htop' C-m

tmux select-pane -t $SESSION:0.0
exec tmux attach-session -t $SESSION

Customization

Variable Description
TIMEOUT Seconds to wait for keypress (default: 10)
SESSION tmux session name
LOG_DIR Directory containing app log files

Notes

  • Assumes user is pi (If not you can always change it, it's a simple script)
  • Also you can adjust to view what-ever, now you have a boilerplate ...
  • Only triggers on TTY (physical console), not SSH sessions. SSH access always drops straight to shell
  • Press any key during countdown to skip dashboard
  • Kill: You can login to a different session (over SSH) and execute: tmux kill-session -t dashboard or if you have keyboard attached to the pi, you know what you can do :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment