Skip to content

Instantly share code, notes, and snippets.

@duydo
Created October 6, 2025 01:41
Show Gist options
  • Select an option

  • Save duydo/4c8a987c0c6bd3a5cee77e8a54ee54df to your computer and use it in GitHub Desktop.

Select an option

Save duydo/4c8a987c0c6bd3a5cee77e8a54ee54df to your computer and use it in GitHub Desktop.
Script: setup_activitywatch_hidden.sh on MacOS
#!/bin/bash
# ===============================================
# ActivityWatch hidden setup for macOS
# Author: ChatGPT (for Duy)
# ===============================================
set -e
APP_PATH="/Applications/ActivityWatch.app"
PLIST_PATH="$HOME/Library/LaunchAgents/com.activitywatch.daemon.plist"
INFO_PLIST="$APP_PATH/Contents/Info.plist"
echo "🔧 Setting up ActivityWatch background service..."
# 1️⃣ Check if app exists
if [ ! -d "$APP_PATH" ]; then
echo "❌ ActivityWatch.app not found in /Applications."
echo "Please install ActivityWatch first from https://activitywatch.net"
exit 1
fi
# 2️⃣ Add LSUIElement flag to hide Dock icon
echo "🫥 Hiding ActivityWatch Dock icon..."
sudo /usr/libexec/PlistBuddy -c "Add :LSUIElement bool true" "$INFO_PLIST" 2>/dev/null || \
sudo /usr/libexec/PlistBuddy -c "Set :LSUIElement true" "$INFO_PLIST"
sudo touch "$APP_PATH"
# 3️⃣ Create LaunchAgent
echo "⚙️ Creating LaunchAgent plist..."
mkdir -p "$HOME/Library/LaunchAgents"
cat > "$PLIST_PATH" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.activitywatch.daemon</string>
<key>ProgramArguments</key>
<array>
<string>$APP_PATH/Contents/MacOS/aw-qt</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>StandardOutPath</key>
<string>/tmp/activitywatch.log</string>
<key>StandardErrorPath</key>
<string>/tmp/activitywatch.err</string>
</dict>
</plist>
EOF
# 4️⃣ Load LaunchAgent
echo "🚀 Loading LaunchAgent..."
launchctl unload "$PLIST_PATH" 2>/dev/null || true
launchctl load "$PLIST_PATH"
# 5️⃣ Hide app from Finder
echo "🙈 Hiding app from Finder..."
sudo chflags hidden "$APP_PATH"
echo "✅ ActivityWatch setup complete!"
echo "It will now run silently in the background on startup."
echo "Check status with: launchctl list | grep activitywatch"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment