Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
usage_of_batocera-settings [2021/08/22 11:09] – repaired scripts (maybe?) atari | usage_of_batocera-settings [2023/10/09 20:41] (current) – python example works now crcerror | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ~~NOTOC~~ | ||
====== Usage of batocera-settings ====== | ====== Usage of batocera-settings ====== | ||
===== Introduction ===== | ===== Introduction ===== | ||
- | <WRAP center round info 60%> | + | <WRAP center round info> |
- | This command is a bit out of date to use now, most if not all things can be adjusted within Batocera EmulationStation itself or through manually editing the text file. Certain commands may no longer be functional. | + | This command is a bit out of date to use now, most if not all things can be adjusted within Batocera EmulationStation itself or through manually editing the text file. Certain commands may no longer be functional. |
</ | </ | ||
- | **batocera-settings** is a command-line tool that can work with regular config files to read/write its content | + | **batocera-settings** is a command-line tool that can work with regular config files to read/write its content, useful for scripting (like say you need to change the config based on what machine you have the drive plugged into). The ''/ |
When manually editing the '' | When manually editing the '' | ||
Line 18: | Line 17: | ||
Down here is a small excerpt of an example config file | Down here is a small excerpt of an example config file | ||
+ | |||
< | < | ||
# ------------ B - Network ------------ # | # ------------ B - Network ------------ # | ||
Line 35: | Line 35: | ||
===== Recommended commands and expressions ===== | ===== Recommended commands and expressions ===== | ||
- | batocera-setting | + | The commands are called with '' |
- | As batocera-settings | + | Syntax for reading setting values: |
+ | < | ||
+ | batocera-settings-get -f [CONFIG_FILE] [KEY] | ||
+ | batocera-settings-get [KEY] | ||
+ | </code> | ||
- | * BATOCERA Basic usage | + | This will read the KEY setting |
- | * **'' | + | |
- | * **'' | + | |
- | * **'' | + | |
- | * BATCOERA Extended usage FIXME This flag no longer exists, was it moved or outright deleted? | + | |
- | * **'' | + | |
- | * **'' | + | |
- | <WRAP center round tip 80%> | + | Syntax for setting those values: |
- | **Basic usage:** //batocera-settings-set -f [CONFIG_FILE] [KEY] [VALUE]\\ | + | <code> |
- | **Extended usage:** //batocera-settings-set | + | batocera-settings-set -f [CONFIG_FILE] [KEY] [VALUE] |
- | **-f** -- Specifies the config file to read from. Defaults to ''/ | + | batocera-settings-set [KEY] [VALUE] |
- | **-v** -- Set value to selected ' | + | </code> |
- | **-e** -- Activate extended mode, needed for parsing game/system specific keys FIXME This flag no longer exists, was it moved or outright deleted? | + | |
- | **-g** -- Filename of the specified game, enclose in double-quotes ("" | + | |
- | **-s** -- Shortname of specified system FIXME This flag no longer exists, was it moved or outright deleted?\\ | + | |
- | </WRAP> | + | |
- | <WRAP center round alert 60%> | + | This will search for the key in the config file and then replace its value with the new specified one. If the key doesn't already exist in the config file, a new line with that key will be created. |
- | FIXME This flag no longer exists, was it moved or outright deleted? | + | |
- | If '' | + | In Batocera **v36** |
- | Use the errorlevels for scripts!\\ | + | |
- | Always use quotes if you use arguments containing blanks!\\ | + | < |
- | </WRAP> | + | batocera-settings-get-master [key] |
+ | </code> | ||
+ | |||
+ | This will read the key from ''/ | ||
===== Error code handling ====== | ===== Error code handling ====== | ||
Line 72: | Line 69: | ||
|EC 0 |No Error, value found | 8-) You made it! | | |EC 0 |No Error, value found | 8-) You made it! | | ||
|EC 1 |General error, e.g. command line error | 8-o Check your command line for correct parameters | | |EC 1 |General error, e.g. command line error | 8-o Check your command line for correct parameters | | ||
- | |EC 2 |File error, e.g. the config file is not available | m( Check file path and r/w access to it | | ||
- | |EC 10 | ||
- | |EC 11 | ||
- | |EC 12 |Key not found | m( Add the key by manual or check your command line for typos | | ||
===== Handling in scripts ===== | ===== Handling in scripts ===== | ||
Line 110: | Line 103: | ||
#This is an example file how batocera-settings-set can be utilized | #This is an example file how batocera-settings-set can be utilized | ||
#to activate UART in / | #to activate UART in / | ||
+ | |||
+ | # Check status of file and make it writeable | ||
+ | [[ -w / | ||
batocera-settings-set -f / | batocera-settings-set -f / | ||
Line 115: | Line 111: | ||
if [[ $ret -eq 0 ]]; then | if [[ $ret -eq 0 ]]; then | ||
echo "UART activated, uncommented enable_uart" | echo "UART activated, uncommented enable_uart" | ||
- | elif [[ $ret -eq 2 ]]; then | ||
- | echo "File is write protected!" | ||
- | echo " | ||
- | mount -o remount, rw /boot | ||
batocera-settings-set -f / | batocera-settings-set -f / | ||
- | if [[ $ret -eq 0 ]]; then | ||
- | echo "UART activated, uncommented enable_uart" | ||
- | fi | ||
else | else | ||
echo "Key: enable_uart not found" | echo "Key: enable_uart not found" | ||
Line 136: | Line 125: | ||
#to set a new key in / | #to set a new key in / | ||
- | value=$(batocera-settings-set core.PS4.emulator | + | value=$(batocera-settings-set core.PS5.emulator |
ret=$? | ret=$? | ||
if [[ $ret -eq 0 ]]; then | if [[ $ret -eq 0 ]]; then | ||
- | echo "PS4 core enabled!" | + | echo "PS5 core enabled!" |
else | else | ||
echo " | echo " | ||
Line 146: | Line 135: | ||
=== 4. python: Obtain a key === | === 4. python: Obtain a key === | ||
- | |||
- | FIXME | ||
<code python| obtain_value.py> | <code python| obtain_value.py> | ||
+ | |||
# | # | ||
- | # -*- coding: utf-8 -*- | ||
#This is an example file how batocera-settings-get can be utilized | #This is an example file how batocera-settings-get can be utilized | ||
#to read a value out from / | #to read a value out from / | ||
import subprocess | import subprocess | ||
- | + | command=(["batocera-settings-get", " | |
- | value = (subprocess.check_output(['batocera-settings-get', 'power.switch.device' | + | rc = subprocess.call(command, |
- | if value: | + | if rc == 0: |
- | print "Power Switch Detected: ", value | + | value = subprocess.check_output(command).decode(" |
+ | print ("Power Switch Detected: ", value) | ||
else: | else: | ||
- | print "No power switch detected!" | + | print ("No power switch detected!" |
</ | </ | ||
+ | |||
+ | |||
+ |
- usage_of_batocera-settings.1629623341.txt.gz
- Last modified: 3 years ago
- by atari