Question

I'm developing a ubuntu unity application with MonoDevelop.

How can I read dconf settings using C#?

Can I access GSettings using C#?

What I actually need is the value of the key /org/gnome/desktop/interface/font-name.

Update

my quick hack is as follows:

private string GetFontName()
{
    string font = "Ubuntu 11";

    Process p = new Process {
        StartInfo = new ProcessStartInfo {
            FileName = "gsettings",
            Arguments = "get org.gnome.desktop.interface font-name",
            UseShellExecute = false,
            RedirectStandardOutput = true,
            CreateNoWindow = true
        }
    };

    p.Start();

    while (!p.StandardOutput.EndOfStream)
        font = p.StandardOutput.ReadLine();

    p.WaitForExit();

    return font.Trim(new char[]{'\''});
}

No correct solution

OTHER TIPS

I never work with Ubuntu and Mono. I think below ode may help you.

using System;
using System.IO;

namespace FileAccess
{
    class MainClass
    {
        public static void Main (string[] args)
        {
            string FileName="TestFile.txt";

            // Open the file into a StreamReader
            StreamReader file = File.OpenText(FileName);
            // Read the file into a string
            string s = file.ReadToEnd();
            // Close the file so it can be accessed again.
            file.Close();

            // Add a line to the text
            s  += "A new line.\n";

            // Hook a write to the text file.
            StreamWriter writer = new StreamWriter(FileName);
            // Rewrite the entire value of s to the file
            writer.Write(s);

            // Add a single line
            writer.WriteLine("Add a single line.");

            // Close the writer
            writer.Close();
        }
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top