2014-08-01 17:15:35 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
## A bit of helper functions...
|
|
|
|
# Check which type of init system we're running on
|
2017-04-11 09:28:01 +00:00
|
|
|
if [ -d /etc/upstart ]; then
|
|
|
|
export INIT_TYPE="upstart"
|
|
|
|
# We'll need that for logging
|
|
|
|
# shellcheck disable=SC1091
|
|
|
|
[ -f /etc/upstart/functions ] && . /etc/upstart/functions
|
2014-08-01 17:15:35 +00:00
|
|
|
else
|
2017-04-11 09:28:01 +00:00
|
|
|
export INIT_TYPE="sysv"
|
|
|
|
# We'll need that for logging
|
|
|
|
# shellcheck disable=SC1091
|
|
|
|
[ -f /etc/rc.d/functions ] && . /etc/rc.d/functions
|
2014-08-01 17:15:35 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Adapted from libkh[5]
|
2019-07-09 17:38:32 +00:00
|
|
|
## Check if we have an FBInk binary available somewhere...
|
|
|
|
# Default to something that won't horribly blow up...
|
|
|
|
FBINK_BIN="true"
|
2020-01-11 03:05:14 +00:00
|
|
|
for my_dir in /var/tmp /mnt/us/koreader /mnt/us/libkh/bin /mnt/us/linkss/bin /mnt/us/linkfonts/bin /mnt/us/usbnet/bin; do
|
|
|
|
my_fbink="${my_dir}/fbink"
|
2019-07-09 17:38:32 +00:00
|
|
|
if [ -x "${my_fbink}" ]; then
|
|
|
|
FBINK_BIN="${my_fbink}"
|
|
|
|
# Got it!
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
has_fbink() {
|
|
|
|
# Because the fallback is the "true" binary/shell built-in ;).
|
|
|
|
if [ "${FBINK_BIN}" != "true" ]; then
|
|
|
|
# Got it!
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# If we got this far, we don't have fbink installed
|
|
|
|
return 1
|
|
|
|
}
|
2018-09-05 23:35:48 +00:00
|
|
|
|
2019-12-31 16:07:33 +00:00
|
|
|
# NOTE: Yeah, the name becomes a bit of a lie now that we're (hopefully) exclusively using FBInk ;p.
|
2017-04-11 09:28:01 +00:00
|
|
|
eips_print_bottom_centered() {
|
|
|
|
# We need at least two args
|
|
|
|
if [ $# -lt 2 ]; then
|
|
|
|
echo "not enough arguments passed to eips_print_bottom ($# while we need at least 2)"
|
|
|
|
return
|
|
|
|
fi
|
2014-08-01 17:15:35 +00:00
|
|
|
|
2017-04-11 09:28:01 +00:00
|
|
|
kh_eips_string="${1}"
|
|
|
|
kh_eips_y_shift_up="${2}"
|
2014-08-01 17:15:35 +00:00
|
|
|
|
2018-09-05 23:35:48 +00:00
|
|
|
# Unlike eips, we need at least a single space to even try to print something ;).
|
|
|
|
if [ "${kh_eips_string}" = "" ]; then
|
|
|
|
kh_eips_string=" "
|
|
|
|
fi
|
2014-08-01 17:15:35 +00:00
|
|
|
|
2017-04-11 09:28:01 +00:00
|
|
|
# Sleep a tiny bit to workaround the logic in the 'new' (K4+) eInk controllers that tries to bundle updates,
|
|
|
|
# otherwise it may drop part of our messages because of other screen updates from KUAL...
|
|
|
|
# Unless we really don't want to sleep, for special cases...
|
2019-07-09 17:38:32 +00:00
|
|
|
if [ -z "${EIPS_NO_SLEEP}" ]; then
|
2017-04-11 09:28:01 +00:00
|
|
|
usleep 150000 # 150ms
|
|
|
|
fi
|
2014-08-01 17:15:35 +00:00
|
|
|
|
2018-09-05 23:35:48 +00:00
|
|
|
# NOTE: FBInk will handle the padding. FBInk's default font is square, not tall like eips,
|
|
|
|
# so we compensate by tweaking the baseline ;). This matches the baseline we use on Kobo, too.
|
2019-07-09 17:38:32 +00:00
|
|
|
if has_fbink; then
|
|
|
|
${FBINK_BIN} -qpm -y $((-4 - kh_eips_y_shift_up)) "${kh_eips_string}"
|
|
|
|
else
|
|
|
|
# Crappy fallback
|
|
|
|
eips 0 0 "${kh_eips_string}" >/dev/null
|
|
|
|
fi
|
2014-08-01 17:15:35 +00:00
|
|
|
}
|