Okay this was not the thing I have been talking about, but I needed a timer.
Table of Contents
─────────────────
1 Creating a timer program
1 Creating a timer program
══════════════════════════
So I need a way to make a program that can count down n seconds. or
minutes.
The not so pretty way to write this would be the hack
┌────
│ : sleep-1 s" sleep 1" system ;
│
└────
This is just to have the ability to sleep, could not find anything in
pure forth to make the program wait for a single second.
┌────
│ : minutes 60 * ;
│ : minute minutes ;
│
│ : wait 0 do sleep-1 I . page loop ;
│
└────
With this defined I want to have something happen upon completion of
the timer, for instance a video playing. Just to be sure I will
notice. So the file can be whatever is at the path you define
┌────
│ : play-alert s" mpv /home/kinslayer/yt/aeil.mkv" system ;
│
└────
Okay that is the file I have chosen. This does a call to the system
and s" defines a string and puts it on the stack, this is so that
system can execute the command. Now I just need to put this whole
thing together and have a countdown to 0 then play a video when the
countdown has finished.
┌────
│ : sleep-1 s" sleep 1" system ;
│
│ : play-alert s" mpv /home/kinslayer/yt/aeil.mkv" system ;
│
│ : countdown 0 do sleep-1 loop play-alert ;
│
└────
With this the small thing is complete. Combining all these words we
can have a waiting time of any number of minutes, just add whatever
seconds you want on top.
Now it is entirely possible to say
┌────
│ 3 minutes countdown
│
└────
and then in 3 minutes the specified video will start playing.