From 422ac2f8284da2414ae8cb2dab24bf5557eed541 Mon Sep 17 00:00:00 2001 From: Eric Hanko Date: Fri, 2 Jun 2017 21:58:12 -0700 Subject: [PATCH] implement actual usage --- .idea/workspace.xml | 112 +++++++++++++++--------------------- recipes/default.rb | 60 +++++++++++++------ resources/system_setting.rb | 26 +++++---- 3 files changed, 104 insertions(+), 94 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 07924d2..5293d92 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,11 +2,9 @@ - - - + - @@ -651,14 +629,6 @@ - - - - - - - - @@ -799,14 +769,6 @@ - - - - - - - - @@ -1016,14 +978,6 @@ - - - - - - - - @@ -1032,18 +986,42 @@ + + + + + + + + + + + + + + + + - - + + + + + + + + + + - - + + diff --git a/recipes/default.rb b/recipes/default.rb index f855a55..41ef553 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -29,40 +29,66 @@ file 'create hidden file' do end system_setting 'com.apple.bluetooth' do - preference 'ControllerPowerState' - enabled false + key 'ControllerPowerState' + set_to false end - system_setting 'com.apple.finder' do - preference 'AppleShowAllFiles' + key 'AppleShowAllFiles' + set_to true end system_setting 'com.apple.TimeMachine' do - preference 'DoNotOfferNewDisksForBackup' - enabled false + key 'DoNotOfferNewDisksForBackup' + set_to false end system_setting 'com.apple.loginwindow' do - preference 'LoginwindowLaunchesRelaunchApps' - enabled false + key 'LoginwindowLaunchesRelaunchApps' + set_to false end system_setting 'com.apple.loginwindow' do - preference 'TALLogoutSavesState' - enabled false + key 'TALLogoutSavesState' + set_to false end system_setting 'com.apple.screensaver' do - preference 'idleTime' - enabled false + key 'idleTime' + set_to false end system_setting 'com.apple.driver.AppleHIDMouse' do - preference 'Button2' + key 'Button2' + set_to true end -system_setting 'com.apple.bluetooth' do - preference 'ControllerPowerState' - enabled false -end \ No newline at end of file +system_setting 'com.apple.Bluetooth' do + key 'ControllerPowerState' + set_to '0' +end + +system_setting 'com.apple.Bluetooth' do + key 'BluetoothAutoSeekKeyboard' + set_to '0' +end + +system_setting 'com.apple.Bluetooth' do + key 'BluetoothAutoSeekPointingDevice' + set_to '0' +end + +system_setting 'sleep' do + set_to '0' +end + +system_setting 'computersleep' do + set_to '0' +end + +system_setting 'displaysleep' do + set_to '0' +end + + + diff --git a/resources/system_setting.rb b/resources/system_setting.rb index 14560ec..44685b6 100644 --- a/resources/system_setting.rb +++ b/resources/system_setting.rb @@ -24,19 +24,25 @@ default_action :set systemsetup = '/usr/sbin/systemsetup' defaults = '/usr/bin/defaults' -property :set_to, String -property :domain, String -property :preference, String, name_property: true -property :value, [String, Integer] property :bin, String, equal_to: [systemsetup, defaults] - +property :preference, String, name_property: true +property :set_to, [Hash, String, true, false] +property :key, String +property :value, [String, Integer] load_current_value do |new_resource| - if shell_out("#{systemsetup} -listCommands | grep #{new_resource.setting}").exitstatus == 0 - utility systemsetup + if shell_out("#{systemsetup} -printCommands | grep #{new_resource.preference}").exitstatus == 0 + new_resource.bin systemsetup else - utility defaults + new_resource.bin defaults end + puts "\n\n++++++++++++++++++++++++++++++++++++" + puts "====> binary: #{new_resource.bin}" + puts "====> Preference: #{new_resource.preference}" + puts "====> Set to: #{new_resource.set_to}" + puts "====> Key: #{new_resource.key}" + puts "====> Value: #{new_resource.value}" + puts "++++++++++++++++++++++++++++++++++++\n" end action :set do @@ -49,10 +55,10 @@ action :set do when defaults execute 'set preference using defaults' do user node['admin_user'] - command "#{defaults} write #{new_resource.domain} #{new_resource.preference} #{set_to} #{new_resource.value}" + command "#{defaults} write #{new_resource.preference} #{new_resource.key} #{set_to} #{new_resource.value}" end else - pass + puts 'Unknown binary' end execute 'restart Finder' do