ScriptsApr 6, 2026·1 min read

微信沉迷提醒脚本

macOS

Agent ready

Safe staging for this asset

This asset is staged first. The copied prompt tells the agent to inspect the staged files and ask before activating scripts, MCP config, or global config.

Stage only · 17/100Policy: stage
Agent surface
Any MCP/CLI agent
Kind
Script
Install
Stage only
Trust
Trust: Established
Entrypoint
wechat-reminder.sh
Safe staging command
npx -y tokrepo@latest install f64b62db-49f8-4e21-8219-92ef2a9dc6a4 --target codex

Stages files first; activation requires review of the staged README and plan.

#!/bin/bash

微信沉迷提醒 - WeChat Usage Reminder

后台运行,检测微信连续使用时间,超时弹通知提醒

===== 可调参数 =====

CHECK_INTERVAL=30 # 每 30 秒检查一次 REMIND_AFTER=600 # 连续用微信 10 分钟后开始提醒 REMIND_EVERY=300 # 之后每 5 分钟再提醒一次

====================

wechat_seconds=0 reminded=false

notify() { osascript -e "display notification "$1" with title "微信沉迷提醒 ⏰" sound name "Glass"" }

echo "🔍 微信沉迷提醒已启动" echo " 连续使用 $((REMIND_AFTER / 60)) 分钟后提醒,之后每 $((REMIND_EVERY / 60)) 分钟提醒一次" echo " 按 Ctrl+C 停止"

while true; do front_app=$(osascript -e 'tell application "System Events" to get name of first application process whose frontmost is true' 2>/dev/null)

if [[ "$front_app" == "WeChat" ]]; then
    wechat_seconds=$((wechat_seconds + CHECK_INTERVAL))
    minutes=$((wechat_seconds / 60))

    if [[ $wechat_seconds -ge $REMIND_AFTER ]]; then
        seconds_past=$((wechat_seconds - REMIND_AFTER))
        if [[ $seconds_past -eq 0 ]] || [[ $((seconds_past % REMIND_EVERY)) -eq 0 ]]; then
            notify "你已经刷了 ${minutes} 分钟微信了,休息一下吧!"
            echo "⚠️  已提醒:连续使用微信 ${minutes} 分钟"
        fi
    fi
else
    # 离开微信了,如果之前超过了提醒阈值,报告一下
    if [[ $wechat_seconds -ge $REMIND_AFTER ]]; then
        minutes=$((wechat_seconds / 60))
        notify "本次微信使用共 ${minutes} 分钟,已离开 👍"
        echo "✅ 离开微信,本次使用 ${minutes} 分钟"
    fi
    wechat_seconds=0
fi

sleep $CHECK_INTERVAL

done

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets