-
-
Save qbit/922d823c6ed412ad2836168f408dc6d0 to your computer and use it in GitHub Desktop.
Shell script daemon for sct
This file contains hidden or 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/sh | |
| S=4500 | |
| INC=2 | |
| SCT=/usr/local/bin/sct | |
| DEBUG=false | |
| if [ ! -e "$SCT" ]; then | |
| echo "Please install sct!" | |
| exit 1; | |
| fi | |
| function dbg { | |
| if [ $DEBUG ]; then | |
| echo $1 | |
| fi | |
| } | |
| function setHM { | |
| H=$(date +"%H" | sed -e 's/^0//') | |
| M=$(date +"%M" | sed -e 's/^0//') | |
| HM=$((${H}*60 + ${M})) | |
| dbg "Current minute: ${HM}" | |
| } | |
| setHM | |
| if [ $HM -gt 720 ]; then | |
| for i in $(jot $((1440 - $HM))); do | |
| S=$((${S}+${INC})) | |
| done | |
| else | |
| for i in $(jot $HM); do | |
| S=$((${S}+${INC})) | |
| done | |
| fi | |
| while true; do | |
| setHM | |
| if [ $HM -gt 720 ]; then | |
| S=$((${S}-${INC})) | |
| dbg "Decrementing S: ${S}" | |
| else | |
| S=$((${S}+${INC})) | |
| dbg "Incrementing S: ${S}" | |
| fi | |
| $SCT $S | |
| sleep 60 | |
| done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment