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 [2020/11/13 19:35] – lala | usage_of_batocera-settings [2023/10/09 18:41] (current) – python example works now crcerror | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ~~NOTOC~~ | + | ====== Usage of batocera-settings |
| - | ===== Usage of: batocera-settings ===== | + | |
| - | ==== Introduction ==== | + | ===== Introduction |
| - | **batocera-settings** | + | <WRAP center round info> |
| + | This command | ||
| + | </ | ||
| - | | + | **batocera-settings** is a command-line tool that can work with regular config files to read/write its content, useful |
| - | * It's recommended | + | |
| - | * It' | + | |
| - | * It's recommended to add content in sections | + | |
| - | * It' | + | |
| - | Down here is a small excerpt of a config file | + | When manually editing the '' |
| - | <code> | + | |
| + | * Use **## This is a text comment** for text comments. | ||
| + | * Use **# | ||
| + | * Describe content and functions in comments when adding them for future reference. | ||
| + | * It's recommended to add content in their appropriate sections, but not strictly required. | ||
| + | |||
| + | Down here is a small excerpt of an example | ||
| + | |||
| + | <file> | ||
| # ------------ B - Network ------------ # | # ------------ B - Network ------------ # | ||
| ## Set system hostname | ## Set system hostname | ||
| Line 26: | Line 31: | ||
| ## Escape your special chars (# ; $) with a backslash : $ => \$ | ## Escape your special chars (# ; $) with a backslash : $ => \$ | ||
| # | # | ||
| - | </code> | + | </file> |
| - | ==== Recommended commands and expressions ==== | + | ===== Recommended commands and expressions |
| - | batocera-setting | + | The commands are called with '' |
| - | As batocera-settings is more modern and supports read/ | + | Syntax for reading setting values: |
| - | * BATOCERA Basic usage | + | < |
| - | * '' | + | batocera-settings-get -f [CONFIG_FILE] [KEY] |
| - | * '' | + | batocera-settings-get [KEY] |
| - | * '' | + | </ |
| - | * BATCOERA Extended usage | + | |
| - | * '' | + | |
| - | * '' | + | |
| - | <WRAP center round tip 80%> | + | This will read the KEY setting from the specified |
| - | **Basic usage:** // | + | |
| - | **Extended usage:** // | + | |
| - | \\ | + | |
| - | **-f** -- Loads any config file, default '/ | + | |
| - | **-r** -- Read 'key' and returns value from config file \\ | + | |
| - | **-w** -- Write 'key' | + | |
| - | **-v** -- Set value to selected | + | |
| - | **-e** -- Activate extended mode, needed for parsing game/ | + | |
| - | **-g** -- Any alphanumeric string for game, set quotes to avoid globbing \\ | + | |
| - | **-s** -- Any alphanumeric string for system \\ | + | |
| - | </WRAP> | + | |
| - | <WRAP center round alert 60%> | + | |
| - | If '' | + | |
| - | Value '' | + | |
| - | Use the errorlevels for scripts! | + | |
| - | </ | + | |
| + | Syntax for setting those values: | ||
| + | < | ||
| + | batocera-settings-set -f [CONFIG_FILE] [KEY] [VALUE] | ||
| + | batocera-settings-set [KEY] [VALUE] | ||
| + | </ | ||
| - | ==== Backward compatibility commands | + | This will search for the key in the config file and then replace its value with the new specified one. If the key doesn' |
| - | | + | In Batocera |
| - | | + | |
| - | | + | |
| - | | + | |
| - | + | ||
| - | ^%%--%%command ^%%--%%key ^%%--%%value ^alias commands ^ | + | |
| - | |load |your.key | |get, | + | |
| - | |write |your.key |keyvalue |set, | + | |
| - | |status |your.key | |stat | | + | |
| - | |comment |your.key | |disable, | + | |
| - | |uncomment |your.key | |enable, | + | |
| - | ==== Error code handling ===== | + | < |
| + | batocera-settings-get-master [key] | ||
| + | </ | ||
| + | |||
| + | This will read the key from ''/ | ||
| + | |||
| + | ===== Error code handling | ||
| - | Whenever '' | + | Whenever '' |
| ^File and Key/Values error ||| | ^File and Key/Values error ||| | ||
| Line 82: | 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 |
| - | I present here some short scripts, to show you how to make batocera-settings work in your script. As I'm more confident in shell scripting I give you just some small exampels | + | I present here some short scripts, to show you how to make batocera-settings work in your script. As I'm more confident in shell scripting I give you just some small examples |
| - bash: Obtain value | - bash: Obtain value | ||
| Line 95: | Line 78: | ||
| - bash: Set a new key | - bash: Set a new key | ||
| - python: Obtain a value | - python: Obtain a value | ||
| - | |||
| ** USE AT YOUR OWN RISK ** 8-) | ** USE AT YOUR OWN RISK ** 8-) | ||
| Line 103: | Line 85: | ||
| <code bash| obtain_value.sh> | <code bash| obtain_value.sh> | ||
| #!/bin/bash | #!/bin/bash | ||
| - | #This is an example file how batocera-settings 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 / | ||
| - | value=" | + | value=" |
| ret=$? | ret=$? | ||
| if [[ $ret -eq 0 ]]; then | if [[ $ret -eq 0 ]]; then | ||
| Line 119: | Line 101: | ||
| <code bash| activate_uart.sh> | <code bash| activate_uart.sh> | ||
| #!/bin/bash | #!/bin/bash | ||
| - | #This is an example file how batocera-settings can be utilized | + | #This is an example file how batocera-settings-set can be utilized |
| #to activate UART in / | #to activate UART in / | ||
| - | batocera-settings | + | # Check status of file and make it writeable |
| + | [[ -w / | ||
| + | |||
| + | batocera-settings-set -f / | ||
| ret=$? | ret=$? | ||
| 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 | + | batocera-settings-set -f /boot/config.txt enable_uart 1 |
| - | echo "File is write protected!" | + | |
| - | echo "I make boot-partition writeable" | + | |
| - | mount -o remount, rw /boot | + | |
| - | echo " | + | |
| else | else | ||
| echo "Key: enable_uart not found" | echo "Key: enable_uart not found" | ||
| Line 139: | Line 120: | ||
| === 3. bash: Set a new key === | === 3. bash: Set a new key === | ||
| - | <code bash| activate_uart.sh> | + | <code bash| set_new_key.sh> |
| #!/bin/bash | #!/bin/bash | ||
| - | #This is an example file how batocera-settings can be utilized | + | #This is an example file how batocera-settings-set can be utilized |
| #to set a new key in / | #to set a new key in / | ||
| - | value=$(batocera-settings --command write --key 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!" |
| - | elif [[ $ret -eq 12 ]]; then | + | |
| - | echo "Key not found! - I add it" | + | |
| - | echo " | + | |
| - | + | ||
| - | echo " | + | |
| else | else | ||
| - | echo "Annother | + | echo "Another |
| fi | fi | ||
| </ | </ | ||
| === 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 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.1605296140.txt.gz
- Last modified: 6 years ago
- by lala