V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
爱意满满的作品展示区。
wukaige
0.1D

写了一个 waybar 模块: 478 呼吸法,分享一下

  •  
  •   wukaige · Nov 14, 2025 · 1901 views
    This topic created in 172 days ago, the information mentioned may be changed or developed.

    breath.sh:

    #!/usr/bin/env bash
    
    STATE_FILE="/tmp/breath_state_478"
    
    # 4s inhale, 7s hold, 8s exhale = 19 total frames
    # 每秒一帧
    
    frames=(
      # --- Inhale 4s (0~3)
      "󰪞 |INHALE"
      "󰪠 |INHALE"
      "󰪢 |INHALE"
      "󰪤 |INHALE"
    
      # --- Hold 7s (4~10)
      "󰪥 |HOLDON"
      "󰪥 |HOLDON"
      "󰪥 |HOLDON"
      "󰪥 |HOLDON"
      "󰪥 |HOLDON"
      "󰪥 |HOLDON"
      "󰪥 |HOLDON"
    
      # --- Exhale 8s (11~18)
      "󰪥 |EXHALE"
      "󰪤 |EXHALE"
      "󰪣 |EXHALE"
      "󰪢 |EXHALE"
      "󰪡 |EXHALE"
      "󰪠 |EXHALE"
      "󰪟 |EXHALE"
      "󰪞 |EXHALE"
      "󰪞 |EXHALE"
    )
    
    TOTAL=${#frames[@]}
    
    # Init state
    if [[ ! -f "$STATE_FILE" ]]; then
        echo 0 > "$STATE_FILE"
    fi
    
    index=$(cat "$STATE_FILE")
    
    # 输出当前帧
    current="${frames[$index]}"
    icon="${current%%|*}"
    text="${current##*|}"
    
    echo "$icon $text"
    
    # 下一个
    next=$(( (index + 1) % TOTAL ))
    echo "$next" > "$STATE_FILE"
    

    modules.json:

      "custom/breath": {
        "exec": "~/.config/waybar/scripts/breath.sh",
        "format": "{}",
        "interval": 1,
        "tooltip": false
      }
    

    TangMonkDance
        1
    TangMonkDance  
       Nov 14, 2025
    这是干嘛用的?
    wukaige
        2
    wukaige  
    OP
       Nov 16, 2025
    @TangMonkDance

    INHALE 状态持续 4s 后切换 HOLDON 状态持续 7s ,后切换 EXHALE 状态持续 8s ,跟着吸气,憋气,呼气。

    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2629 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 59ms · UTC 05:42 · PVG 13:42 · LAX 22:42 · JFK 01:42
    ♥ Do have faith in what you're doing.