Added a color temparature script
This commit is contained in:
parent
75b2b6e0b2
commit
720ddd3d99
61
glue/src/display-temperature
Executable file
61
glue/src/display-temperature
Executable file
@ -0,0 +1,61 @@
|
||||
#!/bin/sh
|
||||
|
||||
name=`basename "$0"`
|
||||
|
||||
isInstalled() {
|
||||
type "$1" > /dev/null
|
||||
}
|
||||
|
||||
mustHaveInstalled() {
|
||||
if ! isInstalled "$1"; then
|
||||
echo "$name: $1 is not installed" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
usage() {
|
||||
echo "Usage: $name day | night | daemon" >&2
|
||||
exit 2
|
||||
}
|
||||
|
||||
dayTemp=6500
|
||||
nightTemp=4000
|
||||
sunset=17
|
||||
sunrise=7
|
||||
|
||||
if isInstalled xsct
|
||||
then SCT=xsct
|
||||
elif isInstalled sct
|
||||
then SCT=sct
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
"day" | "night" | "daemon")
|
||||
mode="$1"
|
||||
shift 1
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
|
||||
[ "$#" -gt 0 ] && usage
|
||||
|
||||
case "$mode" in
|
||||
"day")
|
||||
$SCT "$dayTemp"
|
||||
;;
|
||||
"night")
|
||||
$SCT "$nightTemp"
|
||||
;;
|
||||
"daemon")
|
||||
while
|
||||
hour=`date +%H`
|
||||
if [ "$hour" -gt "$sunset" ] || [ "$hour" -lt "$sunrise" ]
|
||||
then temp="$nightTemp"
|
||||
else temp="$dayTemp"
|
||||
fi
|
||||
$SCT "$temp"
|
||||
do sleep 4; done
|
||||
;;
|
||||
esac
|
Loading…
Reference in New Issue
Block a user