{"id":15644869,"url":"https://github.com/arendruni/location-switch","last_synced_at":"2025-04-13T17:35:38.036Z","repository":{"id":99119500,"uuid":"181164788","full_name":"arendruni/location-switch","owner":"arendruni","description":"Automatic network location switcher","archived":false,"fork":false,"pushed_at":"2024-11-21T20:19:41.000Z","size":21,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-12-08T05:26:56.831Z","etag":null,"topics":["launchagent","launchd","macos","wifi"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arendruni.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-13T12:02:44.000Z","updated_at":"2024-11-21T20:19:45.000Z","dependencies_parsed_at":"2024-10-23T06:26:32.648Z","dependency_job_id":null,"html_url":"https://github.com/arendruni/location-switch","commit_stats":{"total_commits":20,"total_committers":2,"mean_commits":10.0,"dds":0.35,"last_synced_commit":"f5dee10e79021780ff5a689936ee4d9b87c57a7f"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arendruni%2Flocation-switch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arendruni%2Flocation-switch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arendruni%2Flocation-switch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arendruni%2Flocation-switch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arendruni","download_url":"https://codeload.github.com/arendruni/location-switch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229073185,"owners_count":18015807,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["launchagent","launchd","macos","wifi"],"created_at":"2024-10-03T12:03:02.604Z","updated_at":"2024-12-10T14:08:02.108Z","avatar_url":"https://github.com/arendruni.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Network Location Switch\n\nThis bash script is designed to change the network location on a Mac based on the matching MAC address or SSID of a known network location. This can be useful if you frequently switch between different networks with different settings.\n\nThe script works by comparing the MAC address or SSID of the currently connected network to a list of known MAC addresses or SSIDs. If there is a match, the script changes the network location to the corresponding predefined location. If there is no match, the script changes the network location default location.\n\nFor more information on creating and using network locations on macOS, you can refer to the official Apple support document: [Use network locations on Mac](https://support.apple.com/en-us/HT202480).\n\n## Compatibility\n\nThis script is intended to be used on macOS 10.15 (Catalina) or later. It may not work on older versions of macOS.\n\nPlease ensure that your system meets the minimum requirements before attempting to run this script. If you encounter any issues, please let me know and I will do my best to assist you.\n\n## Usage\n\nTo use this script, you will need to change the following variables at the beginning of the script:\n\n- `DEFAULT_LOCATION` - the name of the default network location\n- `KNOWN_LOCATIONS` - a list of known MAC addresses or SSIDs and their corresponding network locations\n\n### `KNOWN_LOCATIONS` Format\n\nThe `KNOWN_LOCATIONS` array is a list of items that represent known locations in the format of MAC addresses and SSIDs. Each item in the array consists of three parts:\n\nA prefix to indicate whether the item is a MAC address or an SSID.\nThe MAC address or SSID value.\nA name for the location.\nThe prefix and value are separated by a colon (\":\") character. The name is separated from the value by another colon.\n\nNote that the name for the location is required and must be provided for each item in the array.\n\nExample:\n\n```bash\nKNOWN_LOCATIONS=(\n  \"m:00:11:22:33:44:55:Home\"\n  \"s:MyWiFiSSID:Office\"\n)\n```\n\n#### MAC Address Format\n\nMAC address items have the prefix \"m\". The value of a MAC address item is a standard MAC address string consisting of six colon-separated pairs of hexadecimal digits. The name of the location follows the MAC address value and is separated by a colon. Example: `m:00:11:22:33:44:55:Home`\n\n#### SSID Format\n\nSSID items have the prefix \"s\". The value of an SSID item is a string representing the name of a WiFi network. The name of the location follows the SSID value and is separated by a colon. Example: `s:MyWiFiSSID:Office`\n\n\n## Demonizing the Script on macOS\n\nTo run this script as a background process on macOS, you can use the `launchd` system. Here's a template `launchd` configuration file you can use:\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003c!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"\u003e\n\u003cplist version=\"1.0\"\u003e\n  \u003cdict\u003e\n    \u003ckey\u003eLabel\u003c/key\u003e\n    \u003cstring\u003eio.giun.dev.location-switch\u003c/string\u003e\n    \u003ckey\u003eProgramArguments\u003c/key\u003e\n    \u003carray\u003e\n      \u003cstring\u003e/path/to/location-switch.sh\u003c/string\u003e\n      \u003cstring\u003e-v\u003c/string\u003e\n    \u003c/array\u003e\n    \u003ckey\u003eStartInterval\u003c/key\u003e\n    \u003cinteger\u003e10\u003c/integer\u003e\n    \u003ckey\u003eRunAtLoad\u003c/key\u003e\n    \u003ctrue /\u003e\n    \u003ckey\u003eLowPriorityIO\u003c/key\u003e\n    \u003ctrue /\u003e\n    \u003ckey\u003eStandardOutPath\u003c/key\u003e\n    \u003cstring\u003e/path/to/location-switch/output.log\u003c/string\u003e\n    \u003ckey\u003eStandardErrorPath\u003c/key\u003e\n    \u003cstring\u003e/path/to/location-switch/error.log\u003c/string\u003e\n  \u003c/dict\u003e\n\u003c/plist\u003e\n```\n\nEdit the example file `io.giun.dev.location-switch.template.plist` to make sure to replace `/path/to/location-switch.sh` with the actual path to your script.\n\nTo load the `launchd` configuration, run the following command:\n\n```shell\n$ launchctl load io.giun.dev.location-switch.plist\n```\n\nThis will start the script and run it every 10 seconds. You can view the script output in the log file specified in the configuration file. To stop the script, unload the `launchd` configuration with the following command:\n\n```shell\n$ launchctl unload io.giun.dev.location-switch.plist\n```\n\nMove the `.plist` file to the `~/Library/LaunchAgents` to launch the agent at startup.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farendruni%2Flocation-switch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farendruni%2Flocation-switch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farendruni%2Flocation-switch/lists"}