1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
#!/usr/bin/perl
#
# Copyright 2005-2019 The Mumble Developers. All rights reserved.
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file at the root of the
# Mumble source tree or at <https://www.mumble.info/LICENSE>.
#
# Generate a Mac OS X Finder .DS_Store file for use on the Mumble disk image.
#
#
# Notes:
#
# The use of binary plists inside the DS_Store seems to be new for the Finder in Mac OS X 10.6 (Snow Leopard),
# but we'll go with this for now. It falls back somewhat gracefully for older versions OS X, since the icons
# will still be placed in their correct positions.
#
use Data::Plist::BinaryWriter;
use Mac::Finder::DSStore::BuddyAllocator;
use Mac::Finder::DSStore;
use IO::File;
use strict;
my $plist = Data::Plist::BinaryWriter->new(serialize => 0);
my $bwsp = $plist->write([dict => {
"ShowPathbar" => [ false => 0 ],
"ShowSidebar" => [ false => 0 ],
"ShowStatusBar" => [ false => 0 ],
"ShowToolbar" => [ false => 0 ],
"SidebarWidth" => [ integer => 192 ],
"WindowBounds" => [ string => "{{388, 166}, {530, 525}}" ],
}]);
my $icvp = $plist->write([ dict => {
"arrangeBy" => [ string => "grid" ],
# these are floats [0, 1]
"backgroundColorBlue" => [ integer => 1 ],
"backgroundColorGreen" => [ integer => 1 ],
"backgroundColorRed" => [ integer => 1 ],
# a mac os alias record or the background image.
# fixme(mkrautz): add our pretty background. :)
"backgroundImageAlias" => [ data => "" ],
# background type. 1=color, 2=image
"backgroundType" => [ integer => 1 ],
"gridOffsetX" => [ integer => 0 ],
"gridOffsetY" => [ integer => 0 ],
"gridSpacing" => [ integer => 100 ],
"iconSize" => [ integer => 80 ],
"labelOnBottom" => [ true => 1 ],
"showIconPreview" => [ true => 1 ],
"showItemInfo" => [ false => 0 ],
"textSize" => [ integer => 12 ],
"viewOptionsVersion" => [ integer => 0 ],
}]);
my @entries = ();
# styling
my %styles = (
'bwsp' => $bwsp,
'icvp' => $icvp,
);
for my $key (keys %styles) {
my $e = Mac::Finder::DSStore::Entry->new(".", $key);
$e->value($styles{$key});
push(@entries, $e);
}
# file info
my %iconpos = (
"Mumble.app" => [ 54, 40 ],
"Applications" => [ 466, 40 ],
"ReadMe.txt" => [ 54, 416 ],
"Changes.txt" => [ 157, 416 ],
"Murmur Extras" => [ 363, 416 ],
"Licenses" => [ 466, 416 ],
);
for my $key (keys %iconpos) {
my $e = Mac::Finder::DSStore::Entry->new($key, 'Iloc');
$e->value(pack('NNnnnn', $iconpos{$key}[0], $iconpos{$key}[1], 65536, 65536, 65536, 65536, 0));
push(@entries, $e);
}
@entries = sort { $a->cmp($b) } @entries;
my $store = Mac::Finder::DSStore::BuddyAllocator->new(new IO::File "DS_Store", '>');
&Mac::Finder::DSStore::putDSDBEntries($store, \@entries);
$store->writeMetaData;
$store->close;
|