]> git.donarmstrong.com Git - bin.git/blobdiff - alarm
add reset usb bus command
[bin.git] / alarm
diff --git a/alarm b/alarm
index 07a5873cc02c677c0c350cf2f199388b54b464b8..4b9639c92580c38099099441d9c2f953720450e3 100755 (executable)
--- a/alarm
+++ b/alarm
@@ -1,6 +1,39 @@
-#!/bin/sh
+#!/bin/bash
 SLEEP=$1;
 if [ -z "$SLEEP" ]; then
-    SLEEP="15m";
+    SLEEP="0.1s";
 fi;
-(sleep $SLEEP; mpg123 -k 15 -n 224 '/home/don/media/jack/Plantasia/01 Plantasia.mp3' 2&>1 >/dev/null) &
+MPG321DEVICE="-o pulse"
+MUSIC=''
+MPG321OPTS="-n 300"
+cmd_exists () {
+    if which "$1" >/dev/null 2>&1; then
+        return 0;
+    else
+        return 1;
+    fi;
+}
+
+message() {
+    if cmd_exists "notify-send"; then
+        notify-send -t 4000 Alarm "your $SLEEP timer has expired";
+    fi;
+}
+
+for plantasia in ~/media/{audio,music}/mort_garson/plantasia/01_plantasia.mp3 \
+                 ~/media/jack2/Plantasia/01\ Plantasia.mp3; do
+                     
+    if [ -e "${plantasia}" ]; then
+        MUSIC="${plantasia}"
+        MPG321OPTS="-k 15 -n 209";
+    fi;
+done;
+if [ -z "$MUSIC" ]; then
+    if [ -d ~/media/music ]; then
+           MUSIC="$(find ~/media/music/ \( -type f -o -xtype f \) -iname '*.mp3' -print -quit)"
+    fi;
+    if [ -d ~/media/jack ]; then
+           MUSIC="$(find ~/media/jack/ \( -type f -o -xtype f \) -iname '*.mp3' -print -quit)"
+    fi;
+fi;
+(sleep $SLEEP; message; mpg321 $MPG321DEVICE $MPG321OPTS "$MUSIC" >/dev/null 2>&1 ) &