distribution/packages/jelos/profile.d/02-distribution
fewtarius fb954b97fa
x55, ES, UI Updates
* Set correct rotation when connected to HDMI on Powkiddy x55.
* Deprecate EmulationStation splash screen.
* Fix bug setting 16:10 aspect ratio - move redundant script bits to a global function.
* Experiment with ES defaults.
2023-07-22 23:56:23 +00:00

132 lines
3 KiB
Text

# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2019-present Shanti Gilbert (https://github.com/shantigilbert)
# Copyright (C) 2020-present Fewtarius
. /etc/os-release
export PATH="/usr/bin:/usr/local/bin:/storage/bin:${PATH}"
export SDL_GAMECONTROLLERCONFIG_FILE="/storage/.config/SDL-GameControllerDB/gamecontrollerdb.txt"
J_DIR="/storage/.config/system"
J_CONF="${J_DIR}/configs/system.cfg"
ES_CONF="/storage/.emulationstation/es_settings.cfg"
JSLISTENCONF="${J_DIR}/configs/jslisten.cfg"
function get_setting() {
if [ ! -z "${3}" ]
then
### Test to see if we have a game setting.
VAR="$2\[\"$(echo ${3} | sed 's/\W/\\&/g')\"]\.$1"
OUTPUT=$(awk 'BEGIN {FS="="} /^'"${VAR}"'/ {print $NF}' ${J_CONF})
if [ ! -z "${OUTPUT}" ]
then
echo ${OUTPUT}
return
else
### If not, check to see if we have a system setting.
LOCAL=$(awk -F: '/^'"${2}.${1}"'=/ { st = index($0,"=");print substr($0,st+1);exit}' ${J_CONF})
if [ ! -z "${LOCAL}" ]
then
echo ${LOCAL}
return
fi
fi
fi
if [ -z "${3}" ] && [ ! -z "${2}" ]
then
### Check to see if we have a system setting.
LOCAL=$(awk -F: '/^'"${2}.${1}"'=/ { st = index($0,"=");print substr($0,st+1);exit}' ${J_CONF})
if [ ! -z "${LOCAL}" ]
then
echo ${LOCAL}
return
fi
fi
### Check to see if we have a global setting and account for legacy "global."
LOCAL=$(awk -F: '/^'"${1}"='/ { st = index($0,"=");print substr($0,st+1);exit}' ${J_CONF})
if [ -z "${LOCAL}" ]
then
awk -F: '/^global.'"${1}"='/ { st = index($0,"=");print substr($0,st+1);exit}' ${J_CONF}
else
echo ${LOCAL}
fi
return
}
function del_setting() {
if [[ "${1}" =~ ^[[:alnum:]] ]]
then
sed -i "/^${1}=/d" "${J_CONF}"
fi
}
function set_setting() {
if [[ "${1}" =~ ^[[:alnum:]] ]]
then
del_setting "${1}"
if [ ! "${2}" = "default" ]
then
echo "${1}=${2}" >> "${J_CONF}"
fi
fi
}
function set_audio() {
case ${1} in
"default")
AUDIO="alsa"
;;
*)
AUDIO=${1}
;;
esac
/usr/bin/rr_audio.sh ${AUDIO}
}
function battery_percent() {
awk 'BEGIN {FS="="} /POWER_SUPPLY_CAPACITY=/ {print $2}' /sys/class/power_supply/[Bb][Aa][Tt]*/uevent 2>/dev/null
}
function get_es_setting() {
echo $(sed -n "s|\s*<${1} name=\"${2}\" value=\"\(.*\)\" />|\1|p" ${ES_CONF})
}
function get_aspect_ratio() {
FBWIDTH=$(fbset | awk '/geometry/ {print $2}')
FBHEIGHT=$(fbset | awk '/geometry/ {print $3}')
ASPECT=$(printf "%.2f" $(echo "(${FBWIDTH} / ${FBHEIGHT})" | bc -l))
case ${ASPECT} in
1.50|0.67)
ASPECT="3:2"
;;
1.33|0.75)
ASPECT="4:3"
;;
1.67|0.60)
ASPECT="5:3"
;;
1.76|0.56)
ASPECT="16:9"
;;
1.60|0.62)
ASPECT="16:10"
;;
esac
echo ${ASPECT}
}
function tocon() {
echo -ne "\033[1000H\033[2K==> ${*}" >/dev/console
}
function log() {
SOURCE=${1//\/*\//}
MESSAGE=${*#${1}}
MESSAGE=${MESSAGE# }
logger -t ${SOURCE} "${MESSAGE}"
echo "$(date) ${SOURCE}: ${MESSAGE}" >>/var/log/messages
}