diff --git a/build-aux/meson/postinstall.py b/build-aux/meson/postinstall.py
new file mode 100755
index 0000000..871f925
--- /dev/null
+++ b/build-aux/meson/postinstall.py
@@ -0,0 +1,13 @@
+#!/usr/bin/env python3
+
+from os import environ, path
+from subprocess import call
+
+prefix = environ.get('MESON_INSTALL_PREFIX', '/usr/local')
+datadir = path.join(prefix, 'share')
+destdir = environ.get('DESTDIR', '')
+
+# Package managers set this so we don't need to run
+if not destdir:
+ print('Compiling GSettings schemas...')
+ call(['glib-compile-schemas', path.join(datadir, 'glib-2.0', 'schemas')])
diff --git a/data/meson.build b/data/meson.build
new file mode 100644
index 0000000..01f1eb7
--- /dev/null
+++ b/data/meson.build
@@ -0,0 +1,10 @@
+install_data('org.erikreider.swaync.gschema.xml',
+ install_dir: join_paths(get_option('datadir'), 'glib-2.0/schemas')
+)
+
+compile_schemas = find_program('glib-compile-schemas', required: false)
+if compile_schemas.found()
+ test('Validate schema file', compile_schemas,
+ args: ['--strict', '--dry-run', meson.current_source_dir()]
+ )
+endif
diff --git a/data/org.erikreider.swaync.gschema.xml b/data/org.erikreider.swaync.gschema.xml
new file mode 100644
index 0000000..911a084
--- /dev/null
+++ b/data/org.erikreider.swaync.gschema.xml
@@ -0,0 +1,10 @@
+
+
+
+
+ false
+ The current do not disturb state
+ Whether notifications should be silent or not
+
+
+
diff --git a/meson.build b/meson.build
index e3ec84c..928e897 100644
--- a/meson.build
+++ b/meson.build
@@ -7,6 +7,9 @@ project('sway-notificaton-center', ['c', 'vala'],
add_project_arguments(['--enable-gobject-tracing'], language: 'vala')
add_project_arguments(['--enable-checking'], language: 'vala')
+i18n = import('i18n')
+
+subdir('data')
subdir('src')
datadir = get_option('datadir')
diff --git a/src/cacher/cacher.vala b/src/cacher/cacher.vala
deleted file mode 100644
index adac952..0000000
--- a/src/cacher/cacher.vala
+++ /dev/null
@@ -1,79 +0,0 @@
-namespace SwayNotificationCenter {
- public class Cacher {
- private static Cacher _instance;
-
- /** Get the static singleton */
- public static unowned Cacher instance {
- get {
- if (_instance == null) _instance = new Cacher ();
- return _instance;
- }
- }
-
- private const string CACHE_FILE_STATE = "swaync-state.cache";
- private const FileCreateFlags FILE_FLAGS = FileCreateFlags.PRIVATE
- | FileCreateFlags.REPLACE_DESTINATION;
-
- private string get_cache_path () {
- string path = Path.build_filename (Environment.get_user_cache_dir (),
- CACHE_FILE_STATE);
-
- File file = File.new_for_path (path);
- if (!file.query_exists ()) {
- try {
- file.create (FILE_FLAGS);
- } catch (Error e) {
- stderr.printf ("Error: %s\n", e.message);
- }
- }
- return path;
- }
-
- public bool cache_state (StateCache state) {
- string path = get_cache_path ();
- Json.Node json = Json.gobject_serialize (state);
- string data = Json.to_string (json, true);
-
- try {
- File file = File.new_for_path (path);
-
- return file.replace_contents (
- data.data,
- null,
- false,
- FILE_FLAGS,
- null);
- } catch (Error e) {
- stderr.printf ("Cache state write error: %s\n", e.message);
- return false;
- }
- }
-
- public StateCache get_state_cache () {
- string path = get_cache_path ();
- StateCache s = null;
- try {
- Json.Parser parser = new Json.Parser ();
- parser.load_from_file (path);
- Json.Node ? node = parser.get_root ();
- if (node == null) {
- throw new Json.ParserError.PARSE ("Node is null!");
- }
-
- StateCache model = Json.gobject_deserialize (
- typeof (StateCache), node) as StateCache;
- if (model == null) {
- throw new Json.ParserError.UNKNOWN ("Json model is null!");
- }
- s = model;
- } catch (Error e) {
- stderr.printf (e.message + "\n");
- }
- return s ?? new StateCache ();
- }
- }
-
- public class StateCache : Object {
- public bool dnd_state { get; set; default = false; }
- }
-}
diff --git a/src/main.vala b/src/main.vala
index e37eaea..e05385a 100644
--- a/src/main.vala
+++ b/src/main.vala
@@ -3,11 +3,15 @@ namespace SwayNotificationCenter {
static string ? style_path;
static string ? config_path;
+ static Settings self_settings;
+
public void main (string[] args) {
Gtk.init (ref args);
Hdy.init ();
Functions.init ();
+ self_settings = new Settings ("org.erikreider.swaync");
+
if (args.length > 0) {
for (uint i = 1; i < args.length; i++) {
string arg = args[i];
diff --git a/src/meson.build b/src/meson.build
index 54f9c2d..3ab09ba 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -32,7 +32,6 @@ app_sources = [
'notification/notification.vala',
'controlCenter/controlCenter.vala',
'controlCenter/topAction/topAction.vala',
- 'cacher/cacher.vala',
'blankWindow/blankWindow.vala',
'functions.vala',
constants,
diff --git a/src/notiDaemon/notiDaemon.vala b/src/notiDaemon/notiDaemon.vala
index d6bfc37..76fa5c9 100644
--- a/src/notiDaemon/notiDaemon.vala
+++ b/src/notiDaemon/notiDaemon.vala
@@ -12,12 +12,8 @@ namespace SwayNotificationCenter {
public NotiDaemon (SwayncDaemon swaync_daemon) {
this.notify["dnd"].connect (() => on_dnd_toggle (dnd));
- // Init from state cache
- swaync_daemon.cache_state.bind_property ("dnd-state",
- this,
- "dnd",
- BindingFlags.BIDIRECTIONAL
- | BindingFlags.SYNC_CREATE);
+ // Init dnd from gsettings
+ self_settings.bind ("dnd-state", this, "dnd", SettingsBindFlags.DEFAULT);
this.noti_window = new NotificationWindow ();
this.control_center = new ControlCenter (swaync_daemon, this);
diff --git a/src/swayncDaemon/swayncDaemon.vala b/src/swayncDaemon/swayncDaemon.vala
index 5407975..bd5ef64 100644
--- a/src/swayncDaemon/swayncDaemon.vala
+++ b/src/swayncDaemon/swayncDaemon.vala
@@ -7,20 +7,12 @@ namespace SwayNotificationCenter {
[DBus (name = "org.erikreider.swaync.cc")]
public class SwayncDaemon : Object {
- public StateCache cache_state;
-
public NotiDaemon noti_daemon;
private Array blank_windows = new Array ();
private unowned Gdk.Display ? display = Gdk.Display.get_default ();
public SwayncDaemon () {
- this.cache_state = Cacher.instance.get_state_cache ();
- this.cache_state.notify.connect ((x, r) => {
- debug ("State changed: %s\n", r.name);
- Cacher.instance.cache_state (cache_state);
- });
-
// Init noti_daemon
this.noti_daemon = new NotiDaemon (this);
Bus.own_name (BusType.SESSION, "org.freedesktop.Notifications",