Skip to content

Commit

Permalink
Remove need for RCDefaultApp
Browse files Browse the repository at this point in the history
Now, running the application on its own checks whether it's the default app for magnet URIs and prompts to associate itself if it isn't.
Readme updated accordingly.
  • Loading branch information
Lord-Kamina committed Feb 11, 2016
1 parent 343ac6f commit f98b1aa
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 7 deletions.
23 changes: 21 additions & 2 deletions Applescript_Code.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
--THIS IS THE APPLESCRIPT CODE

on quit
try
tell application "System Events" to tell process "Deluge"
Expand Down Expand Up @@ -27,4 +25,25 @@ on open location this_URL
do shell script (quoted form of (delugePath & "/Contents/MacOS/Deluge") & " add " & delugeArgument & "; return;")
quit
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
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
set dialogResult to display dialog "Magnet Handler has not been configured to handle magnet URIs.

Would you like to do this now?" buttons {"Yes", "No"} default button "Yes" cancel button "No" with title "Notification" with icon POSIX file (thisPath & "/Contents/Resources/deluge_magnet.icns")
on error number -128
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

end if
end try
end if
quit
2 changes: 1 addition & 1 deletion Magnet Handler.app/Contents/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<key>positionOfDivider</key>
<real>421</real>
<key>savedFrame</key>
<string>777 375 700 672 0 0 1920 1177 </string>
<string>777 288 700 672 0 0 1920 1057 </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.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{\rtf1\ansi\ansicpg1252\cocoartf1348\cocoasubrtf170
{\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf340
{\fonttbl}
{\colortbl;\red255\green255\blue255;}
}
Binary file added Magnet Handler.app/Contents/Resources/duti
Binary file not shown.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@

# Instructions
1. ) Install to "Applications" folder.
2. ) Run The application once.
3. ) Install RCDefaultApp (http://www.rubicode.com/Software/RCDefaultApp/) if you don't have it already, it's fantastical and incredibly useful anyway, and use it to associate Magnet URIs to the Magnet Handler app.
4. ) Go to a browser and click on a magnet to test it.
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.
3. ) Go to a browser and click on a magnet to test it.

0 comments on commit f98b1aa

Please sign in to comment.