~demifiend/blueshift

da25826b7966ab350ebce4e3a6a003d7f8326f34 — Matthew Graybosch 7 months ago 99a2bc6 v1.1.0
bugfix and documentation update

blueshift wasn't handling nighttime calculation properly, but I realized it
wasn't necessary to calculate nighttime. If it's not day, it's gotta be night.

I'm also checking for an active X Window session using $DISPLAY.
2 files changed, 10 insertions(+), 7 deletions(-)

M README.md
M blueshift
M README.md => README.md +1 -1
@@ 71,7 71,7 @@ $ blueshift 0600 1800 6500 4500

## todo

* I really should verify that X11 is running as part of the initial diagnostics.
* DONE! ~~I really should verify that X11 is running as part of the initial diagnostics.~~
* Write a proper manual page
* Create a port for OpenBSD so it can be installed through the package mangler.


M blueshift => blueshift +9 -6
@@ 37,12 37,17 @@ if [ "${#}" -ne 4 ]; then
fi

# hey, we better see if sct is installed...

if ! [ -x "$(command -v sct)" ]; then
    printf "ERROR:\\tPlease install sct using your system's package mangler.\\n\\tOn OpenBSD use \"doas pkg_add -iv sct\". Thanks!\\n"
    exit 1
fi

# is the X server even running?
if [ -z "${DISPLAY}" ]; then
    printf "ERROR:\\tNo X Window session in progress.\\n"
    exit 1
fi    

# test argument validity.
if [ "${SUNRISE}" -lt 0 ] || [ "${SUNRISE}" -ge 2400 ]; then
    printf "ERROR:\\tSunrise time is an invalid value.\\n\\tPlease use a value between 0000 and 2359.\\n"


@@ 76,10 81,8 @@ fi
# let's check the time and set the color temperature now.
if [ "${CURRENT}" -ge "${SUNRISE}" ] && [ "${CURRENT}" -lt "${SUNSET}" ]; then
    sct "${DAYTIME_COLOR_TEMP}"
    exit 0
fi

if [ "${CURRENT}" -lt "${SUNRISE}" ] && [ "${CURRENT}" -ge "${SUNSET}" ]; then
else
    sct "${NIGHTTIME_COLOR_TEMP}"
    exit 0
fi

exit 0