Permalink
Browse files

Lion fixes, settings recipe/attributes, integers

* Add settings attribute and recipe to process it (great idea from Ben Bleything's bootstrap)
* Use integers instead of strings for plain numbers
* Set resource as updated
* Support floating point numbers
  • Loading branch information...
1 parent 5ed2619 commit 2099f3a960cba2973eacebe1f276aa23de982d8d @jtimberman jtimberman committed Aug 10, 2012
View
@@ -11,6 +11,27 @@ Platform
Tested on Mac OS X 10.6.8, should work on any version.
+Attributes
+==========
+
+* `node['mac_os_x']['settings']` - A hash of settings to apply with
+ the `mac_os_x_userdefaults` LWRP (see below), used in the
+ `mac_os_x::settings` recipe. Set up sub-attributes for each domain's
+ settings to apply. The attribute must be a hash, and must have a
+ "domain" key with the domain of the defaults setting. Each key is a
+ "key" used in the LWRP, and its value is the corresponding "value"
+
+For example, some 'dock' settings (for com.apple.dock):
+
+```ruby
+node.default['mac_os_x']['settings']['dock'] = {
+ "domain" => "com.apple.dock",
+ "no-glass" => true,
+ "autohide" => true,
+ "showhidden" => true
+}
+```
+
Resource/Provider
=================
@@ -162,11 +183,32 @@ Enables password protection for screensaver and sets the delay to ask for passwo
Enable time machine to backup to unsupported devices like NAS drives or AFP shares.
+### settings
+
+Iterates over the `node['mac_os_x']['settings']` attribute (see
+_Attributes_ above) for domain settings to apply. The attributes file
+has commented-out settings to use for examples; this attribute is by
+default an empty hash. You are encouraged to set the attributes for
+your own nodes through a role, rather than modifying the cookbook's
+attributes file directly.
+
+Recipes above which implement specific settings through
+`mac_os_x_userdefaults` can be replaced entirely through the use of
+attributes, and may be removed in favor of this in a future release.
+
+*Assumptions*
+
+There are a couple glaring assumptions made by this recipe.
+
+* If the domain starts with `/Library/Preferences`, then sudo is set
+ to true, as that is not user writable.
+* If the domain is `NSGlobalDomain`, then global is set to true.
+
License and Author
==================
Author:: Joshua Timberman (<cookbooks@housepub.org>)
-Author:: Ben Bleything
+Author:: Ben Bleything (<ben@bleything.net>)
Copyright 2011, Joshua Timberman
View
@@ -0,0 +1,98 @@
+#
+# Original credit: Ben Bleything's workstation bootstrap config
+# cookbook:
+#
+# https://github.com/bleything/bootstrap/tree/master/cookbooks/config
+#
+# Author:: Joshua Timberman <opensource@housepub.org>
+# Copyright (c) 2012, Joshua Timberman
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+node.default['mac_os_x']['settings'] = {}
+
+#######################################################################
+#
+# These commented attributes are provided as examples, though you are
+# encouraged to set attributes from a role, rather than modifying the
+# local cookbook directly.
+#
+# node.default['mac_os_x']['settings']['dock'] = {
+# "domain" => "com.apple.dock",
+# "no-glass" => true,
+# "autohide" => true,
+# "showhidden" => true,
+# "show-process-indicators" => false,
+# "checked-for-launchpad" => true
+# }
+
+# node.default['mac_os_x']['settings']['finder'] = {
+# "domain" => "com.apple.finder",
+# "FXPreferredViewStyle" => "Nlsv", # list view
+# "NewWindowTarget" => "PfHm", # home directory
+# "RemoveIDiskFromSidebarOnStartup" => true,
+# "ShowExternalHardDrivesOnDesktop" => true,
+# "ShowHardDrivesOnDesktop" => false,
+# "ShowMountedServersOnDesktop" => true,
+# "ShowRemovableMediaOnDesktop" => true,
+# "ShowStatusBar" => true,
+# }
+
+# node.default['mac_os_x']['settings']['global'] = {
+# "domain" => "NSGlobalDomain",
+# "NSNavPanelExpandedStateForSaveMode" => true,
+# "PMPrintingExpandedStateForPrint" => true,
+# "AppleAquaColorVariant" => 6,
+# "AppleHighlightColor" => "1.000000 0.823500 0.505900"
+# }
+
+# Corner action magic numbers:
+#
+# 0: no action
+# 2: mission control
+# 3: application windows
+# 4: desktop
+# 5: start screen saver
+# 6: disable screen saver
+# 7: dashboard
+# 10: display sleep
+# 11: launchpad
+#
+# node.default['mac_os_x']['settings']['hot_corners'] = {
+# "domain" => "com.apple.dock",
+# "wvous-tl-corner" => 0, # top left
+# "wvous-bl-corner" => 0, # bottom left
+# "wvous-tr-corner" => 0, # top right
+# "wvous-br-corner" => 0 # bottom right
+# }
+
+# node.default['mac_os_x']['settings']['safari'] = {
+# "domain" => "com.apple.Safari",
+# "IncludeDevelopMenu" => true,
+# "IncludeInternalDebugMenu" => true,
+# "AutoOpenSafeDownloads" => false,
+# "HomePage" => "https://www.google.com/",
+# "NewTabBehavior" => 1,
+# "NewWindowBehavior" => 0,
+# "TabCreationPolicy" => 1,
+# "ShowStatusBar" => true
+# }
+
+# node.default['mac_os_x']['settings']['screensaver'] = {
+# "domain" => "com.apple.screensaver"
+# "askForPassword" => 1,
+# "askForPasswordDelay" => 0
+# }
@@ -56,6 +56,8 @@ def load_current_resource
type ||= 'bool'
when Integer
type ||= 'int'
+ when Float
+ type ||= 'float'
when Hash
type ||= 'dict'
@@ -66,5 +68,6 @@ def load_current_resource
cmd << "-#{type}" if type
cmd << value
execute cmd.join(' ')
+ new_resource.updated_by_last_action(true)
end
end
View
@@ -20,23 +20,23 @@
#
mac_os_x_userdefaults "finder expanded save dialogs" do
- domain "NSNavPanelExpandedStateForSaveMode"
+ key "NSNavPanelExpandedStateForSaveMode"
type "bool"
- value "TRUE"
+ value true
global true
end
mac_os_x_userdefaults "dont show hard drives on the desktop" do
domain "com.apple.finder"
key "ShowHardDrivesOnDesktop"
- value 0
+ value false
type "bool"
end
mac_os_x_userdefaults "show all files in Finder" do
domain "com.apple.finder"
key "AppleShowAllFiles"
- value 0
+ value false
type "bool"
end
View
@@ -24,4 +24,5 @@
key "globalstate"
value "1"
type "int"
+ sudo true
end
View
@@ -0,0 +1,27 @@
+#
+# Cookbook Name:: mac_os_x
+# Recipe:: itunes
+#
+# Author:: Joshua Timberman <opensource@housepub.org>
+# Copyright:: Copyright (c) 2011, Joshua Timberman
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+mac_os_x_userdefaults "Search iTunes locally" do
+ domain "com.apple.iTunes"
+ key "invertStoreLinks"
+ value true
+ type "bool"
+end
View
@@ -20,7 +20,8 @@
#
mac_os_x_userdefaults "Full Keyboard Access to All Controls" do
- domain "AppleKeyboardUIMode"
+ key "AppleKeyboardUIMode"
global true
- value "2"
+ type "int"
+ value 2
end
View
@@ -23,12 +23,12 @@
domain "~/Library/Preferences/.GlobalPreferences"
key "KeyRepeat"
type "int"
- value "2"
+ value 2
end
mac_os_x_userdefaults "set key initial repeat delay to short" do
domain "~/Library/Preferences/.GlobalPreferences"
key "InitialKeyRepeat"
type "int"
- value "15"
+ value 15
end
View
@@ -23,12 +23,12 @@
not_if "defaults read com.apple.mail NSUserKeyEquivalents 2>&1 | grep -q '.*Archive = \"@y\"'"
end
-%w[Reply, Send].each do |animation|
+%w[Reply Send].each do |animation|
mac_os_x_userdefaults "Disable Lions mail #{animation} animation" do
domain "com.apple.Mail"
key "Disable#{animation}Animations"
- value 1
+ value "yes"
type "bool"
end
View
@@ -22,34 +22,99 @@
include_recipe "mac_os_x::lion_mail"
+ execute "killall Dock" do
+ action :nothing
+ end
+
+ mac_os_x_userdefaults "Disable Launchpad gesture" do
+ domain "com.apple.dock"
+ key "showLaunchpadGestureEnabled"
+ type "bool"
+ value false
+ notifies :run, "execute[killall Dock]"
+ end
+
+ mac_os_x_userdefaults "Translucent hidden Dock icons" do
+ domain "com.apple.Dock"
+ key "showhidden"
+ value true
+ type "bool"
+ end
+
+ mac_os_x_userdefaults "0 Duration for Mission Control animation" do
+ domain "com.apple.dock"
+ key "expose-animation-duration"
+ type "int"
+ value false
+ notifies :run, "execute[killall Dock]"
+ end
+
+ mac_os_x_userdefaults "Double tap switch spaces" do
+ domain "com.apple.dock"
+ key "double-tap-jump-back"
+ type "bool"
+ value true
+ notifies :run, "execute[killall Dock]"
+ end
+
+ mac_os_x_userdefaults "Don't automatically rearrange spaces" do
+ domain "com.apple.dock"
+ key "mru-spaces"
+ type "bool"
+ value false
+ notifies :run, "execute[killall Dock]"
+ end
+
mac_os_x_userdefaults "Disable Lions window animations" do
domain "NSGlobalDomain"
key "NSAutomaticWindowAnimationsEnabled"
type "bool"
- value "NO"
+ value false
only_if "defaults read NSGlobalDomain NSAutomaticWindowAnimationsEnabled"
end
mac_os_x_userdefaults "Disable keyboard press and hold" do
- domain "ApplePressAndHoldEnabled"
- value "false"
+ key "ApplePressAndHoldEnabled"
+ value false
global true
end
mac_os_x_userdefaults "Disable automatic spelling correction" do
domain "NSGlobalDomain"
key "NSAutomaticSpellingCorrectionEnabled"
- value "NO"
+ value false
+ type "bool"
+ end
+
+ %w{WebAutomaticDashSubstitutionEnabled
+ WebAutomaticTextReplacementEnabled
+ WebContinuousSpellCheckingEnabled}.each do |text|
+
+ mac_os_x_userdefaults "Disable #{text}" do
+ key text
+ value false
+ type "bool"
+ global true
+ end
+ end
+
+ mac_os_x_userdefaults "Disable AirDrop" do
+ domain "com.apple.NetworkBrowser"
+ key "DisableAirDrop"
+ value true
type "bool"
end
mac_os_x_userdefaults "Always show scrollbars" do
- domain "AppleShowScrollBars"
+ key "AppleShowScrollBars"
type "string"
value "Always"
global true
end
execute "chflags nohidden #{ENV['HOME']}/Library"
+else
+ Chef::Log.warn("#{cookbook_name}::#{recipe_name} is only supported on Mac OS X Lion (10.7)+")
+ return
end
View
@@ -23,12 +23,12 @@
domain "com.apple.screensaver"
key "askForPassword"
type "int"
- value "1"
+ value 1
end
mac_os_x_userdefaults "password protected screensaver delay" do
domain "com.apple.screensaver"
key "askForPasswordDelay"
type "int"
- value "5"
+ value 5
end
Oops, something went wrong.

0 comments on commit 2099f3a

Please sign in to comment.