30 lines
972 B
Bash
30 lines
972 B
Bash
DURATION=20 # How long it takes to progress the bar fully
|
|
STEPS=100 # In how many steps to progress (> 0)
|
|
|
|
# Trick to fake decimals
|
|
EXP=3
|
|
interval_ms="$(( "${DURATION}" * ( 10 ** "${EXP}" ) / "${STEPS}" ))"
|
|
padded_interval_ms="$(printf "%0${EXP}d" "${interval_ms}")"
|
|
interval_s="${padded_interval_ms:0:-${EXP}}.${padded_interval_ms:-${EXP}}"
|
|
|
|
end_time="$(( "$( date '+%s' )" + "${DURATION}" + 1 ))"
|
|
|
|
# notify-send args
|
|
replace_id="${end_time}"
|
|
expire_time="$(( "${interval_ms}" + 1 ))" # To avoid flickering
|
|
|
|
counter=0
|
|
while [[ "${end_time}" -gt "$( date '+%s' )" ]]; do
|
|
# Remap to [0, 100]
|
|
remaining_part="$(( ("${STEPS}" - "${counter}") * 100 / "${STEPS}" ))"
|
|
|
|
notify-send \
|
|
'Look away from your screen :)' 'RemEYEnder' \
|
|
--hint="int:value:${remaining_part}" \
|
|
--category='sysinfo' \
|
|
--replace-id="${replace_id}" \
|
|
--expire-time="${expire_time}"
|
|
|
|
counter="$(( "${counter}" + 1 ))"
|
|
sleep "${interval_s}"
|
|
done
|