Skip to content

Commit 9ae09a9

Browse files
committed
Fixed detection and registering magnet URIs
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.
1 parent f98b1aa commit 9ae09a9

File tree

6 files changed

+11
-10
lines changed

6 files changed

+11
-10
lines changed

Applescript_Code.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ on open location this_URL
2727
end open location
2828
tell application "Finder" to set thisPath to (POSIX path of (application file id "org.deluge.MagnetURIHandler" as string))
2929
log thisPath
30-
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"
31-
if (check_default = "TRUE") then
30+
set lsToolRead to do shell script (quoted form of (thisPath & "/Contents/Resources/lstool") & " read url magnet")
31+
if (lsToolRead contains "Magnet Handler.app") then
3232
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")
3333
else
3434
try
@@ -39,9 +39,8 @@ Would you like to do this now?" buttons {"Yes", "No"} default button "Yes" cance
3939
end try
4040
try
4141
if button returned of dialogResult is "Yes" then
42-
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"
43-
log dutiPath
44-
do shell script dutiPath
42+
do shell script (quoted form of (thisPath & "/Contents/Resources/lstool") & " write url magnet org.deluge.MagnetURIHandler")
43+
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")
4544

4645
end if
4746
end try

Magnet Handler.app/Contents/Info.plist

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
<string>Magnet Handler</string>
1919
<key>CFBundlePackageType</key>
2020
<string>APPL</string>
21+
<key>CFBundleVersion</key>
22+
<string>1.1.0</string>
2123
<key>CFBundleShortVersionString</key>
22-
<string>1.0.2</string>
24+
<string>1.1.0</string>
2325
<key>CFBundleSignature</key>
2426
<string>aplt</string>
2527
<key>CFBundleURLTypes</key>
@@ -49,13 +51,13 @@
4951
<key>dividerCollapsed</key>
5052
<false/>
5153
<key>eventLogLevel</key>
52-
<integer>0</integer>
54+
<integer>2</integer>
5355
<key>name</key>
5456
<string>ScriptWindowState</string>
5557
<key>positionOfDivider</key>
56-
<real>421</real>
58+
<real>326</real>
5759
<key>savedFrame</key>
58-
<string>777 288 700 672 0 0 1920 1057 </string>
60+
<string>365 301 956 876 0 0 1920 1177 </string>
5961
<key>selectedTab</key>
6062
<string>log</string>
6163
</dict>
352 Bytes
Binary file not shown.
-29.3 KB
Binary file not shown.
296 KB
Binary file not shown.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33

44
# Instructions
55
1. ) Install to "Applications" folder.
6-
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.
6+
2. ) Run The application once by double-clicking it on the Finder, it should ask you to associate itself to magnet URIs.
77
3. ) Go to a browser and click on a magnet to test it.

0 commit comments

Comments
 (0)