diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2016-11-16 19:21:51 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2016-11-16 19:21:51 -0700 |
commit | 2864b660ec78df99cb05ad9ecc04747e88c64b76 (patch) | |
tree | 90188cacbe6404516a50424e9ef47d107e911740 | |
parent | 4ecc67e52eaf5d98e08bd4f3c95565136988991e (diff) | |
download | dotfiles-2864b660ec78df99cb05ad9ecc04747e88c64b76.tar.gz |
simple bedtime script
-rwxr-xr-x | bin/bedtime | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/bin/bedtime b/bin/bedtime new file mode 100755 index 00000000..6b6d2f51 --- /dev/null +++ b/bin/bedtime @@ -0,0 +1,18 @@ +#!/bin/bash + +. $HOME/.shenv + +# someday, make this work instead: +# <http://joeyh.name/blog/entry/a_programmable_alarm_clock_using_systemd/> + +(($EUID == 0)) || exec sudo "$0" "$@" + +WHEN="${1:-tomorrow 6am}" +CMD="/home/spwhitton/bin/goodmorning" + +when=$(date +%s -d "$WHEN") +echo $when + +loginctl lock-sessions +systemd-inhibit --what=handle-lid-switch --why=goodmorning sh -c \ + "rtcwake -m mem -t $when && /bin/su spwhitton -c $CMD" |