#!/bin/bash # SPDX-License-Identifier: Apache-2.0 # Copyright (C) 2021-present Fewtarius (https://github.com/fewtarius) . /etc/profile hdmi_con() { if [ -f "/sys/class/extcon/hdmi/state" ] then HDMI="$(cat /sys/class/extcon/hdmi/state)" if [ "${HDMI}" = "HDMI=1" ] then if [ -f "/sys/devices/virtual/graphics/fbcon/rotate" ] then echo 0 >/sys/devices/virtual/graphics/fbcon/rotate fi fi fi } ### ### Test for an HDMI connection and if there is none, configure the system to use ### a rotation patched SDL2. cat </storage/.config/profile.d/006-hdmi HDMI="\$(cat /sys/class/extcon/hdmi/state)" if [ ! "\${HDMI}" = "HDMI=1" ] then SDL=\$(readlink -f /usr/lib/SDL2-rotated/libSDL2.so 2>/dev/null) export LD_PRELOAD="\${SDL}" fi EOF chmod 0755 /storage/.config/profile.d/006-hdmi ### If hdmi is connected, set the framebuffer rotation back to normal. hdmi_con