Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // compile with valac --pkg gio-2.0 daemon.vala
- // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
- /***
- BEGIN LICENSE
- Copyright (C) 2011-2014 elementary Developers
- This program is free software: you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License version 3, as published
- by the Free Software Foundation.
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranties of
- MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
- PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU General Public License along
- with this program. If not, see <http://www.gnu.org/licenses/>
- END LICENSE
- ***/
- void main () {
- var settings = new Settings ("org.gnome.desktop.background");
- write_settings (settings);
- settings.changed.connect (() => {
- write_settings (settings);
- });
- new MainLoop ().run ();
- }
- void write_settings (Settings settings) {
- try {
- string settings_path = Path.build_path ("/", Environment.get_home_dir (), ".greeter-settings");
- var settings_file = File.new_for_path (settings_path);
- if (settings_file.query_exists ()) {
- settings_file.delete ();
- }
- var dos = new DataOutputStream (
- new BufferedOutputStream.sized (settings_file.create (
- FileCreateFlags.REPLACE_DESTINATION), 65536));
- dos.put_string ("picture-uri=" + settings.get_string ("picture-uri") + "\n");
- dos.put_string ("picture-option=" + settings.get_string ("picture-options") + "\n");
- dos.put_string ("primary-color=" + settings.get_string ("primary-color") + "\n");
- dos.put_string ("secondary-color=" + settings.get_string ("secondary-color") + "\n");
- if (!dos.close ()) {
- warning ("Failed to close the output-stream");
- }
- } catch (Error e) {
- warning ("%s", e.message);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement