简体   繁体   中英

Install/configure Arduino IDE preferences via script

I created an ansible script that installs Arduino IDE together with an icon and Freedesktop compliant launcher file. This parts works very well.

Now I want to preconfigure the IDE's language. A lot of sites mention that preferences are stored in ~/.arduino15/preferences.txt . Such a file does not exist on my computers. When I create it and add the language setting, it is completely ignored.

Instead I found the file ~/.arduinoIDE/settings.json , but it seems to not contain any language settings.

Then there is ~/.arduinoIDE/arduino-cli.yaml , and it has a locale key that is set to the value chosen in the UI. However it seems not authorative for IDE startup. Whatever I put in the file, the IDE will still used the language I configured in the IDE.

Where does Arduino IDE store it's preferences that I can use to control the IDE's language on next startup?

I was able to drill down where the locale information is stored. Since Arduino-IDE 2.x (the Theja based one), preferences are kept in a leveldb at ~/.config/arduino-ide/Local Storage/leveldb .

Following the hint from https://stackoverflow.com/a/53845549/4222206 and plyvel I was able to create the below python script, which will configure Arduino-IDE to run with the english locale (regardless of what you had configured in the UI before):

import plyvel
db = plyvel.DB('~/.config/arduino-ide/Local Storage/leveldb')
db.put(b'_file://\x00\x01localeId', b'\x01en') 

So you may choose your language, eg French and just set the value to b'\x01fr' . Other languages seem to follow the same pattern.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM