Suggestion: Include Login Items in AppSweep

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Suggestion: Include Login Items in AppSweep Sat Mar 13, 2010 6:41 pm • by nixta
When you delete an application that's in Login Items, Mac OS X isn't smart enough to remove it from Login Items on the next login (that's perhaps a good thing, come to think of it).

Would AppSweeper be able to include Login Items in the list of things it checks and clears up?

Incidentally, I have AppZapper but no longer use it since I tried Hazel's AppSweep. Great stuff!

Nick.
nixta
 
Posts: 9
Joined: Tue Mar 09, 2010 9:11 pm

Re: Suggestion: Include Login Items in AppSweep Tue Mar 16, 2010 12:52 pm • by holigen
I don't know if Noodlesoft will implement this feature, but until they do, you can use this rule attached to your Trash folder.

The trash folder is in ~/.Trash, or the folder named .Trash in your home folder. You can add this folder to Hazel by pressing Cmd+Shift+G in Hazel's open folder dialog box when you're adding a folder and then typing in "~/.Trash" without the quotes.

The corresponding rule will match any file that has an extension of app (to workaround a bug that I think is in the current version of Hazel) and, upon matching, run an AppleScript. The contents of the embedded script are as follows:

Code: Select all
try
   tell application "System Events"
      set theLoginItem to (every login item whose path is (POSIX path of theFile))
      
      if (length of theLoginItem) is greater than 0 then
         tell application "HazelHelper" to display dialog "Would you like to remove the login item for " & (do shell script "basename " & (POSIX path of theFile)) & "?" with icon 1 with title "Hazel"
         delete first item of theLoginItem
      end if
   end tell
end try


Whenever this rule matches an application that has a login item attached to it, it will ask you if you want to remove that login item. If you confirm, then the corresponding login item will be removed.
holigen
 
Posts: 18
Joined: Tue Mar 16, 2010 2:43 am

Re: Suggestion: Include Login Items in AppSweep Tue Mar 16, 2010 1:03 pm • by nixta
holigen wrote:I don't know if Noodlesoft will implement this feature, but until they do, you can use this rule attached to your Trash folder.

The trash folder is in ~/.Trash, or the folder named .Trash in your home folder. You can add this folder to Hazel by pressing Cmd+Shift+G in Hazel's open folder dialog box when you're adding a folder and then typing in "~/.Trash" without the quotes.

The corresponding rule will match any file that has an extension of app (to workaround a bug that I think is in the current version of Hazel) and, upon matching, run an AppleScript. The contents of the embedded script are as follows:

Code: Select all
try
   tell application "System Events"
      set theLoginItem to (every login item whose path is (POSIX path of theFile))
      
      if (length of theLoginItem) is greater than 0 then
         tell application "HazelHelper" to display dialog "Would you like to remove the login item for " & (do shell script "basename " & (POSIX path of theFile)) & "?" with icon 1 with title "Hazel"
         delete first item of theLoginItem
      end if
   end tell
end try


Whenever this rule matches an application that has a login item attached to it, it will ask you if you want to remove that login item. If you confirm, then the corresponding login item will be removed.

Nice! Clever stuff. And some good Mac OS hints too. Thank you.

My only thought (though it barely matters) is that it doesn't couple the removal of the Login Item with Hazel's removal of the app's resources. I think this script works well on its own - perhaps as a Folder Action.

Which makes me realise that actually mine is maybe a slightly silly request in the first place. Unless Hazel places something like a .hazelLoginItem in the trash which it can then restore if you reinstall the app's resources later it doesn't fit the Trash paradigm.
nixta
 
Posts: 9
Joined: Tue Mar 09, 2010 9:11 pm

nixta wrote:I think this script works well on its own - perhaps as a Folder Action.


Actually, yeah, it would make a much better Folder Action than a rule in Hazel.

nixta wrote:Unless Hazel places something like a .hazelLoginItem in the trash which it can then restore if you reinstall the app's resources later it doesn't fit the Trash paradigm.


You're probably right. Now that I think about it, I doubt that this feature will be implemented in Hazel directly, unless it's implemented as an extra step in the AppSweep process. Perhaps it could ask to remove the login item when the Trash is being emptied since, technically, the link to the application after it's been moved to the Trash is still preserved by the login item in System Preferences.
holigen
 
Posts: 18
Joined: Tue Mar 16, 2010 2:43 am

Re: Suggestion: Include Login Items in AppSweep Tue Mar 16, 2010 5:19 pm • by nixta
Now that I think about it, I doubt that this feature will be implemented in Hazel directly, unless it's implemented as an extra step in the AppSweep process. Perhaps it could ask to remove the login item when the Trash is being emptied since, technically, the link to the application after it's been moved to the Trash is still preserved by the login item in System Preferences.

Indeed. Well, I have a solution that should work for me, and the thought is now out there, so we'll leave it to Mr. Noodle now, I guess.

Thanks for the sample script. I know next to nothing about scripting under Mac OS and tend to end up writing bash scripts when I do try to automate something (I know, I know). It's on my list of things to learn one day... Your example is very helpful - I can see a bunch of things in there that it would have taken me hours to work out.
nixta
 
Posts: 9
Joined: Tue Mar 09, 2010 9:11 pm

I thought I had this entered in the bug/feature database but I can't find it so entering it now. Thanks for the report and holigen, thanks for the script and your help in the other threads as well.
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support