]> git.donarmstrong.com Git - bin.git/blob - alarm
add reset usb bus command
[bin.git] / alarm
1 #!/bin/bash
2 SLEEP=$1;
3 if [ -z "$SLEEP" ]; then
4     SLEEP="0.1s";
5 fi;
6 MPG321DEVICE="-o pulse"
7 MUSIC=''
8 MPG321OPTS="-n 300"
9 cmd_exists () {
10     if which "$1" >/dev/null 2>&1; then
11         return 0;
12     else
13         return 1;
14     fi;
15 }
16
17 message() {
18     if cmd_exists "notify-send"; then
19         notify-send -t 4000 Alarm "your $SLEEP timer has expired";
20     fi;
21 }
22
23 for plantasia in ~/media/{audio,music}/mort_garson/plantasia/01_plantasia.mp3 \
24                  ~/media/jack2/Plantasia/01\ Plantasia.mp3; do
25                      
26     if [ -e "${plantasia}" ]; then
27         MUSIC="${plantasia}"
28         MPG321OPTS="-k 15 -n 209";
29     fi;
30 done;
31 if [ -z "$MUSIC" ]; then
32     if [ -d ~/media/music ]; then
33             MUSIC="$(find ~/media/music/ \( -type f -o -xtype f \) -iname '*.mp3' -print -quit)"
34     fi;
35     if [ -d ~/media/jack ]; then
36             MUSIC="$(find ~/media/jack/ \( -type f -o -xtype f \) -iname '*.mp3' -print -quit)"
37     fi;
38 fi;
39 (sleep $SLEEP; message; mpg321 $MPG321DEVICE $MPG321OPTS "$MUSIC" >/dev/null 2>&1 ) &