Created
April 11, 2021 18:05
-
-
Save lexszero/b5f738653f11f320147ad07590ee817e to your computer and use it in GitHub Desktop.
A script to annoy the user with sounds and notifications (like `setTimeout()`, but for humans)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euo pipefail | |
export XDG_RUNTIME_DIR=/run/user/1000 | |
readonly SOUND_DIR="/home/lexs/stuff" | |
eval "export $(egrep -z DBUS_SESSION_BUS_ADDRESS /proc/$(pgrep -u $LOGNAME dunst)/environ)" | |
echo "DBUS_SESSION_BUS_ADDRESS: $DBUS_SESSION_BUS_ADDRESS" | |
usage() { | |
cat <<EOF | |
Usage: $0 <action> [args..] | |
Actions: | |
periodic supposed to be run hourly from cron, just to ping me | |
once <text> show notification with <text>, say current time and <text> | |
at <time> <text> run "once <text>" at specified time | |
EOF | |
} | |
play_sound() { | |
local audiofile="${SOUND_DIR}/alarm_${1}.mp3" | |
local inhibit_flag="/tmp/alarm_inhibit_${1}" | |
if [[ -f "$inhibit_flag" ]]; then | |
return 0 | |
fi | |
mpv "$audiofile" >/dev/null 2>&1 | |
} | |
say() { | |
padsp espeak "$*" | |
} | |
say_time() { | |
say "It's $(date +"%H:%M"), my dudes" | |
} | |
cmd="$1" | |
shift | |
case "$cmd" in | |
periodic) | |
notify-send "⌚️ WAZZUP ⌚️" | |
say_time | |
play_sound periodic | |
;; | |
once) | |
notify-send "⭐️ ALARM ⭐️" "$*" | |
play_sound single | |
say_time | |
sleep 0.5 | |
say "$*" | |
;; | |
at) | |
when="$1" | |
shift | |
echo "$HOME/bin/annoy_me once $* >/dev/null 2>&1" | at "$when" | |
;; | |
*) | |
usage | |
exit 1 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment