From 8cf544d54fe7065259a7c307859c853fdf8de221 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Sat, 21 May 2016 16:47:57 -0700 Subject: [PATCH] Associate .torrent files to WebTorrent Desktop (OS X) (#553) Before this change, .torrent files would only be associated to WebTorrent Desktop if another torrent client (like Transmission) was installed on the system. That's because one of the user's apps needs to define "UTExportedTypeDeclarations". On a fresh machine, without Transmission, WebTorrent Desktop now associates .torrent files correctly. So it will appear in the "Open With..." menu and the webtorrent .torrent icon will be used for .torrent files. Closes #542. --- bin/package.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/bin/package.js b/bin/package.js index 2fa97387..3dede2f1 100755 --- a/bin/package.js +++ b/bin/package.js @@ -182,8 +182,6 @@ function buildDarwin (cb) { var infoPlistPath = path.join(contentsPath, 'Info.plist') var infoPlist = plist.parse(fs.readFileSync(infoPlistPath, 'utf8')) - // TODO: Use new `extend-info` and `extra-resource` opts to electron-packager, - // available as of v6. infoPlist.CFBundleDocumentTypes = [ { CFBundleTypeExtensions: [ 'torrent' ], @@ -211,6 +209,25 @@ function buildDarwin (cb) { } ] + infoPlist.UTExportedTypeDeclarations = [ + { + UTTypeConformsTo: [ + 'public.data', + 'public.item', + 'com.bittorrent.torrent' + ], + UTTypeDescription: 'BitTorrent Document', + UTTypeIconFile: path.basename(config.APP_FILE_ICON) + '.icns', + UTTypeIdentifier: 'org.bittorrent.torrent', + UTTypeReferenceURL: 'http://www.bittorrent.org/beps/bep_0000.html', + UTTypeTagSpecification: { + 'com.apple.ostype': 'TORR', + 'public.filename-extension': [ 'torrent' ], + 'public.mime-type': 'application/x-bittorrent' + } + } + ] + fs.writeFileSync(infoPlistPath, plist.build(infoPlist)) // Copy torrent file icon into app bundle