#!/bin/bash

[[ -z "$3" ]] && volume=90 || volume="$3"

#if [[ "$(date "+%F" -d "$2")" = "$(date "+%F")" ]]
#then
#	set -- "$1" "tomorrow $2" "$3"
#fi

sleeptime=$(date -Iseconds -d "$1")
wakeuptime=$(date -Iseconds -d "$2")


#if [[ "$(whoami)" != "root" ]]
#then
#	echo "Ce script doit être exécuté en root" >&2
#	exit 1
#fi

echo $sleeptime
echo $wakeuptime

read

echo 0 off > /proc/acpi/ibm/led
pkill xscreensaver

termdown -f contessa -a "$sleeptime"
mocp -s
pkill vlc

termdown -f contessa -a "$wakeuptime"

#rtcwake -m mem -t $wakeuptime

amixer -q -D default sset Master "$volume%"

echo 0 on > /proc/acpi/ibm/led

pkill mpv
mpv --loop-file ${HOME}/Musique_old/Sons/girlswithguns.mp3
xscreensaver &
#mpv --loop-file /home/breizh/Musique/Radio_caroline.m3u