From a04f5db39a0f94eb0abed6cdcc5bc93bf0ec8afa Mon Sep 17 00:00:00 2001 From: eylenburg <84839316+eylenburg@users.noreply.github.com> Date: Mon, 23 Jun 2025 14:39:49 +0100 Subject: [PATCH] Create TimeSync.ps1 Signed-off-by: Oskar Manhart <52569953+oskardotglobal@users.noreply.github.com> --- oem/TimeSync.ps1 | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 oem/TimeSync.ps1 diff --git a/oem/TimeSync.ps1 b/oem/TimeSync.ps1 new file mode 100644 index 0000000..8541d09 --- /dev/null +++ b/oem/TimeSync.ps1 @@ -0,0 +1,32 @@ +# Script to monitor if there is a sleep_marker created by WinApps (indicating the Linux host was suspended) in order to trigger a time sync as the time in the Windows VM will otherwise drift while Linux is suspended. + +# Define the path to monitor. Make sure this matches the location for the sleep_marker in the Winapps script (need to match the APPDATA path). +$filePath = "\\tsclient\home\.local\share\linoffice\sleep_marker" +$networkPath = "\\tsclient\home" + +# Function to check and handle file +function Monitor-File { + while ($true) { + # Check if network location is available + try { + $null = Test-Path -Path $networkPath -ErrorAction Stop + # Check if file exists + if (Test-Path -Path $filePath) { + # Run time resync silently + w32tm /resync /quiet + + # Remove the file + Remove-Item -Path $filePath -Force + } + } + catch { + # Network location not available, continue monitoring silently + } + + # Wait 5 minutes before next check + Start-Sleep -Seconds 3000 + } +} + +# Start monitoring silently +Monitor-File