blob: cfe57f2600ec2fb7764e5bfca9c5d743310b684f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#!/bin/sh
# ttym on_done -- runs when a countdown reaches zero.
#
# $1 mode always "countdown" -- a stopwatch never completes
# $2 seconds the full duration that elapsed
# $3 comment the -c text, or an empty string
#
# Nothing here duplicates the notify patch: if your build has it, the
# desktop notification and sound have already fired by the time this
# runs. Use this for what the binary does not do.
#
# timer waits for this before the completion bell and the alert loop, so
# background anything slow with &.
mode=$1 seconds=$2 comment=$3
# --- session record ------------------------------------------------------
state=${XDG_STATE_HOME:-$HOME/.local/state}/ttym
if mkdir -p "$state" 2>/dev/null; then
printf '%s\tDONE\t%s\t%s\t%s\n' \
"$(date +%Y-%m-%dT%H:%M:%S)" "$mode" "$seconds" "$comment" \
>> "$state/sessions.tsv"
fi
# --- leave focus mode ----------------------------------------------------
# Note the ordering: the notify patch emits its completion popup *before*
# this hook runs, so with dunst paused that popup is queued and appears
# the moment the next line unpauses. Delayed, not lost.
command -v dunstctl > /dev/null 2>&1 && dunstctl set-paused false
command -v playerctl > /dev/null 2>&1 && playerctl play 2>/dev/null
command -v mpc > /dev/null 2>&1 && mpc -q play 2>/dev/null
# --- timewarrior ---------------------------------------------------------
# command -v timew > /dev/null 2>&1 && timew stop > /dev/null 2>&1
exit 0
|