Commits

Mark Roddy committed d2490cb

only run if setting is a change, and fix several bugs

Comments (0)

Files changed (2)

providers/default.rb

   end
 end
 
+# Get the current value for the specified setting
+def get_current_gsetting_value(user, schema, option)
+  output = `sudo -u #{user} dbus-launch gsettings get #{schema} #{option}`
+  return output.strip()
+end
+
 action :set do
   value = format_value_for_commandline(new_resource.value)
   cmd = "dbus-launch gsettings set #{new_resource.schema} #{new_resource.option} #{value}"
-  execute "Updating gsetting config #{new_resource.schema} #{new_resource.option}" do
-    command cmd
-    user new_resource.user
+  current_value = get_current_gsetting_value(new_resource.user, new_resource.schema, new_resource.option)
+  if current_value != value then
+    msg = "Updating gsetting config #{new_resource.schema} #{new_resource.option} "
+    msg += "from #{current_value} to #{value}"
+    execute msg do
+      command cmd
+      user new_resource.user
+    end
   end
 end
 
   else
     schema = new_resource.schema
     key = new_resource.option
-    cmd = "dbus-launch gsettings reset-recursively #{schema} #{key}"
-    cmd_mame = "Unsetting gsettings key '#{new_resource.key}'"
+    cmd = "dbus-launch gsettings reset #{schema} #{key}"
+    cmd_mame = "Unsetting gsettings key '#{key}'"
   end
   execute cmd_name do
     command cmd

resources/default.rb

 actions :set, :reset
 
-default_action :set
-# Covers 0.10.8 and earlier
-def initialize(*args)
-  super
-  @action = :set
+begin
+  default_action :set
+rescue NoMethodError
+  # Covers 0.10.8 and earlier
+  def initialize(*args)
+    super
+    @action = :set
+  end
 end
 
 attribute :schema, :kind_of => String, :name_attribute => true