1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-08-08 04:20:07 +02:00

👌 Make user-supplied apps available (#73)

This commit is contained in:
2022-01-04 00:20:47 +01:00
parent 9ef184331e
commit 7f320897be
4 changed files with 22 additions and 2 deletions

View File

@ -246,6 +246,16 @@ The supported apps are: <i>PhpStorm, Visual Studio Code, Sublime Text, Sublime M
All of these apps should just be detected correctly, no matter their location on your system. If you can open it using `open -a "appname"`, the app should be detected and work. If you have renamed the app, there might be an issue getting it detected. All of these apps should just be detected correctly, no matter their location on your system. If you can open it using `open -a "appname"`, the app should be detected and work. If you have renamed the app, there might be an issue getting it detected.
To see which files are checked to determine availability, see [this file](./phpmon/Domain/Helpers/Application.swift). To see which files are checked to determine availability, see [this file](./phpmon/Domain/Helpers/Application.swift).
You can add your own apps by creating and editing a `~/.phpmon.conf.json` file, with the following entry:
<code>
{
"scan_apps": ["Xcode", "Kraken"]
}
</code>
You can put as many apps as you'd like in the `scan_apps` array, and PHP Monitor will check for the existence of these apps. You do not need to set the full path, just the name of the app should work. Not all apps support opening a folder, though, so your success might vary.
</details> </details>
<details> <details>

View File

@ -14,7 +14,7 @@ import Foundation
class Application { class Application {
enum AppType { enum AppType {
case editor, browser, git_gui, terminal case editor, browser, git_gui, terminal, user_supplied
} }
/// Name of the app. Used for display purposes and to determine `name.app` exists. /// Name of the app. Used for display purposes and to determine `name.app` exists.

View File

@ -51,9 +51,15 @@ extension MainMenu {
Log.info("Setting up watchers...") Log.info("Setting up watchers...")
App.shared.handlePhpConfigWatcher() App.shared.handlePhpConfigWatcher()
// Detect applications (preset + custom)
Log.info("Detecting applications...") Log.info("Detecting applications...")
// Attempt to load list of applications
App.shared.detectedApplications = Application.detectPresetApplications() App.shared.detectedApplications = Application.detectPresetApplications()
let customApps = Preferences.custom.scanApps.map { appName in
return Application(appName, .user_supplied)
}.filter { app in
return app.isInstalled()
}
App.shared.detectedApplications.append(contentsOf: customApps)
let appNames = App.shared.detectedApplications.map { app in let appNames = App.shared.detectedApplications.map { app in
return app.name return app.name
} }

View File

@ -76,6 +76,10 @@ class Preferences {
return Self.shared.cachedPreferences return Self.shared.cachedPreferences
} }
static var custom: CustomPrefs {
return Self.shared.customPreferences
}
/** /**
Determine whether a particular preference is enabled. Determine whether a particular preference is enabled.
- Important: Requires the preference to have a corresponding boolean value, or a fatal error will be thrown. - Important: Requires the preference to have a corresponding boolean value, or a fatal error will be thrown.