/linkHomeApps

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

linkHomeApps

Automatic Script that Links Apps from Home Folder to Root Applications Folder

For a couple of years, I have noticed that a few of my applications have been installed into an Applications folder in my home folder (~/Applications). While I am unsure why this is the case, it has caused me headaches as I am used to navigating directly to the main Applications folder to find all of my apps (/Applications). Furthermore and annoyingly, some of the apps were buried within folders! Using launchd and python, I made a script that will add soft links for each app buried within the home Applications folder to the root Applications folder automatically. A screenshot that shows home appplications folder side-by-side with the root applications folder

Installation

  1. Clone or download this repository. I used Homebrew to install Python 3.
  2. Copy the 'linkHomeApps.py' script to a folder that your user account has permissions to access. For example, one may store the file in ~/scripts.
  3. Create a user agent to watch the ~/Applications folder for changes. This can be done using Soma's LaunchControl gui application: A screenshot that shows user agent that watches home Applications folder for changes then fires the script.
  • Select 'User Agents' from the top left menu then add a new user agent (⌘ N). Name and label it appropriately.
  • In the "Program to run" text field, add /usr/local/bin/python3 "/Users/userName/scripts/linkHomeApps.py". Change userName to your local user name and adjust the path to match the location of the linkHomeApps.py script. If using a different Python 3 installation (or venv), adjust the path to the Python 3 binary.
  • Drag a "WatchPaths" from the pallet on the right side of the LaunchControl. Add the path to the Applications directory located within your home folder.
  • Save the user agent.
  • Right click on the file on the left side of the application then click "load".
  • The user agent should now begin watching for changes in the home applications directory.
  • For apps already installed within the home applications folder to appear in root Applications folder, the script will need to be run once manually. However, this and testing of the user agent may be accomplished simultaneously by running touch ~/Applications/test.app then rm -f ~/Applications/test.app from the terminal once the user agent has been created and loaded.
  1. If you want to use launchctl from the terminal instead of Soma's app, a sample plist has been included in the Github code. Apple has some great instructions on how to create and manage launch daemons and agents using the command line and plist files.