Skip to content

Commit

Permalink
Fixed detection and registering magnet URIs
Browse files Browse the repository at this point in the history
Replaced duti with lstool (originally found in RCDefaultApp by Rubicode, http://www.rubicode.com/Software/RCDefaultApp/) in order to make the whole process simpler, neater and more reliable.
  • Loading branch information
Lord-Kamina committed Feb 23, 2016
1 parent f98b1aa commit 9ae09a9
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
9 changes: 4 additions & 5 deletions Applescript_Code.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ on open location this_URL
end open location
tell application "Finder" to set thisPath to (POSIX path of (application file id "org.deluge.MagnetURIHandler" as string))
log thisPath
set check_default to do shell script "MAGNET_DEFAULT_APP=`VERSIONER_PERL_PREFER_32_BIT=1 perl -MMac::InternetConfig -le \"print +(GetICHelper 'magnet')[1]\"`; if [[ $MAGNET_DEFAULT_APP = 'Magnet Handler' ]]; then echo TRUE; else echo FALSE; fi"
if (check_default = "TRUE") then
set lsToolRead to do shell script (quoted form of (thisPath & "/Contents/Resources/lstool") & " read url magnet")
if (lsToolRead contains "Magnet Handler.app") then
display dialog "Magnet Handler is already the default application to handle magnet URIs" buttons {"OK"} with title "Notification" with icon POSIX file (thisPath & "/Contents/Resources/deluge_magnet.icns")
else
try
Expand All @@ -39,9 +39,8 @@ Would you like to do this now?" buttons {"Yes", "No"} default button "Yes" cance
end try
try
if button returned of dialogResult is "Yes" then
set dutiPath to quoted form of (thisPath & "/Contents/Resources/duti") & " -s org.deluge.MagnetURIHandler magnet all && /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain system -domain user"
log dutiPath
do shell script dutiPath
do shell script (quoted form of (thisPath & "/Contents/Resources/lstool") & " write url magnet org.deluge.MagnetURIHandler")
display dialog "Magnet Handler has now been configured as the default application to handle magnet URIs" buttons {"OK"} with title "Notification" with icon POSIX file (thisPath & "/Contents/Resources/deluge_magnet.icns")

end if
end try
Expand Down
10 changes: 6 additions & 4 deletions Magnet Handler.app/Contents/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
<string>Magnet Handler</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleVersion</key>
<string>1.1.0</string>
<key>CFBundleShortVersionString</key>
<string>1.0.2</string>
<string>1.1.0</string>
<key>CFBundleSignature</key>
<string>aplt</string>
<key>CFBundleURLTypes</key>
Expand Down Expand Up @@ -49,13 +51,13 @@
<key>dividerCollapsed</key>
<false/>
<key>eventLogLevel</key>
<integer>0</integer>
<integer>2</integer>
<key>name</key>
<string>ScriptWindowState</string>
<key>positionOfDivider</key>
<real>421</real>
<real>326</real>
<key>savedFrame</key>
<string>777 288 700 672 0 0 1920 1057 </string>
<string>365 301 956 876 0 0 1920 1177 </string>
<key>selectedTab</key>
<string>log</string>
</dict>
Expand Down
Binary file modified Magnet Handler.app/Contents/Resources/Scripts/main.scpt
Binary file not shown.
Binary file removed Magnet Handler.app/Contents/Resources/duti
Binary file not shown.
Binary file added Magnet Handler.app/Contents/Resources/lstool
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

# Instructions
1. ) Install to "Applications" folder.
2. ) Run The application once by double-clicking it on the Finder, it should ask you to associate itself to magnet URIs; this will take a a couple minutes while Launch Services are rebuilt; wait until application exits on its own. Running the application again should tell you it's already associated to magnet URIs.
2. ) Run The application once by double-clicking it on the Finder, it should ask you to associate itself to magnet URIs.
3. ) Go to a browser and click on a magnet to test it.

0 comments on commit 9ae09a9

Please sign in to comment.