Permalink
Browse files

Replaced all the remaining commands that can use the defaults provider

  • Loading branch information...
1 parent a984f80 commit e406705ea7b9cde8b76833b22be8bf381620c46f Davis W. Frank committed Jul 24, 2012
@@ -10,7 +10,8 @@ def type_flag
return '-int' if new_resource.integer
return '-string' if new_resource.string
return '-float' if new_resource.float
- return '-boolean' unless new_resource.nil?
+ return '-boolean' unless new_resource.boolean.nil?
+ ''
end
def value
@@ -18,13 +18,16 @@
}
corners.each do |corner, value|
- execute "#{corner} right #{value}" do
- command "defaults write com.apple.dock wvous-#{corner}-corner -int #{active_corner_value_to_int[value]}"
- user WS_USER
+ pivotal_workstation_defaults "Active Corner: #{corner} right #{value}" do
+ domain 'com.apple.dock'
+ key "wvous-#{corner}-corner"
+ integer active_corner_value_to_int[value]
end
- execute "#{corner} modifier" do
- command "defaults write com.apple.dock wvous-#{corner}-modifier -int 0"
- user WS_USER
+
+ pivotal_workstation_defaults "Active Corner: #{corner} modifier" do
+ domain 'com.apple.dock'
+ key "wvous-#{corner}-modifier"
+ integer 0
end
end
@@ -1,4 +1,5 @@
-execute "set finder to display full path in title bar" do
- command "defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES"
- user WS_USER
+pivotal_workstation_defaults "set finder to display full path in title bar" do
+ domain 'com.apple.finder'
+ key '_FXShowPosixPathInTitle'
+ boolean true
end
@@ -4,9 +4,10 @@
# The following won't take effect until the person logs out & logs back in again.
# THE BELT
-execute "Turn " + ( as_fn_keys ? "on" : "off" ) + " function-keys-work-as-function keys" do
- command "defaults write .GlobalPreferences com.apple.keyboard.fnState -bool #{node.default['function_keys']['use_function_keys_as_function_keys']}"
- user WS_USER
+pivotal_workstation_defaults "Turn #{as_fn_keys ? "on" : "off" } function-keys-work-as-function keys" do
+ domain '.GlobalPreferences'
+ key 'com.apple.keyboard.fnState'
+ boolean node.default['function_keys']['use_function_keys_as_function_keys']
end
# Attempt an interactive change. Two req'ts: 1) user must be logged in 2) assistive devices enabled
@@ -1,3 +1,5 @@
-execute "Turn on Input menu in login screen (dvorak vs qwerty)" do
- command "defaults write /Library/Preferences/com.apple.loginwindow showInputMenu -bool true"
+pivotal_workstation_defaults "Turn on Input menu in login screen (dvorak vs qwerty)" do
+ domain '/Library/Preferences/com.apple.loginwindow'
+ key 'showInputMenu'
+ boolean true
end
@@ -1,4 +1,5 @@
-execute "set safari to show status bar" do
- command "defaults write com.apple.safari ShowStatusBar -bool YES"
- user WS_USER
-end
+pivotal_workstation_defaults "set safari to show status bar" do
+ domain 'com.apple.safari'
+ key 'ShowStatusBar'
+ boolean true
+end
@@ -1,14 +1,17 @@
-execute "show hard drive on desktop" do
- command "defaults write com.apple.finder ShowHardDrivesOnDesktop -bool YES"
- user WS_USER
+pivotal_workstation_defaults "show hard drive on desktop" do
+ domain 'com.apple.finder'
+ key 'ShowHardDrivesOnDesktop'
+ boolean true
end
-execute "show external hard drives on desktop" do
- command "defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool YES"
- user WS_USER
+pivotal_workstation_defaults "show external hard drives on desktop" do
+ domain 'com.apple.finder'
+ key 'ShowExternalHardDrivesOnDesktop'
+ boolean true
end
-execute "show removable media on desktop" do
- command "defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool YES"
- user WS_USER
-end
+pivotal_workstation_defaults "show removable media on desktop" do
+ domain 'com.apple.finder'
+ key 'ShowRemovableMediaOnDesktop'
+ boolean true
+end
@@ -1,4 +1,5 @@
-execute "show hard drive on desktop" do
- command "defaults write com.apple.finder ShowHardDrivesOnDesktop -bool YES"
- user WS_USER
+pivotal_workstation_defaults "show hard drive on desktop" do
+ comain 'com.apple.finder'
+ key 'ShowHardDrivesOnDesktop'
+ boolean true
end
@@ -1,9 +1,11 @@
-execute "allow clicking by touch" do
- command "defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking 1"
- user WS_USER
+pivotal_workstation_defaults "allow clicking by touch" do
+ domain 'com.apple.driver.AppleBluetoothMultitouch.trackpad'
+ key 'Clicking'
+ integer 1
end
-execute "allow dragging by touch" do
- command "defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Dragging 1"
- user WS_USER
+pivotal_workstation_defaults "allow dragging by touch" do
+ domain 'com.apple.driver.AppleBluetoothMultitouch.trackpad'
+ key 'Dragging'
+ integer 1
end
@@ -1,4 +1,5 @@
-execute "turn on focus-follows-mouse for terminal" do
- command "defaults write com.apple.Terminal FocusFollowsMouse -string YES"
- user WS_USER
-end
+pivotal_workstation_defaults "turn on focus-follows-mouse for terminal" do
+ domain 'com.apple.Terminal'
+ key 'FocusFollowsMouse'
+ string 'yes'
+end
@@ -1,4 +1,5 @@
-execute "set terminal color scheme" do
- command "defaults write com.apple.Terminal 'Startup Window Settings' -string #{node['terminal']['color_scheme']}"
- user WS_USER
+pivotal_workstation_defaults "Set terminal color scheme to #{node['terminal']['color_scheme']}" do
+ domain 'com.apple.Terminal'
+ key 'Startup Window Settings'
+ string node['terminal']['color_scheme']
end
@@ -1,13 +1,15 @@
include_recipe "pivotal_workstation::textmate"
-execute "set save on losing focus" do
- command "defaults write ~/Library/Preferences/com.macromates.textmate OakSaveAllOnDeactivate -bool TRUE"
- user WS_USER
+pivotal_workstation_defaults "set save on losing focus" do
+ domain '~/Library/Preferences/com.macromates.textmate'
+ key 'OakSaveAllOnDeactivate'
+ boolean true
end
execute "show line numbers" do
- command "defaults write ~/Library/Preferences/com.macromates.textmate OakTextViewLineNumbersEnabled -bool TRUE"
- user WS_USER
+ domain '~/Library/Preferences/com.macromates.textmate'
+ key 'OakTextViewLineNumbersEnabled'
+ boolean true
end
gem_package("plist")
@@ -1,6 +1,7 @@
-execute "TimeMachine should NOT ask to use every new disk" do
- command "defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool YES"
- user WS_USER
+pivotal_workstation_defaults "TimeMachine should NOT ask to use every new disk" do
+ domain 'com.apple.TimeMachine'
+ key 'DoNotOfferNewDisksForBackup'
+ boolean true
end
old_menu_extras = `sudo -u #{WS_USER} defaults read com.apple.systemuiserver menuExtras`
@@ -1,4 +1,5 @@
-execute "turn on focus-follows-window for browsers, etc.." do
- command "defaults write org.x.X11 wm_ffm -bool true"
- user WS_USER
-end
+pivotal_workstation_defaults "turn on focus-follows-window for browsers, etc.." do
+ domain 'org.x.X11'
+ key 'wm_ffm'
+ boolean true
+end
View
@@ -1,20 +1,42 @@
=begin
+
+A resoudce/provider to call to MacOS's plist 'defaults' command line tool.
+
+Syntax:
+
pivotal_workstation_defaults "set key repeat rate" do
domain "/Users/#{WS_USER}/Library/Preferences/.GlobalPreferences"
key "KeyRepeat"
integer 2
end
+
+Supports the attribute types below.
+
+TODO List:
+
+* Remaining params that need to be supported:
+ -data <hex_digits>
+ -date <date_rep>
+ -array <value1> <value2> ...
+ -array-add <value1> <value2> ...
+ -dict <key1> <value1> <key2> <value2> ...
+ -dict-add <key1> <value1> ..
+* Should support notifies
+* Should support overrides of not_if with a more complex block
+
=end
actions :write
attribute :description, :kind_of => String, :name_attribute => true
attribute :domain, :kind_of => String, :default => nil
attribute :key, :kind_of => String, :default => nil
+
attribute :integer, :kind_of => Integer, :default => nil
attribute :string, :kind_of => String, :default => nil
attribute :boolean, :kind_of => [ TrueClass, FalseClass ], :default => nil
attribute :float, :kind_of => [Float, Integer], :default => nil
+attribute :array, :kind_of => [Array, String, Integer], :defaults => nil
def initialize(name, run_context=nil)
super

0 comments on commit e406705

Please sign in to comment.