kde-plasmakde4plasmoid

Where do I store plasmoid's custom data?


I'm new to KDE development. I wrote a plasmoid that needs to store its data somewhere, namely - ical feeds need to be stored for offline usage.

While I could just write it to ~/.ical/ or some other location I would make up, I'd like to know what is the proper way of doing it - is there an API i can query about the path to store my private data?


Solution

  • I have received an answer on KDE forums:

    I think you can use KStandardDirs to create a directory inside the user's KDEHOME, in a specific path for your application (I suggest using "data" for that).

    So my code now looks like this:

        def getDataPath(self, *parts):
            main_dir = str(KStandardDirs.locateLocal("data", "gcal-agenda"))
            dirs = [main_dir] + list(parts)
            return os.path.join(*dirs)
    

    where "gcal-agenda" is the name of my plasmoid.