{"id":15037417,"url":"https://github.com/mandrigin/alfredswitchwindows","last_synced_at":"2025-04-09T07:06:10.478Z","repository":{"id":47727223,"uuid":"81984058","full_name":"mandrigin/AlfredSwitchWindows","owner":"mandrigin","description":"An application for using in Alfred workflow to enumerate and switch between windows on OSX.","archived":false,"fork":false,"pushed_at":"2022-07-21T07:53:26.000Z","size":9086,"stargazers_count":334,"open_issues_count":19,"forks_count":31,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-04-09T07:06:04.300Z","etag":null,"topics":["alfred3-workflow","macos","scriptingbridge","swift","swift3"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mandrigin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-14T20:04:58.000Z","updated_at":"2024-10-12T17:39:47.000Z","dependencies_parsed_at":"2022-09-06T23:21:28.172Z","dependency_job_id":null,"html_url":"https://github.com/mandrigin/AlfredSwitchWindows","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mandrigin%2FAlfredSwitchWindows","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mandrigin%2FAlfredSwitchWindows/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mandrigin%2FAlfredSwitchWindows/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mandrigin%2FAlfredSwitchWindows/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mandrigin","download_url":"https://codeload.github.com/mandrigin/AlfredSwitchWindows/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247994119,"owners_count":21030050,"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":["alfred3-workflow","macos","scriptingbridge","swift","swift3"],"created_at":"2024-09-24T20:34:35.495Z","updated_at":"2025-04-09T07:06:10.460Z","avatar_url":"https://github.com/mandrigin.png","language":"Swift","readme":"# Swift Windows Switcher\n\n## Catalina Users\n\nMake sure that Alfred is added to \"Security \u0026 Privacy -\u003e Screen Recording\".\nThe context on why that is needed is [here](https://github.com/mandrigin/AlfredSwitchWindows/issues/31).\n\n![](/catalina.png)\n\n## * * *\n\nMy little \"weekend\" project.\nAlfred workflow to switch between open windows in the system and Safari tabs.\n\n![](/demo_concise.gif)\n\n## Features\n- Switch between the open windows using Alfred\n- Switch between the Safari tabs using Alfred\n- Very quick comparing to the alternative implementations because of the native search implementation.\n\n## Releases\n\nYou can download the ready-to-use `.workflow` files from [the releases page](https://github.com/mandrigin/AlfredSwitchWindows/releases).\n\n## Source code\n\nYou can start exploring the source code at [main.swift](EnumWindows/main.swift)\n\n### `ScriptingBridge` in Swift\n\nIt turns out, that `ScriptingBridge` implementation is not fully compatible with Swift.\n\n(Classes like `SafariApplication` are not imported, so we can't use them).\n\nOne of the possible solutions to this issue is demonstrated in [BrowserApplication.swift](EnumWindows/BrowserApplication.swift)\n(used for both Safari and Chrome automation)\n\n**UPD:** There is a better solution using `optional` protocol methods:\n```swift\n@objc fileprivate enum PlayerState: NSInteger {\n    case stopped = 0x6b505353\n    case playing = 0x6b505350\n    case paused = 0x6b505370\n    case fastForwarding = 0x6b505346\n    case rewinding = 0x6b505352\n};\n\n@objc fileprivate protocol iTunesBridge {\n    @objc optional var isRunning: Bool { get }\n    @objc optional var playerState: PlayerState { get }\n    @objc optional func pause() -\u003e Void\n}\n\nextension SBApplication: iTunesBridge{}\n\nguard let app = SBApplication(bundleIdentifier: \"com.apple.iTunes\") as? iTunesBridge else {\n   return\n}\n\nlet isPlaying = app.playerState == .playing\n\nNSLog(\"isPlaying: \\(isPlaying)\")\n```\n\n## License\n\nCopyright 2017 © Igor Mandrigin\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmandrigin%2Falfredswitchwindows","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmandrigin%2Falfredswitchwindows","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmandrigin%2Falfredswitchwindows/lists"}