Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.


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.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)

# 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:

# 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    
share|improve this question
Take a look at these questions:…… – mivoligo Nov 7 '12 at 10:54
up vote 2 down vote accepted

Quickly applications use the glib schemas for application preferences. A default schema is created in data/glib-2.0/schemas. It's an xml file called net.launchpad.XXXX.gschema.xml where XXXX is your application name.

Here's an example entry:

<?xml version="1.0" encoding="UTF-8"?>
<schemalist gettext-domain="drawers">
  <schema id="net.launchpad.drawers" path="/net/launchpad/drawers/">
    <key name="maxicons-row" type="i">
      <range min="1" max="15"/>
      <summary>Maximum Icons per Row</summary>
      <description>Minimum value = 1 Max=15</description>

Key's can be integers (type="i"), boolean (type="b"), or floats (type="d"). Use only lower case and - in key names.

To access the settings and bind them to widgets, you can get them as follows (taken from the generated by quickly):

def finish_initializing(self, builder):# pylint: disable=E1002
    """Set up the preferences dialog"""
    super(PreferencesDrawersDialog, self).finish_initializing(builder)

    # Bind each preference widget to gsettings
    self.settings = Gio.Settings("net.launchpad.drawers")
    widget = self.builder.get_object('maxicons_row')
    self.settings.bind("maxicons-row", widget, "value", Gio.SettingsBindFlags.DEFAULT)

To read values for variables within a program you can do the following:

from gi.repository import Gio
settings = Gio.Settings("net.launchpad.drawers")
float = settings.get_double("floatsetting")
bool = settings.get_boolean("booleansetting")

Hope that helps.

share|improve this answer
Thank you Ian,that is definately more elegant then my solution which I ended up with. – Rudi Strydom Nov 8 '12 at 20:28

If you are storing user data, you typically save it under $HOME/.config/$YOURAPP/ (though the user can change this, so it's better to use xdg.BaseDirectory.xdg_config_home).

If you are using Python, I recommend the ConfigParser library which makes it easy to read and write structured config file data.

share|improve this answer
Thank you, I will check it out! – Rudi Strydom Nov 8 '12 at 15:43

I dont have much work experience with linux. But the similar issue i faced while working on my application.

In linux, every application generates a file which includes all the settings. If its Linux own application, you can easily search for the file in " /etc/ " folder.

please provide some sample Application name for more details.

Hope this may help you find your way.

share|improve this answer
/etc/ is for system-wide settings, not user settings. – mhall119 Nov 8 '12 at 14:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.