<commit_before>#!/bin/bash

nth_or() {
    local i
    local line
    local jobdone
    i=$1
    jobdone=0
    while [ "$i" != 1 ]
    do
        if read line
        then
            i=$(($i-1))
        else
            i=1
            echo $2
            jobdone=1
        fi
    done
    if [ $jobdone = 0 ]
    then
        if read line
        then
            echo $line
        else
            echo $2
        fi
    fi
}

username=$(whoami)
while true
do
    consumed=$(cat consumed/$username)
    weekday=$(date +%u)
    allowed=$(cat limits/$username|nth_or $weekday 0)
    remaining=$(($allowed - $consumed))
    if [ $(($remaining < 5)) = 1 ]
    then
        notify-send "remaining $remaining minutes"
    fi
    sleep 60
done<commit_msg>add a parameter to limitime-notify to specify when to alert the user<commit_after>#!/bin/bash

nth_or() {
    local i
    local line
    local jobdone
    i=$1
    jobdone=0
    while [ "$i" != 1 ]
    do
        if read line
        then
            i=$(($i-1))
        else
            i=1
            echo $2
            jobdone=1
        fi
    done
    if [ $jobdone = 0 ]
    then
        if read line
        then
            echo $line
        else
            echo $2
        fi
    fi
}

critical=$1
if [ -z "$critical" ]
then
    critical=5
fi
username=$(whoami)
while true
do
    consumed=$(cat consumed/$username)
    weekday=$(date +%u)
    allowed=$(cat limits/$username|nth_or $weekday 9999) # 9999 is infinity
    remaining=$(($allowed - $consumed))
    if [ $(($remaining < $critical)) = 1 ]
    then
        notify-send "Remaining $remaining minutes"
    fi
    sleep 60
done
{'fraction_non_alphanumeric': 0.11057108140947752, 'fraction_numerical': 0.02187120291616039, 'mean_word_length': 1.5377503852080123, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4966768', 'n_tokens_mistral': 552, 'n_tokens_neox': 529, 'n_words': 156}