distribution/packages/jelos/profile.d/02-distribution
2023-01-21 10:15:01 -05:00

71 lines
1.8 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"
get_setting() {
if [ ! -z "${3}" ]
then
### Test to see if we have a game setting.
VAR="$2\[\"$(echo ${3} | sed 's/[\(\)]/\\&/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.
awk -F: '/^'"${2}.${1}"'=/ { st = index($0,"=");print substr($0,st+1);exit}' ${J_CONF}
return
fi
elif [ -z "${3}" ] && [ ! -z "${2}" ]
then
### Check to see if we have a system setting.
awk -F: '/^'"${2}.${1}"'=/ { st = index($0,"=");print substr($0,st+1);exit}' ${J_CONF}
return
else
### Check to see if we have a global setting
awk -F: '/^'"${1}"='/ { st = index($0,"=");print substr($0,st+1);exit}' ${J_CONF}
return
fi
}
set_setting() {
if [[ "${1}" =~ ^[[:alnum:]] ]]
then
sed -i "/^${1}=/d" "${J_CONF}"
echo "${1}=${2}" >> "${J_CONF}"
fi
}
set_audio() {
case ${1} in
"default")
AUDIO="alsa"
;;
*)
AUDIO=${1}
;;
esac
/usr/bin/rr_audio.sh ${AUDIO}
}
get_es_setting() {
echo $(sed -n "s|\s*<${1} name=\"${2}\" value=\"\(.*\)\" />|\1|p" ${ES_CONF})
}
log() {
SOURCE=${1//\/*\//}
MESSAGE=${*#${1}}
MESSAGE=${MESSAGE# }
logger -t ${SOURCE} "${MESSAGE}"
}