From dafbf2974eaa1aafb903280cca5c7e91ac1ba2c9 Mon Sep 17 00:00:00 2001 From: jbergner Date: Tue, 16 Dec 2025 22:16:14 +0100 Subject: [PATCH] RC-1 --- main.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index e329d8c..37a6353 100644 --- a/main.go +++ b/main.go @@ -15,6 +15,8 @@ import ( "time" ) +const appUserModelID = "de.stadthilden.GoSysNotifyAgent" + type Notification struct { ID int64 `json:"id"` CreatedAt time.Time `json:"created_at"` @@ -29,6 +31,7 @@ var ( ) func main() { + if v := os.Getenv("SERVICE_URL"); v != "" { serviceURL = strings.TrimRight(v, "/") } @@ -149,12 +152,15 @@ func showToast(title, message string) error { title = escapeXML(title) message = escapeXML(message) - psScript := fmt.Sprintf(` + psScript := ` [Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null [Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] > $null -# AppId von "Windows PowerShell" holen (oder erste gefundene App als Fallback) -$appid = (Get-StartApps | Where-Object Name -eq 'Windows PowerShell').AppId +# bevorzugt Windows Terminal, sonst Windows PowerShell, sonst erste App +$appid = (Get-StartApps | Where-Object Name -eq 'Windows Terminal').AppId +if (-not $appid) { + $appid = (Get-StartApps | Where-Object Name -eq 'Windows PowerShell').AppId +} if (-not $appid) { $appid = (Get-StartApps | Select-Object -First 1).AppId } @@ -163,8 +169,8 @@ $xmlString = @" - %s - %s + ` + title + ` + ` + message + ` @@ -176,7 +182,7 @@ $xml.LoadXml($xmlString) $notifier = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($appid) $toast = [Windows.UI.Notifications.ToastNotification]::new($xml) $notifier.Show($toast) -`, title, message) +` cmd := exec.Command("powershell", "-NoProfile", "-NonInteractive", "-Command", psScript) out, err := cmd.CombinedOutput()