blob: 79e6f1338a0fe8df068480f6b577b53f29510dd2 [file] [log] [blame]
# Copyright 2021 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
description "Start Frecon"
author "chromeos-core-services@google.com"
start on started dbus
expect fork
respawn
pre-start script
# b/158282097: force reprobe since type-c to DP connectors
# seems not detected at boot
for f in /sys/class/drm/*/status; do
echo detect > "${f}"
done
sleep 1s
resolution="$(/bin/frecon-lite --print-resolution || echo 1000 1000)"
x_res="${resolution% *}"
y_res="${resolution#* }"
if [ "${x_res}" -le "${y_res}" ]; then
# for tablet mode, add 20px margin for left and right edge.
CANVAS_SIZE="$(( x_res - 40 ))"
else
CANVAS_SIZE="${y_res}"
fi
if [ "${CANVAS_SIZE}" -ge 1920 ]; then
FRECON_SCALING_FACTOR=2
CANVAS_SIZE="$(( CANVAS_SIZE / 2 ))"
else
FRECON_SCALING_FACTOR=1
fi
# Save Frecon constants to use in MiniOs.
mkdir -p /etc/frecon
echo "${CANVAS_SIZE}" > /etc/frecon/size
echo "${FRECON_SCALING_FACTOR}" > /etc/frecon/scale
end script
exec frecon-lite --enable-vt1 --daemon --no-login --enable-gfx --enable-vts \
--scale="${FRECON_SCALING_FACTOR}" --clear="0x202124" \
--pre-create-vts /dev/null
post-start script
# Give frecon a second to start up before turning off keyboard input
# processing and starting MiniOs UI.
# TODO(b/181366924): MiniOs: detect if Frecon is up before showing screens.
sleep 1s
printf "\033]input:off\a" > /run/frecon/vt0
end script