Skip to content
This repository has been archived by the owner on May 22, 2018. It is now read-only.

Support refreshonly in osx_defaults #63

Closed
wants to merge 2 commits into from
Closed

Conversation

foca
Copy link

@foca foca commented Sep 7, 2013

Some settings might be set only conditionally upon other resources refreshing. For this scenario, it would be a good idea to support refreshonly inside the boxen::osx_defaults type.

This comes from me trying to manage my desktop background with boxen. I only want to run the osx_defaults that changes the background resource when the file actually changes.

The code (that I would like to have):

  $desktop_file = "/Users/${::boxen_user}/.desktop.png"

  file { $desktop_file:
    ensure => present,
    source => "puppet:///modules/people/foca/wallpaper.png";
  }

  boxen::osx_defaults { "Set desktop background":
    domain      => "com.apple.Desktop",
    key         => "Background",
    value       => "{default = {ImageFilePath = \"${desktop_file}\";};}",
    refreshonly => true, # BOOM
    subscribe   => File[$desktop_file],
    notify      => Exec["Restart the Dock"];
  }

  exec { "Restart the Dock":
    command     => "killall Dock",
    refreshonly => true;
  }

The code I ended up with:

  $desktop_file = "/Users/${::boxen_user}/.desktop.png"

  file { $desktop_file:
    ensure => present,
    source => "puppet:///modules/people/foca/wallpaper.png";
  }

  exec { "Set desktop background":
    command     => "defaults write com.apple.Desktop Background '{default = {ImageFilePath = \"${desktop_file}\";};}'",
    unless      => "defaults read com.apple.Desktop Background | grep '${desktop_file}'",
    refreshonly => true,
    subscribe   => File[$desktop_file],
    notify      => Exec["Restart the Dock"];
  }

  exec { "Restart the Dock":
    command     => "killall Dock",
    refreshonly => true;
  }

Does this make sense? :)

foca added 2 commits September 6, 2013 20:37
Some settings might be set only conditionally upon other resources refreshing. For this scenario, it would be a good idea to support refreshonly inside the `boxen::osx_defaults` type.
…doesn't highlight trailing whitespace.
$value = undef,
$user = undef,
$type = undef,
$refresh = undef,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not this be called $refreshonly?

@n0ts n0ts mentioned this pull request Jan 1, 2014
@rafaelfranca
Copy link
Member

Closing since #82 was merged

@foca
Copy link
Author

foca commented Jan 10, 2014

🤘

@foca foca deleted the patch-1 branch January 10, 2014 15:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants