pub / sguard

Suspend Guard for the PhoneShell "Phosh"
git clone https://src.jayvii.de/pub/sguard.git
Home | Log | Files | Exports | Refs | README | RSS

commit a49ebe3d8225ff999d7a8b0935e0c872aa93ca4e
parent 270174b99c4647c910016cced515760190b6705d
Author: JayVii <jayvii[AT]noreply[DOT]localhost>
Date:   Thu, 17 Sep 2020 22:12:17 +0200

Initial alarm script

Diffstat:
Aalarm.sh | 50++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+), 0 deletions(-)

diff --git a/alarm.sh b/alarm.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +# defaults ------------------------------------------------------------- +zzzaction=0 + +# checks --------------------------------------------------------------- +# has alarmtone been chosen yet? +if [ ! -f ~/.alarmtone ]; then + # assuming some tone... + ln -s /usr/share/sounds/freedesktop/stereo/phone-incoming-call.oga \ + ~/.alarmtone +fi + +# Function: ring alarm ------------------------------------------------- +function alarm_ring { + # play ringtone + mpv --loop-file=inf ~/.alarmtone & + # noting down PID of alarm process + alarmpid=$! +} + +# Function: ask user what to do ---------------------------------------- +function zzzorawake { + yad --title="Alarm!" \ + --text="$(date +%H:%M)" \ + --button="Snooze..." \ + --button="Stop!" + zzzaction=$? +} + +# initial run ---------------------------------------------------------- +# ringing alarm... +alarm_ring +# asking user what to do +zzzorawake + +# the famous snooze loop ----------------------------------------------- +# if snooze was chosen, wait for another 5 minutes before ringing +while [ $zzzaction == 0 ]; do + kill $alarmpid + sleep 5 # 5 minutes + alarm_ring # ring alarm + zzzorawake # ask user what to do +done + +# if you finally get up, we can stop the misery ------------------------ +kill $alarmpid + +# EOF alarm.sh +\ No newline at end of file