1

I am trying to read and write the panel configuration file (~/.config/lxpanel/LXDE-pi/panel ).
I was planning to use some dedicated Python library for the purpose but I cannot recognise the file format.

The file starts like:

# lxpanel <profile> config file. Manually editing is not recommended.
# Use preference dialog in lxpanel to adjust config when you can.

Global { edge=top allign=left margin=0 ... more properties here ... background=0 backgroundfile=/usr/share/lxpanel/images/background.png iconsize=28 monitor=0 } Plugin { type=space Config { Size=4 } } Plugin { type=menu Config { ...............

It doesn't look like any YAML, INI, JSON or XML file format I am familiar to work with with python libraries.

I know I can use a Python or bash script with some find/replace strategy but I would like to have a bit more control on the process.

Could someone please tell me the type of format of this file or give me a hint on how to handle it programmatically?

joaquin
  • 125
  • 8

2 Answers2

3

lxpanel is based off of fbpanel. There's info on the file format at his github, and the associated project page. https://github.com/aanatoly/fbpanel

I was looking for info as well, because in the README, he says "Legal values are..." then specifies "systray" as one of the options - however, it's unusable.

Didn't find out 'til later on, while perusing through lxpanel's config, that they were nearly identical, and tray works fine in both apps. Perhaps it was "systray" in a previous version.

Not sure where the parser is located, but I'm certain you can find it, either in that repo, or the one for lxpanel.

If you want to roll-your-own, he gives specifics in that README about how whitespace is stripped, and capitalization is discarded for keywords, but not their values. There were a few other things, mentioned closing brackets } had to be on a newline.

Found README location from man fbpanel
said it was located at /usr/share/doc/fbpanel/README

but that's gzipped, so you'll need to extract it:
sudo gzip -d /usr/share/doc/fbpanel/README.gz

If you don't have access to fbpanel, I would imagine that text exists on the repo or website.

Doyousketch2
  • 146
  • 1
2

It is indeed a pity lxpanel doesn't use a generic format for its config files.

Make a config template, and then put the required values into it using either search/replace or format specifiers (%s, {}, f-strings, etc).

Making an actual parser for a custom loosely-specified format you will never use again is a waste of time.

Dmitry Grigoryev
  • 28,277
  • 6
  • 54
  • 147