RPi-Distro / raspi-config

Configuration tool for the Raspberry Pi
Other
565 stars 206 forks source link

How can I access a raspi-config submenus directly? #206

Closed fedekrum closed 1 year ago

fedekrum commented 1 year ago

I am working on a script that needs to access raspi-config at "Interface Options > I2C" directly. Is there a way to do this at the command line ?

Thanks

cinderblock commented 1 year ago

Yes. As users discovered here, it's fully supported, albeit un-documented, afaik. No idea if this is considered stable.

sudo raspi-config nonint do_i2c 0 # Enable I2C
sudo raspi-config nonint do_i2c 1 # Disable I2C

Most settings in raspi-config follow this standard of do_X 0 to enable X. 0 = Enable. 1 = Disable.

If you're looking for how this is supported, the important entry lines are:

https://github.com/RPi-Distro/raspi-config/blob/master/raspi-config#L2937-L2939

They take all arguments after nonint and just call them directly. So you can call other functions in the bash file directly.

Note, there is no direct way to launch just that submenu, afaik. You could source the shell script, set INTERACTIVE=true, and then run do_i2c to maybe get it to work... But I'm sure that is very unsupported usage.