Skip to content
This repository was archived by the owner on Dec 2, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,18 @@ class { 'osx::dock::magnification':
}
```

`osx::menu::clock_format` - change the menu bar clock format

```puppet
# Set the default value (format="EEE d MMM h:mm a")
include osx::menu::clock_format

# ... or set your own
class { 'osx::menu::clock_format':
format => "h:mm a"
}
```

## Required Puppet Modules

* boxen
Expand Down
13 changes: 13 additions & 0 deletions manifests/menu.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Internal: Restart the SystemUIServer (menu bar) when necessary.
#
# Example
#
# boxen::osx_defaults { 'Do a thing':
# # ... other stuff here ...
# notify => Exec['killall SystemUIServer'];
# }
class osx::menu {
exec { 'killall SystemUIServer':
refreshonly => true
}
}
32 changes: 32 additions & 0 deletions manifests/menu/clock_format.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Public: Set the menu clock format
#
# format - the menu bar clock format. Defaults to "EEE d MMM h:mm a", eg. "Wed 12 Nov 11:45 pm"
#
# Examples
#
# # set the clock to Wed 12 Nov 11:45 pm (the default)
# include osx::menu::clock_format
#
# # ...or pick your own custom format
# class { 'osx::menu::clock_format':
# format => 'h:mm a'
# }
#
# h:mm = 11:45
# h:mm:ss = 11:45:30
# HH:mm:ss = 23:45:30
# h:mm a = 11:45 pm
# EEE h:mm = Wed 11:45
# d MMM h:mm = 12 Nov 11:45
# EEE d MMM h:mm a = Wed 12 Nov 11:45 pm
#
class osx::menu::clock_format($format = 'EEE d MMM h:mm a') {
boxen::osx_defaults { 'Set clock format':
user => $::boxen_user,
key => 'DateFormat',
domain => 'com.apple.menuextra.clock',
value => $format,
type => 'string',
notify => Exec['killall SystemUIServer'];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There's no matching exec { 'killall SystemUIServer': } for this resource to notify

}
}
24 changes: 24 additions & 0 deletions spec/classes/menu/clock_format_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require 'spec_helper'

describe 'osx::menu::clock_format' do
let(:facts) { {:boxen_user => 'ilikebees'} }

it do
should contain_boxen__osx_defaults('Set clock format').with_value('EEE d MMM h:mm a')
end

describe 'with parameters' do
let(:params) { {:format => 'h:mm a'} }

it 'allows you to pass a format' do
should contain_boxen__osx_defaults('Set clock format').with({
:user => facts[:boxen_user],
:key => 'DateFormat',
:domain => 'com.apple.menuextra.clock',
:value => 'h:mm a',
:type => 'string',
:notify => 'Exec[killall SystemUIServer]'
})
end
end
end