Posted on
Artificial Intelligence

Artificial Intelligence Desktop Projects

Author
  • User
    linuxbash
    Posts by this author
    Posts by this author

4 Artificial Intelligence Desktop Projects You Can Build on Linux with Bash

What if your Linux desktop could summarize whatever’s on your clipboard, explain a gnarly shell one‑liner, or take voice dictation—all locally, without sending your data to the cloud? With today’s open models and a bit of Bash, you can.

This article shows you how to stand up practical, private AI helpers on your Linux desktop using simple shell scripts and open tools. You’ll get installation notes for apt, dnf, and zypper, runnable code, and real-world workflows you can use today.

Why AI on the Linux desktop?

  • Privacy and control: Run models locally; keep sensitive data off third-party servers.

  • Speed and ergonomics: Trigger AI from hotkeys, rofi/wofi, or your terminal. No context-switching.

  • Glue-friendly: Bash + curl + jq + notify-send turn AI into composable Unixy tools.

  • Hardware-friendly: Models like Llama 3 run on CPUs/GPUs; Whisper handles speech-to-text locally.

Prerequisites

Install the common packages you’ll use across projects.

  • Debian/Ubuntu (apt):

    sudo apt update
    sudo apt install -y curl jq rofi xclip wl-clipboard ffmpeg libnotify-bin python3 python3-pip git
    
  • Fedora/RHEL/CentOS Stream (dnf):

    sudo dnf install -y curl jq rofi xclip wl-clipboard ffmpeg libnotify python3 python3-pip git
    
  • openSUSE Leap/Tumbleweed (zypper):

    sudo zypper install -y curl jq rofi xclip wl-clipboard ffmpeg libnotify-tools python3 python3-pip git
    

Install a local LLM runtime (Ollama) and at least one model (e.g., Llama 3):

curl -fsSL https://ollama.com/install.sh | sh
ollama pull llama3
  • If the service isn’t started automatically, run: ollama serve or as a user service (if provided by your install): systemctl --user start ollama

Install Whisper (for speech-to-text):

python3 -m pip install --user openai-whisper

Note: The first run of a model (Llama or Whisper) will download weights; this can be a few GB. CPU works; a GPU speeds things up.


Project 1: Rofi-powered “Ask AI” launcher (local, fast)

Type a question, get an answer, copy it to your clipboard, and see a desktop notification. Great for quick lookups and snippets.

Create ~/.local/bin/ai-ask and make it executable:

mkdir -p ~/.local/bin
cat > ~/.local/bin/ai-ask << 'EOF'
#!/usr/bin/env bash
set -euo pipefail

MODEL="${MODEL:-llama3}"
URL="${OLLAMA_URL:-http://localhost:11434}"

# Prompt via rofi (fallback to stdin if rofi isn't available)
if command -v rofi >/dev/null 2>&1; then
  PROMPT="$(rofi -dmenu -p "Ask AI")" || exit 0
else
  read -rp "Ask AI: " PROMPT
fi

[ -z "${PROMPT:-}" ] && exit 0

payload="$(jq -nc --arg m "$MODEL" --arg p "$PROMPT" '{model:$m, prompt:$p, stream:false}')"
RESP="$(curl -s "$URL/api/generate" -d "$payload" | jq -r '.response')"

# Copy to clipboard (Wayland or X)
if command -v wl-copy >/dev/null 2>&1; then
  printf "%s" "$RESP" | wl-copy
elif command -v xclip >/dev/null 2>&1; then
  printf "%s" "$RESP" | xclip -selection clipboard
fi

# Notify
if command -v notify-send >/dev/null 2>&1; then
  notify-send "AI Answer" "$(printf "%s" "$RESP" | head -c 500)"
fi

printf "\n---\n%s\n" "$RESP"
EOF

chmod +x ~/.local/bin/ai-ask

Usage:

  • Run ai-ask from your terminal or bind it to a hotkey in your desktop environment.

  • Tip: Set MODEL=mistral or another model you’ve pulled with Ollama.

Real-world example:

  • Ask for a Bash one-liner to rename files, or a quick regex explanation.

Project 2: Voice dictation to clipboard (Whisper + ffmpeg)

Record a short voice note and turn it into text you can paste anywhere.

Create ~/.local/bin/ai-dictate and make it executable:

cat > ~/.local/bin/ai-dictate << 'EOF'
#!/usr/bin/env bash
set -euo pipefail

DURATION="${DURATION:-10}"   # seconds
WAV="/tmp/dictate.wav"

# Choose input: PulseAudio if available, else ALSA
if command -v pactl >/dev/null 2>&1; then
  INPUT=(-f pulse -i default)
else
  INPUT=(-f alsa -i default)
fi

# Record
ffmpeg -hide_banner -loglevel error -y -t "$DURATION" "${INPUT[@]}" -ac 1 -ar 16000 "$WAV"

# Transcribe with Whisper CLI (installed via pip as 'whisper')
whisper "$WAV" --model small --language en --fp16 False --output_format txt --output_dir /tmp >/dev/null

TXT="/tmp/$(basename "$WAV" .wav).txt"
[ -f "$TXT" ] || { echo "Transcription failed"; exit 1; }

TEXT="$(cat "$TXT")"

# Copy to clipboard
if command -v wl-copy >/dev/null 2>&1; then
  printf "%s" "$TEXT" | wl-copy
elif command -v xclip >/dev/null 2>&1; then
  printf "%s" "$TEXT" | xclip -selection clipboard
fi

# Notify
if command -v notify-send >/dev/null 2>&1; then
  notify-send "Dictation complete" "$(printf "%s" "$TEXT" | head -c 200)"
fi

printf "%s\n" "$TEXT"
EOF

chmod +x ~/.local/bin/ai-dictate

Usage:

  • Run ai-dictate and speak. After DURATION seconds, the text is in your clipboard and printed in the terminal.

  • Adjust DURATION=20 ai-dictate for longer notes.

  • Works on Wayland or X11; no cloud required.

Real-world example:

  • Dictate meeting notes or TODOs, then paste them into your editor or chat.

Project 3: Summarize your clipboard in seconds

Turn any selected text (article snippet, logs, man pages) into a concise summary.

Create ~/.local/bin/ai-summarize-clipboard and make it executable:

cat > ~/.local/bin/ai-summarize-clipboard << 'EOF'
#!/usr/bin/env bash
set -euo pipefail

MODEL="${MODEL:-llama3}"
URL="${OLLAMA_URL:-http://localhost:11434}"

# Read clipboard (Wayland or X)
if command -v wl-paste >/dev/null 2>&1; then
  CLIP="$(wl-paste)"
elif command -v xclip >/dev/null 2>&1; then
  CLIP="$(xclip -o -selection clipboard)"
else
  echo "No clipboard tool found (need wl-paste or xclip)." >&2
  exit 1
fi

[ -z "${CLIP// }" ] && { echo "Clipboard is empty."; exit 1; }

PROMPT="Summarize the following text in 5 bullet points with clear, concrete phrasing. Keep it under 120 words.\n\n---\n$CLIP"

payload="$(jq -nc --arg m "$MODEL" --arg p "$PROMPT" '{model:$m, prompt:$p, stream:false}')"
RESP="$(curl -s "$URL/api/generate" -d "$payload" | jq -r '.response')"

# Copy and notify
if command -v wl-copy >/dev/null 2>&1; then
  printf "%s" "$RESP" | wl-copy
elif command -v xclip >/dev/null 2>&1; then
  printf "%s" "$RESP" | xclip -selection clipboard
fi

if command -v notify-send >/dev/null 2>&1; then
  notify-send "Clipboard summary ready" "$(printf "%s" "$RESP" | head -c 300)"
fi

printf "%s\n" "$RESP"
EOF

chmod +x ~/.local/bin/ai-summarize-clipboard

Usage:

  • Copy any text, then run ai-summarize-clipboard. Paste the result wherever you need it.

Real-world example:

  • Skim long GitHub issues or log dumps before diving in.

Project 4: Explain any shell command (right from your terminal)

Ever stare at a scary find | xargs | sed chain and hope for the best? Get a safe, structured explanation first.

Add this function to your ~/.bashrc (or ~/.zshrc) and reload your shell:

explain() {
  if [ $# -eq 0 ]; then
    echo "Usage: explain <command>"; return 1
  fi

  local CMD MODEL URL PROMPT payload RESP
  CMD="$*"
  MODEL="${MODEL:-llama3}"
  URL="${OLLAMA_URL:-http://localhost:11434}"

  PROMPT=$'You are a Linux shell expert. Explain the following command step-by-step, including:\n- What each part does\n- Potential dangers (data loss, network calls, rm -rf, sudo)\n- A safer alternative if risky\n\nCommand:\n'"$CMD"

  payload="$(jq -nc --arg m "$MODEL" --arg p "$PROMPT" '{model:$m, prompt:$p, stream:false}')"
  RESP="$(curl -s "$URL/api/generate" -d "$payload" | jq -r '.response')"

  printf "%s\n" "$RESP"
}

Usage:

  • explain 'find . -type f -mtime -1 -print0 | xargs -0 rm'

Real-world example:

  • Review a command from a blog or a colleague for safety before you run it.

Performance and model tips

  • Use smaller models for snappy responses: llama3:8b, mistral, or phi3.

  • For Whisper, try --model medium for better accuracy, or --model tiny for speed.

  • GPU acceleration (CUDA/ROCm/Metal) can give huge speedups if supported by your setup.

Troubleshooting

  • Ollama not responding:

    • Ensure it’s running: pgrep ollama or curl -s localhost:11434/api/tags
    • Start it: ollama serve
  • Clipboard tools:

    • Wayland: wl-clipboard provides wl-copy/wl-paste
    • X11: xclip
  • ffmpeg on Fedora:

    • Newer Fedora includes ffmpeg in the default repos as ffmpeg. If unavailable, enable RPM Fusion.

Wrap-up and next steps

You now have four practical AI utilities—ask, dictate, summarize, and explain—running locally on your Linux desktop with a handful of shell scripts. They’re private, scriptable, and easy to extend.

Where to go from here:

  • Bind scripts to hotkeys in your WM/DE.

  • Turn them into systemd user services for background automation.

  • Add prompt presets (proofread, translate, code review) to ai-ask.

  • Swap models in and out with MODEL=... environment variables.

Build your own desktop AI toolkit—one small Bash script at a time.