Skip to content

(Feature addition) Screensaver mode! #4

Description

@moorew

There are times when you don't want BMO to be in "Agent Mode"—maybe you just want a Pi for watching videos, running a background process, or simply looking cool on your desk without the mic listening.

For those times, I created a native screensaver that autostarts on boot and rotates through the faces folder. It treats the images like a proper screensaver: it starts after 60 seconds of inactivity and kills the process instantly when you move the mouse.

Key Features:

  • Autostarts after 60 seconds of inactivity.
  • Wakes up instantly on any mouse click or key press.
  • Automatically disables itself if the BMO agent (agent.py) is running, so it won't interrupt your AI.

Simply copy and paste the script below into your terminal. It handles all the dependencies, creates the logic, and sets up the autostart automatically.

#!/bin/bash

# ==========================================
# BMO Screensaver Installer (Wayland/Pi 5)
# ==========================================

# --- Configuration ---
TIMEOUT_SECONDS=60
PROJECT_DIR="$HOME/be-more-agent"
IMAGES_DIR="$PROJECT_DIR/faces"
AUTOSTART_DIR="$HOME/.config/autostart"
DESKTOP_FILE="$AUTOSTART_DIR/bmo-screensaver.desktop"
EXCLUDE_KEYWORD="warmup"

# Script Paths
SCRIPT_START="$PROJECT_DIR/saver-start.sh"
SCRIPT_KILL="$PROJECT_DIR/saver-kill.sh"
SCRIPT_WATCH="$PROJECT_DIR/saver-watch.sh"
INPUT_CONF="$PROJECT_DIR/saver-input.conf"
BLOCK_PROCESS="agent.py"

echo "🤖 Initiating BMO Screensaver Setup..."

# 1. Install Dependencies
sudo apt update -qq
sudo apt install -y swayidle mpv

# 2. Clean up old processes
killall -q -9 swayidle
killall -q -9 mpv

# 3. Create MPV Input Config (Click or Key to Close)
cat <<EOF > "$INPUT_CONF"
MBTN_LEFT quit
MBTN_RIGHT quit
MBTN_MID quit
WHEEL_UP quit
WHEEL_DOWN quit
SPACE quit
ENTER quit
ESC quit
q quit
EOF

# 4. Create Starter Script
cat <<EOF > "$SCRIPT_START"
#!/bin/bash
# Block if agent is running
if pgrep -f "$BLOCK_PROCESS" > /dev/null; then exit 0; fi

# Cleanup just in case
killall -q -9 mpv

# Launch with custom inputs
find "$IMAGES_DIR" -type f | grep -v "$EXCLUDE_KEYWORD" | mpv --playlist=- \\
    --vo=gpu --gpu-context=wayland \\
    --fs \\
    --no-osc \\
    --input-conf="$INPUT_CONF" \\
    --image-display-duration=5 \\
    --loop-playlist \\
    --shuffle \\
    --stop-screensaver=no \\
    > /dev/null 2>&1
EOF
chmod +x "$SCRIPT_START"

# 5. Create Killer Script
cat <<EOF > "$SCRIPT_KILL"
#!/bin/bash
killall -q -9 mpv
EOF
chmod +x "$SCRIPT_KILL"

# 6. Create Watcher Script
cat <<EOF > "$SCRIPT_WATCH"
#!/bin/bash
killall -q -9 swayidle
/usr/bin/swayidle -w \\
    timeout $TIMEOUT_SECONDS '$SCRIPT_START' \\
    resume '$SCRIPT_KILL' \\
    before-sleep '$SCRIPT_KILL'
EOF
chmod +x "$SCRIPT_WATCH"

# 7. Update Autostart
mkdir -p "$AUTOSTART_DIR"
cat <<EOF > "$DESKTOP_FILE"
[Desktop Entry]
Type=Application
Name=BMO Screensaver
Comment=Launch swayidle for faces
Exec=$SCRIPT_WATCH
Terminal=false
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
EOF

echo ""
echo "🎉 Setup Complete!"
echo "Please reboot your Pi to apply changes."

How to change the timeout later
If 60 seconds is too fast (or too slow), you don't need to reinstall. Just edit the watcher script directly:

  1. Open the file:
    nano ~/be-more-agent/start-idle-watcher.sh

  2. Find the number after timeout (default is 60) and change it to whatever you like (in seconds).

  3. Save, exit, and reboot.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions