Skip to content

Instantly share code, notes, and snippets.

@qbit
Created February 4, 2017 00:57
Show Gist options
  • Select an option

  • Save qbit/922d823c6ed412ad2836168f408dc6d0 to your computer and use it in GitHub Desktop.

Select an option

Save qbit/922d823c6ed412ad2836168f408dc6d0 to your computer and use it in GitHub Desktop.
Shell script daemon for sct
#!/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