From fbb382e1e8ce9fe78bc765e1ac54b9c7020f091b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 23 Jun 2025 13:49:54 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Signed-off-by: Oskar Manhart <52569953+oskardotglobal@users.noreply.github.com> --- bin/winapps | 16 ++++++++-------- oem/TimeSync.ps1 | 4 ++-- oem/install.bat | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/bin/winapps b/bin/winapps index 6d12a2d..01a8bf0 100755 --- a/bin/winapps +++ b/bin/winapps @@ -648,7 +648,7 @@ function waCheckIdle() { fi } -# Name: 'waTimeSync' +# Name: 'waTimeSync' # Role: Detect if system went to sleep by comparing uptime progression, then sync time in Windows VM function waTimeSync() { local CURRENT_TIME=$(date +%s) @@ -657,31 +657,31 @@ function waTimeSync() { local STORED_UPTIME=0 local EXPECTED_UPTIME=0 local UPTIME_DIFF=0 - + # Read stored values if file exists if [ -f "$SLEEP_DETECT_PATH" ]; then STORED_TIME=$(head -n1 "$SLEEP_DETECT_PATH" 2>/dev/null || echo 0) STORED_UPTIME=$(tail -n1 "$SLEEP_DETECT_PATH" 2>/dev/null || echo 0) fi - + if [ "$STORED_TIME" -gt 0 ] && [ "$STORED_UPTIME" -gt 0 ]; then # Calculate what uptime should be now EXPECTED_UPTIME=$((STORED_UPTIME + CURRENT_TIME - STORED_TIME)) UPTIME_DIFF=$((EXPECTED_UPTIME - CURRENT_UPTIME)) - + dprint "UPTIME_DIFF: ${UPTIME_DIFF} seconds" - + # If uptime is significantly less than expected, system likely slept if [[ "$UPTIME_DIFF" -gt 30 && ! -f "$SLEEP_MARKER" ]]; then dprint "DETECTED SLEEP/WAKE CYCLE (uptime gap: ${UPTIME_DIFF}s). CREATING SLEEP MARKER TO SYNC WINDOWS TIME." - + # Create sleep marker which will be monitored by Windows VM to trigger time sync touch "$SLEEP_MARKER" - + dprint "CREATED SLEEP MARKER" fi fi - + # Store current values { echo "$CURRENT_TIME" diff --git a/oem/TimeSync.ps1 b/oem/TimeSync.ps1 index 8541d09..3f475c9 100644 --- a/oem/TimeSync.ps1 +++ b/oem/TimeSync.ps1 @@ -14,7 +14,7 @@ function Monitor-File { if (Test-Path -Path $filePath) { # Run time resync silently w32tm /resync /quiet - + # Remove the file Remove-Item -Path $filePath -Force } @@ -22,7 +22,7 @@ function Monitor-File { catch { # Network location not available, continue monitoring silently } - + # Wait 5 minutes before next check Start-Sleep -Seconds 3000 } diff --git a/oem/install.bat b/oem/install.bat index 9a1b208..4281a1c 100644 --- a/oem/install.bat +++ b/oem/install.bat @@ -31,9 +31,9 @@ set "command2=powershell.exe -WindowStyle Hidden -ExecutionPolicy Bypass -File \ schtasks /query /tn "%taskname2%" >nul if %ERRORLEVEL% equ 0 ( - echo %DATE% %TIME% Task "%taskname2%" already exists, skipping creation. + echo %DATE% %TIME% Task "%taskname2%" already exists, skipping creation. ) else ( - schtasks /create /tn "%taskname2%" /tr "%command2%" /sc onlogon /rl HIGHEST /f + schtasks /create /tn "%taskname2%" /tr "%command2%" /sc onlogon /rl HIGHEST /f if %ERRORLEVEL% equ 0 ( echo %DATE% %TIME% Scheduled task "%taskname2%" created successfully. ) else (