aboutsummaryrefslogtreecommitdiff
path: root/Scripts/.local/scripts
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2021-03-10 16:24:11 +0000
committerAryadev Chavali <aryadev@aryadevchavali.com>2021-03-10 16:24:11 +0000
commitf88f5bb640ae3634dffb28b6cfc6814d58c18560 (patch)
tree043fb87e8c86c372dc57118b43665b70995aac04 /Scripts/.local/scripts
parent8b6a9807f954bc373df5c11fdbdfe1792cacb5f4 (diff)
downloaddotfiles-f88f5bb640ae3634dffb28b6cfc6814d58c18560.tar.gz
dotfiles-f88f5bb640ae3634dffb28b6cfc6814d58c18560.tar.bz2
dotfiles-f88f5bb640ae3634dffb28b6cfc6814d58c18560.zip
(Scripts)+timer script to help with studying and stuff
This script acts as a library (to be symlinked/copied into your project) for interfacing with the 'espeak' and 'play' libraries in python. It also has a 'main' functionality where it acts a study timer with a 40/20 minute split of work to rest.
Diffstat (limited to 'Scripts/.local/scripts')
-rwxr-xr-xScripts/.local/scripts/timer32
1 files changed, 32 insertions, 0 deletions
diff --git a/Scripts/.local/scripts/timer b/Scripts/.local/scripts/timer
new file mode 100755
index 0000000..f425703
--- /dev/null
+++ b/Scripts/.local/scripts/timer
@@ -0,0 +1,32 @@
+#!/usr/bin/env python3
+from time import sleep
+from sys import argv
+from os import system
+
+def speak(text: str, volume=100, word_gap=20):
+ system(f'espeak -a {volume} -g {word_gap} -k 20 "{text}"')
+
+def beep():
+ system("play -q -n synth 0.1 sin 880")
+
+if __name__ == '__main__':
+ study_duration = 40
+ if (len(argv) > 1):
+ study_duration = int(argv[1])
+
+ gap_duration = 20
+ if (len(argv) > 2):
+ study_duration = int(argv[2])
+
+ speak(f"Starting timer with parameters study={study_duration} minutes and gap={gap_duration} minutes")
+
+ for i in range(1, study_duration + 1):
+ sleep(60)
+ if i % 10 == 0:
+ speak(f"{study_duration - i} minutes of study time left")
+
+ speak("You can take a break now!")
+ for i in range(1, gap_duration + 1):
+ sleep(60)
+ if i % 10 == 0:
+ speak(f"{gap_duration - i} minutes of gap time left")