#!/usr/bin/env bash
# In the name of Allah, the most Gracious, the most Merciful.
#
#  ▓▓▓▓▓▓▓▓▓▓ 
# ░▓ Author ▓ Abdullah <https://abdullah.today> 
# ░▓▓▓▓▓▓▓▓▓▓ 
# ░░░░░░░░░░ 
# 
# A script to wake system on a time specified on command line. 

USAGE="
USAGE:\n
\n
$0 time tune\n
\n
Example:\n
\n
  $0 'today 13:00' /home/ak/Documents/somefile.mp3\n
  $0 stop
"

[[ $# -eq 0 ]] && { echo ""; echo -e $USAGE; echo ""; exit 1; }

alarm_time="$1"
alarm_sound="$2"
[[ -z $alarm_sound ]] && alarm_sound="$HOME/.local/share/misc/Kursi.mp3"


alarm_start ()
{
  sudo rtcwake -d rtc0 -m mem -t $(date +%s -d "$alarm_time") -v && mpv --no-resume-playback --loop-file $alarm_sound 
}

alarm_start
