I am looking at creating some Ubuntu applications, but finding good resoures are hard.
I am using the quickly toolkit, but would really like some more insight. How does one normally store application preferences and settings in Linux / Ubuntu.
Is it as simple as creating a XML file and saving the information and then reading from said file on application bootstrap?
If someone can point me in a direction it would be greatly appreciated.
EDIT
This is something I wrote whilst waiting for a reply. Probably exactly what preferences does, but just coded out. You might find it usefull:
import ConfigParser, os # We need to be able to store and recal settings
#first try to read the config.cfg file
config = ConfigParser.RawConfigParser()
configFile = 'data/config.cfg'
# We need to set some defaults
monState = False
tueState = False
wedState = False
thurState = False
friState = False
satState = False
sunState = False
# Creating the Config file
def createConfigFile(fileName):
print "CREATING CONFIG" # not needed, but nice for debugging
config.add_section('Preferences')
config.set('Preferences', 'mon', False)
config.set('Preferences', 'tues', False)
config.set('Preferences', 'wed', False)
config.set('Preferences', 'thur', False)
config.set('Preferences', 'fri', False)
config.set('Preferences', 'sat', False)
config.set('Preferences', 'sun', False)
rewriteConfigFile(filename)
# After reading the config file, we can update configs in memory.
# But this will save it to file for when the application is started up again.
def rewriteConfigFile(filename):
with open(filename, 'wb') as configfile:
config.write(configfile)
# Reading the config file
def readConfigFile(fileName):
print "READING CONFIG" # not needed, but nice for debugging
global monState, tueState, wedState, thurState, friState, satState, sunState
monState = config.getboolean('Preferences', 'mon')
tueState = config.getboolean('Preferences', 'tues')
wedState = config.getboolean('Preferences', 'wed')
thurState = config.getboolean('Preferences', 'thur')
friState = config.getboolean('Preferences', 'fri')
satState = config.getboolean('Preferences', 'sat')
sunState = config.getboolean('Preferences', 'sun')
# If the config does not exist, create it, then read it. Otherwise simply read it
if not config.read(configFile):
createConfigFile(configFile)
readConfigFile(configFile)
else:
readConfigFile(configFile)