feat(remEYEnder): Add progress bar
This commit is contained in:
parent
69283dfea5
commit
747f5d3e69
3 changed files with 35 additions and 6 deletions
30
scripts/remEYEnder.sh
Normal file
30
scripts/remEYEnder.sh
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue