Compare commits

...

6 commits

Author SHA1 Message Date
XargonWan 1a5463c696 LOGGER: default level is now info
Some checks are pending
Build RetroDECK / Build_RetroDECK (push) Waiting to run
Build RetroDECK / GitHub-publish (push) Blocked by required conditions
2024-11-28 15:06:31 +09:00
XargonWan c35db6b46f LOGGER: actual implementation of log levels 2024-11-28 15:06:21 +09:00
XargonWan 74fec2e9fa LOGGER: fixed blank newlines 2024-11-28 15:01:21 +09:00
XargonWan 1c94be1c33 SRM: feeding it with Steam user data 2024-11-28 14:38:31 +09:00
XargonWan a9c2145230 FRAMEWORK: getting user info at startup 2024-11-28 13:54:23 +09:00
XargonWan 638f92bb7c SPLASHES: added placeholder for new_year, oktoberfest and fruhlingsfest. Ordered the events chronologically 2024-11-28 13:43:09 +09:00
9 changed files with 204 additions and 113 deletions

View file

@ -61,12 +61,12 @@
}
},
"splash_screens": {
"xmas": {
"start_date": "1201",
"end_date": "1231",
"new_year": {
"start_date": "1231",
"end_date": "0106",
"start_time": "0000",
"end_time": "2359",
"filename": "rd-xmas-splash.svg"
"filename": "placeholder.svg"
},
"lunar_dragon": {
"start_date": "0209",
@ -96,6 +96,13 @@
"end_time": "2359",
"filename": "rd-stpatricks-splash.svg"
},
"fruhlingsfest": {
"start_date": "0425",
"end_date": "0428",
"start_time": "0000",
"end_time": "2359",
"filename": "placeholder.svg"
},
"kodomo_golden_week": {
"start_date": "0429",
"end_date": "0505",
@ -123,6 +130,20 @@
"start_time": "0000",
"end_time": "2359",
"filename": "placeholder.svg"
},
"oktoberfest": {
"start_date": "0920",
"end_date": "1005",
"start_time": "0000",
"end_time": "2359",
"filename": "placeholder.svg"
},
"xmas": {
"start_date": "1201",
"end_date": "1231",
"start_time": "0000",
"end_time": "2359",
"filename": "rd-xmas-splash.svg"
}
},
"incompatible_presets": {

View file

@ -36,7 +36,7 @@ sound_effects=true
volume_effects=10
font=1
cheevos_login=false
logging_level=none
logging_level=info
[cheevos]
duckstation=false

View file

@ -5,31 +5,40 @@
"steamDirectory": "${steamdirglobal}",
"steamCategory": "RetroDECK",
"romDirectory": "${romsdirglobal}",
"steamCategories": [],
"executableArgs": "",
"executableModifier": "\"${exePath}\"",
"startInDirectory": "",
"titleModifier": "${fuzzyTitle}",
"fetchControllerTemplatesButton": null,
"removeControllersButton": null,
"steamInputEnabled": "1",
"imageProviders": [
"SteamGridDB"
"sgdb",
"steamCDN"
],
"onlineImageQueries": [
"${fuzzyTitle}"
],
"onlineImageQueries": "${${fuzzyTitle}}",
"imagePool": "${fuzzyTitle}",
"drmProtect": false,
"userAccounts": {
"specifiedAccounts": ""
"specifiedAccounts": [
""
]
},
"parserInputs": {
"glob": "${title}.sh"
},
"executable": {
"path": "",
"shortcutPassthrough": false,
"appendArgsToExecutable": true
},
"parserInputs": {
"glob": "${title}.sh"
},
"titleFromVariable": {
"limitToGroups": "",
"limitToGroups": [],
"caseInsensitiveVariables": false,
"skipFileIfVariableWasNotFound": false,
"tryToMatchTitle": false
"skipFileIfVariableWasNotFound": false
},
"fuzzyMatch": {
"replaceDiacritics": true,
@ -47,6 +56,7 @@
"mappingId": "RetroDECK_controller_ps5.vdf",
"profileType": "template"
},
"ps5_edge": null,
"xbox360": {
"title": "RetroDECK Controller",
"mappingId": "RetroDECK_controller_xbox360_simple.vdf",
@ -57,6 +67,7 @@
"mappingId": "RetroDECK_controller_xboxone_simple.vdf",
"profileType": "template"
},
"xboxelite": null,
"switch_joycon_left": {
"title": "Controller",
"mappingId": "controller_switch_joycon_left_gamepad_joystick.vdf",
@ -76,10 +87,11 @@
"title": "RetroDECK Controller",
"mappingId": "RetroDECK_controller_steamdeck_neptune_full.vdf",
"profileType": "template"
}
},
"steamcontroller_gordon": null
},
"imageProviderAPIs": {
"SteamGridDB": {
"sgdb": {
"nsfw": false,
"humor": false,
"styles": [],
@ -88,7 +100,11 @@
"stylesIcon": [],
"imageMotionTypes": [
"static"
]
],
"sizes": [],
"sizesHero": [],
"sizesTall": null,
"sizesIcon": []
}
},
"defaultImage": {
@ -106,6 +122,6 @@
"icon": null
},
"parserId": "1725539138664815",
"version": 15
"version": 25
}
]

View file

@ -1,24 +1,29 @@
{
"fuzzyMatcher": {
"verbose": false,
"filterProviders": true
"verbose": false,
"filterProviders": true
},
"environmentVariables": {
"steamDirectory": "",
"userAccounts": "${steamlogin}",
"romsDirectory": "",
"retroarchPath": "",
"raCoresDirectory": "",
"localImagesDirectory": ""
"steamDirectory": "",
"userAccounts": [
"steamlogin"
],
"romsDirectory": "",
"retroarchPath": "",
"raCoresDirectory": "",
"localImagesDirectory": ""
},
"previewSettings": {
"retrieveCurrentSteamImages": true,
"deleteDisabledShortcuts": false,
"imageZoomPercentage": 30,
"preload": false
"imageLoadStrategy": "loadLazy",
"retrieveCurrentSteamImages": true,
"disableCategories": false,
"deleteDisabledShortcuts": false,
"imageZoomPercentage": 30,
"hideUserAccount": false
},
"enabledProviders": [
"SteamGridDB"
"sgdb",
"steamCDN"
],
"batchDownloadSize": 50,
"language": "en-US",
@ -26,5 +31,10 @@
"offlineMode": false,
"navigationWidth": 0,
"clearLogOnTest": false,
"version": 6
}
"version": 10,
"dnsServers": [],
"autoUpdate": true,
"autoKillSteam": false,
"autoRestartSteam": false
}

View file

@ -513,3 +513,53 @@ do
fi
done < "$1"
}
get_steam_user() {
# This function populates environment variables with the actual logged Steam user data
if [ -f "$HOME/.steam/steam/config/loginusers.vdf" ]; then
# Extract the Steam ID of the most recent user
export steam_id=$(awk '
/"users"/ {flag=1}
flag && /^[ \t]*"[0-9]+"/ {id=$1}
flag && /"MostRecent".*"1"/ {print id; exit}' "$HOME/.steam/steam/config/loginusers.vdf" | tr -d '"')
# Extract the Steam username (AccountName)
export steam_username=$(awk -v steam_id="$steam_id" '
$0 ~ steam_id {flag=1}
flag && /"AccountName"/ {gsub(/"/, "", $2); print $2; exit}' "$HOME/.steam/steam/config/loginusers.vdf")
# Extract the Steam pretty name (PersonaName)
export steam_prettyname=$(awk -v steam_id="$steam_id" '
$0 ~ steam_id {flag=1}
flag && /"PersonaName"/ {gsub(/"/, "", $2); print $2; exit}' "$HOME/.steam/steam/config/loginusers.vdf")
# Log success
log i "Steam user found:"
log i "SteamID:\t$steam_id"
log i "Username:\t$steam_username"
log i "Name:\t\t$steam_prettyname"
if [[ $steam_sync == "true" ]]; then
populate_steamuser_srm
fi
else
# Log warning if file not found
log w "No Steam user found, proceeding" >&2
fi
}
populate_steamuser_srm(){
# Populating SRM config with Steam Username
log d "Populating Steam Rom Manager config file with Steam Username"
jq --arg username "$steam_username" '
map(
if .userAccounts.specifiedAccounts then
.userAccounts.specifiedAccounts = [$username]
else
.
end
)
' "$XDG_CONFIG_HOME/steam-rom-manager/userData/userConfigurations.json" > "$XDG_CONFIG_HOME/steam-rom-manager/userData/userConfigurations.json.tmp" &&
mv "$XDG_CONFIG_HOME/steam-rom-manager/userData/userConfigurations.json.tmp" "$XDG_CONFIG_HOME/steam-rom-manager/userData/userConfigurations.json"
}

View file

@ -54,7 +54,8 @@ cooker_repository_name="Cooker"
main_repository_name="RetroDECK" # The name of the main repository under RetroDECK organization
features="$config/retrodeck/reference_lists/features.json" # A file where all the RetroDECK and component capabilities are kept for querying
es_systems="/app/share/es-de/resources/systems/linux/es_systems.xml" # ES-DE supported system list
es_find_rules="/app/share/es-de/resources/systems/linux/es_find_rules.xml" # ES-DE emulator find rules
es_find_rules="/app/share/es-de/resources/systems/linux/es_find_rules.xml" # ES-DE emulator find rules
logging_level="info" # Initializing this to avoid printing blank newlines, this will be actually red later from the config file
# Godot data transfer temp files

View file

@ -1,99 +1,87 @@
# SORRY, I WILL CLEAN UP THIS
# -Xargon
# This script provides a logging function 'log' that can be sourced in other scripts.
# It logs messages to both the terminal and a specified logfile, allowing different log levels.
# The log function takes three parameters: log level, log message, and optionally the logfile. If no logfile is specified, it writes to retrodeck/logs/retrodeck.log
# It logs messages to both the terminal and a specified logfile, supporting multiple log levels.
# The log function takes three parameters: log level, log message, and optionally the logfile. If no logfile is specified, it writes to retrodeck/logs/retrodeck.log.
#
# Supported logging levels (controlled by the variable 'logging_level'):
# - none: No logs are produced.
# - info: Logs informational messages (i) and errors (e).
# - warn: Logs warnings (w), informational messages (i), and errors (e).
# - debug: Logs all message types (d, w, i, e).
#
# Type of log messages:
# log d - debug message: maybe in the future we can decide to hide them in main builds or if an option is toggled
# log i - normal informational message
# log w - waring: something is not expected but it's not a big deal
# log e - error: something broke
# - d: Debug message (logged only in debug level).
# - i: Informational message (logged in debug, info, and warn levels).
# - w: Warning message (logged in debug and warn levels).
# - e: Error message (logged in all levels except none).
#
# Example usage:
# log w "foo" -> logs a warning with message foo in the default log file retrodeck/logs/retrodeck.log
# log e "bar" -> logs an error with message bar in the default log file retrodeck/logs/retrodeck.log
# log i "par" rekku.log -> logs an information with message in the specified log file inside the logs folder retrodeck/logs/rekku.log
# log w "foo" -> Logs a warning with message "foo" to the default log file retrodeck/logs/retrodeck.log.
# log e "bar" -> Logs an error with message "bar" to the default log file retrodeck/logs/retrodeck.log.
# log i "baz" rekku.log -> Logs an informational message "baz" to the specified log file retrodeck/logs/rekku.log.
#
# The function auto-detects if the shell is sh and avoids colorizing the output in that case.
log() {
if [[ ! $logging_level == "none" ]]; then
# Exit early if logging_level is "none"
if [[ $logging_level == "none" ]]; then
return
fi
local level="$1"
local message="$2"
local timestamp="$(date +[%Y-%m-%d\ %H:%M:%S.%3N])"
local colorize_terminal
local level="$1" # Logging level of the current message
local message="$2" # Message to log
local timestamp="$(date +[%Y-%m-%d\ %H:%M:%S.%3N])" # Timestamp for the log entry
local logfile="${3:-$rd_logs_folder/retrodeck.log}" # Log file, default to retrodeck.log
local colorize_terminal=true
# Use specified logfile or default to retrodeck.log
local logfile
if [ -n "$3" ]; then
logfile="$3"
else
logfile="$rd_logs_folder/retrodeck.log"
fi
# Check if the shell is sh (not bash or zsh) to avoid colorization
if [ "${SHELL##*/}" = "sh" ]; then
colorize_terminal=false
fi
# Check if the shell is sh (not bash or zsh) to avoid colorization
if [ "${SHELL##*/}" = "sh" ]; then
colorize_terminal=false
else
colorize_terminal=true
fi
# Function to check if the current message level should be logged
should_log() {
case "$logging_level" in
debug) return 0 ;; # Always log everything
info) [[ "$level" == "i" || "$level" == "e" ]] && return 0 ;;
warn) [[ "$level" != "d" ]] && return 0 ;;
error) [[ "$level" == "e" ]] && return 0 ;;
esac
return 1
}
if should_log; then
# Define message colors based on level
case "$level" in
d)
if [[ $logging_level == "debug" ]]; then
if [ "$colorize_terminal" = true ]; then
# Debug (green) for terminal
colored_message="\e[32m[DEBUG] $message\e[0m"
else
# Debug (no color for sh) for terminal
colored_message="$timestamp [DEBUG] $message"
fi
# Write to log file without colorization
log_message="$timestamp [DEBUG] $message"
fi
color="\e[32m[DEBUG]"
prefix="[DEBUG]"
;;
e)
if [[ $logging_level == "debug" || $logging_level == "error" ]]; then
if [ "$colorize_terminal" = true ]; then
# Error (red) for terminal
colored_message="\e[31m[ERROR] $message\e[0m"
else
# Error (no color for sh) for terminal
colored_message="$timestamp [ERROR] $message"
fi
# Write to log file without colorization
log_message="$timestamp [ERROR] $message"
fi
e)
color="\e[31m[ERROR]"
prefix="[ERROR]"
;;
w)
if [[ $logging_level == "debug" || $logging_level == "error" || $logging_level == "warn" ]]; then
if [ "$colorize_terminal" = true ]; then
# Warning (yellow) for terminal
colored_message="\e[33m[WARN] $message\e[0m"
else
# Warning (no color for sh) for terminal
colored_message="$timestamp [WARN] $message"
fi
# Write to log file without colorization
log_message="$timestamp [WARN] $message"
fi
color="\e[33m[WARN]"
prefix="[WARN]"
;;
i)
if [[ $logging_level == "debug" || $logging_level == "error" || $logging_level == "warn" || $logging_level == "info" ]]; then
# Write to log file without colorization for info message
log_message="$timestamp [INFO] $message"
colored_message=$log_message
fi
color="\e[34m[INFO]"
prefix="[INFO]"
;;
*)
# Default (no color for other shells) for terminal
colored_message="$timestamp $message"
# Write to log file without colorization
log_message="$timestamp $message"
color="\e[37m[LOG]"
prefix="[LOG]"
;;
esac
# Construct the log message
if [ "$colorize_terminal" = true ]; then
colored_message="$color $message\e[0m"
else
colored_message="$timestamp $prefix $message"
fi
log_message="$timestamp $prefix $message"
# Display the message in the terminal
echo -e "$colored_message" >&2

View file

@ -205,16 +205,16 @@ conf_read() {
do
if [[ (! -z "$current_setting_line") && (! "$current_setting_line" == "#"*) && (! "$current_setting_line" == "[]") ]]; then # If the line has a valid entry in it
if [[ ! -z $(grep -o -P "^\[.+?\]$" <<< "$current_setting_line") ]]; then # If the line is a section header
local current_section=$(sed 's^[][]^^g' <<< $current_setting_line) # Remove brackets from section name
local current_section=$(sed 's^[][]^^g' <<< "$current_setting_line") # Remove brackets from section name
else
if [[ "$current_section" == "" || "$current_section" == "paths" || "$current_section" == "options" ]]; then
local current_setting_name=$(get_setting_name "$current_setting_line" "retrodeck") # Read the variable name from the current line
local current_setting_value=$(get_setting_value "$rd_conf" "$current_setting_name" "retrodeck" "$current_section") # Read the variables value from retrodeck.cfg
local current_setting_name=$(cut -d'=' -f1 <<< "$current_setting_line" | xargs) # Extract name
local current_setting_value=$(cut -d'=' -f2 <<< "$current_setting_line" | xargs) # Extract value
declare -g "$current_setting_name=$current_setting_value" # Write the current setting name and value to memory
fi
fi
fi
done < $rd_conf
done < "$rd_conf"
}
conf_write() {
@ -936,6 +936,7 @@ quit_retrodeck() {
}
start_retrodeck() {
get_steam_user # get steam user info
splash_screen # Check if today has a surprise splashscreen and load it if so
ponzu
log i "Starting RetroDECK v$version"

View file

@ -95,6 +95,10 @@ prepare_component() {
log i "Updating steamDirectory and romDirectory lines in $srm_userdata/userSettings.json"
jq '.environmentVariables.steamDirectory = "'$HOME'/.steam/steam"' "$srm_userdata/userSettings.json" > "$srm_userdata/tmp.json" && mv -f "$srm_userdata/tmp.json" "$srm_userdata/userSettings.json"
jq '.environmentVariables.romsDirectory = "'$rdhome'/.sync"' "$srm_userdata/userSettings.json" > "$srm_userdata/tmp.json" && mv -f "$srm_userdata/tmp.json" "$srm_userdata/userSettings.json"
get_steam_user
populate_steamuser_srm
fi
if [[ "$component" =~ ^(retroarch|all)$ ]]; then