From: EdTheDev Date: Sat, 6 Jan 2024 16:56:16 +0000 (-0600) Subject: Stay Awake for Ubuntu X-Git-Url: https://us-delaporte.pagekite.me/gitweb/dotfiles.git/commitdiff_plain/e4567f96b7fa1173bf3d8bf286bdc1af5df240a3?ds=inline Stay Awake for Ubuntu --- diff --git a/psmodules/file_management.psm1 b/psmodules/file_management.psm1 index 3622885..945d484 100644 --- a/psmodules/file_management.psm1 +++ b/psmodules/file_management.psm1 @@ -46,7 +46,7 @@ Export-ModuleMember -Function Show-LargeFiles # Stay awake to allow large transfers to complete # without permanently giving up battery saving features -function Invoke-StayAwake() { +function Invoke-StayAwakeWindows() { param($minutes=90) $wsh = New-Object -ComObject WScript.Shell do{ @@ -59,4 +59,15 @@ function Invoke-StayAwake() { # Thank you to http://www.zhornsoftware.co.uk/caffeine/ } -Export-ModuleMember -Function Invoke-StayAwake \ No newline at end of file +Export-ModuleMember -Function Invoke-StayAwake +Export-ModuleMember -Function Invoke-StayAwakeWindows + +function Invoke-StayAwake() { + param($minutes=90) + do{ + "Staying awake for $minutes minutes" + systemd-inhibit sleep 60 + $minutes-=1; + }until($minutes -lt 0) +} + diff --git a/psmodules/stay_awake.psm1 b/psmodules/stay_awake.psm1 deleted file mode 100644 index 40bc896..0000000 --- a/psmodules/stay_awake.psm1 +++ /dev/null @@ -1,10 +0,0 @@ -param($minutes=90) -$wsh = New-Object -ComObject WScript.Shell -do{ - "Staying awake for $minutes minutes" - $minutes-=1; - # Send Shift+F15 - $wsh.SendKeys('+{F15}') - Start-Sleep -seconds 59 -}until($minutes -lt 0) -# Thank you to http://www.zhornsoftware.co.uk/caffeine/