-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathMyWhooshMonitor.ps1
44 lines (35 loc) · 1.36 KB
/
MyWhooshMonitor.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Define the JSON config file path
$configFile = "$PSScriptRoot\mywhoosh_config.json"
$myWhooshApp = "myWhoosh Indoor Cycling App.app"
# Check if the JSON file exists and read the stored path
if (Test-Path $configFile) {
$config = Get-Content -Path $configFile | ConvertFrom-Json
$mywhooshPath = $config.path
} else {
$mywhooshPath = $null
}
# Validate the stored path
if (-not $mywhooshPath -or -not (Test-Path $mywhooshPath)) {
Write-Host "Searching for $myWhooshApp"
$mywhooshPath = Get-ChildItem -Path "/Applications" -Filter $myWhooshApp -Recurse -ErrorAction SilentlyContinue | Select-Object -First 1
if (-not $mywhooshPath) {
Write-Host " not found!"
exit 1
}
$mywhooshPath = $mywhooshPath.FullName
# Store the path in the JSON file
$config = @{ path = $mywhooshPath }
$config | ConvertTo-Json | Set-Content -Path $configFile
}
Write-Host "Found $myWhooshApp at $mywhooshPath"
# Start mywhoosh.exe
Start-Process -FilePath $mywhooshPath
# Wait for the application to finish
Write-Host "Waiting for $myWhooshApp to finish..."
while ($process = ps -ax | grep -i $myWhooshApp | grep -v "grep") {
Write-Output $process
Start-Sleep -Seconds 5
}
# Run the Python script
Write-Host "$myWhooshApp has finished, running Python script..."
python3 /Users/jayqueue/Development/Python/MyWhoosh2Garmin/myWhoosh2Garmin.py