2 files changed,
0 insertions(+),
112 deletions(-)
Author:
Oleksandr Smirnov
olexsmir@gmail.com
Committed at:
2026-02-06 19:57:31 +0200
Parent:
377c329
jump to
| D | bin/pomodoro |
| D | bin/time.sh |
D
bin/pomodoro
··· 1 -#!/usr/bin/bash 2 -# credits: https://github.com/gpanders/dotfiles/blob/master/.local/bin/pomodoro 3 - 4 -usage() { 5 - echo "Usage: $(basename "$0") [focus time] [short break] [long break]" 6 -} 7 - 8 -if [ "$1" = "-h" ]; then 9 - usage 10 - exit 0 11 -fi 12 - 13 -focus_time=${1:-25} 14 -short_break=${2:-5} 15 -long_break=${3:-15} 16 - 17 -# Ensure all arguments are numbers 18 -case $focus_time$short_break$long_break in 19 - *[!0-9]*) 20 - echo "Arguments must be positive integer numbers" >&2 21 - usage >&2 22 - exit 1 23 - ;; 24 -esac 25 - 26 -notify() { 27 - echo "$1" 28 - if command -v terminal-notifier >/dev/null 2>&1; then 29 - terminal-notifier -title 'Pomodoro' -message "$1" 30 - elif command -v notify-send >/dev/null 2>&1; then 31 - notify-send "$1" 32 - fi 33 -} 34 - 35 -countdown() { 36 - timer=$(($1 * 60)) 37 - while true; do 38 - minutes=$((timer / 60)) 39 - seconds=$((timer - 60*minutes)) 40 - printf '\e[0K\r' # Clear current line 41 - printf 'Remaining: %02d:%02d' "$minutes" "$seconds" 42 - 43 - [ $timer -eq 0 ] && break 44 - timer=$((timer - 1)) 45 - sleep 1 46 - done 47 - printf '\n' 48 -} 49 - 50 -while true; do 51 - notify "Focus for $focus_time minutes" 52 - countdown "$focus_time" 53 - 54 - notify "Take a short break for $short_break minutes (1/4)" 55 - countdown "$short_break" 56 - 57 - notify "Focus for $focus_time minutes" 58 - countdown "$focus_time" 59 - 60 - notify "Take a short break for $short_break minutes (2/4)" 61 - countdown "$short_break" 62 - 63 - notify "Focus for $focus_time minutes" 64 - countdown "$focus_time" 65 - 66 - notify "Take a short break for $short_break minutes (3/4)" 67 - countdown "$short_break" 68 - 69 - notify "Focus for $focus_time minutes" 70 - countdown "$focus_time" 71 - 72 - notify "Take a long break for $long_break minutes (4/4)" 73 - countdown "$long_break" 74 -done
D
bin/time.sh
··· 1 -#!/usr/bin/env bash 2 -set -euo pipefail 3 - 4 -CATEGORIES=( 5 - "stop" 6 - "programming" 7 - "notes" 8 - "chat" 9 - "chore" 10 - "study" 11 - "wasted" 12 -) 13 - 14 -_stop() { timew stop; } 15 - 16 -_status() { 17 - if current=$(timew get dom.active.tags 2>/dev/null); then 18 - echo "$current" 19 - else 20 - echo "none" 21 - fi 22 -} 23 - 24 -_select() { 25 - selected=$(printf "%s\n" "${CATEGORIES[@]}" | sk --margin 25% --color="bw" --reverse) 26 - [[ "$selected" == "" ]] && exit 1 27 - 28 - if [[ "$selected" == "stop" ]] 29 - then _stop 30 - else timew start "$selected" 31 - fi 32 -} 33 - 34 -case "${1:-}" in 35 - status) _status ;; 36 - stop) _stop ;; 37 - *) _select ;; 38 -esac