aboutsummaryrefslogtreecommitdiff
path: root/handlers/timer.zsh
blob: 483863a3320164b6737fe98b6061dd83bc300d65 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Copyright (C) 2024-2026 Maria Lisina
# Copyright (C) 2024-2026 Danil Lisin
# SPDX-License-Identifier: Apache-2.0

if ! mkdir "${cache}.lock"
then
    exit
fi

timer_ctime=$(strftime %s)
timer_mtime=$(< "${cache}.timer")

if [[ $((timer_ctime - timer_mtime)) -lt 5 ]]
then
    rmdir "${cache}.lock"
    exit
fi

source "${operators}/timer_unlock.zsh"
source "${operators}/timer_uncache.zsh"

strftime %s > "${cache}.timer"
rmdir "${cache}.lock"