-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathstatus_notification.ps1
More file actions
executable file
·93 lines (71 loc) · 2.8 KB
/
status_notification.ps1
File metadata and controls
executable file
·93 lines (71 loc) · 2.8 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# Monitors changes in activity status and send notification when it changes
#
# Works on: Windows with Powershell
# If you have permission issues running, see:
# https://stackoverflow.com/a/62403405/10232
#
# Created by Mike Chambers
# https://www.mikechambers.com
#
# Released under an MIT License
# More info at:
# https://github.com/mikechambers/dcli/
#
# Requires dclia v0.1.1
################ Script configuration #################
$default_check_interval_seconds=15
#only check if Destiny process is running. Set to $false
#if you want it to check regardless of whether Destiny is running
#on the same machine
$only_check_if_destiny_running = $true
#whether it should print out status and other output to console
$quiet=$false
#pull setting from environment variables. you can also
#just enter them here
#you can get member_id and platform by running dclis
$member_id=$env:MEMBER_ID
$platform=$env:PLATFORM
#run dclim to sync manifest before running this script
############# program #############
$old_activity=""
while ($true) {
$check_interval_seconds = $default_check_interval_seconds
#check if Destiny is running and whether we should skip check if its not running
$should_check = (Get-Process destiny2 -ErrorAction SilentlyContinue) -or !$only_check_if_destiny_running
if ($should_check) {
if (!$quiet) {
Write-Output "Checking Status..."
}
# assumes dclia is in your path
$activity = (dclia --name mesh#3230) -join "`n"
$skip_notification = (($activity -eq "Not currently in an activity") -or ($activity -eq "Currently sitting in Orbit"))
#dont send notification the first time we run
if($old_activity -eq "") {
if (!$quiet) {
Write-Output $activity
Write-Output "Initial status check. Skipping notification."
}
$skip_notification = $true
$old_activity = $activity
}
if ( ($old_activity -ne $activity) -and !$skip_notification)
{
[void] [reflection.assembly]::loadwithpartialname("System.Windows.Forms")
[void] [reflection.assembly]::loadwithpartialname("System.Drawing")
$notify = new-object system.windows.forms.notifyicon
$notify.icon = [System.Drawing.SystemIcons]::Information
$notify.visible = $true
$notify.showballoontip(10,"Destiny 2 Activity Changed",$activity,[system.windows.forms.tooltipicon]::None)
if (!$quiet) {
Write-Output $activity
}
$old_activity = $activity
$check_interval_seconds = 60
}
} else {
if (!$quiet) {
Write-Output "Destiny 2 is not running. Skipping status check."
}
}
Start-Sleep -Seconds $check_interval_seconds
}