main
 1#!/usr/bin/env bash
 2#
 3# check-mu-lock.sh - Check if mu database is locked
 4#
 5# Returns:
 6#   0 - Database is NOT locked (safe to run mu index)
 7#   1 - Database IS locked (mu server is running)
 8#   2 - Error checking lock status
 9#
10# Usage:
11#   if check-mu-lock.sh; then
12#       mu index
13#   else
14#       echo "mu4e is running, skipping index"
15#   fi
16
17set -euo pipefail
18
19# Check if mu server is running
20if pgrep -u "$UID" mu > /dev/null 2>&1; then
21    # mu process found - database is locked
22    exit 1
23fi
24
25# No mu process running - database is unlocked
26exit 0