Last active
February 28, 2023 17:32
-
-
Save RichardBronosky/c61465ed897c2f10e9bf16704d1d9af9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# From: https://gist.github.com/RichardBronosky/c61465ed897c2f10e9bf16704d1d9af9 | |
# This works from both WSL/bash and powershell! | |
powershell.exe -command "& (Get-ItemProperty 'HKCU:Control Panel\Desktop').{SCRNSAVE.EXE}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Start-ScreenSaver | |
# Version: 1.1 | |
# From: https://lunaticexperiments.wordpress.com/2006/12/07/powershell-script-to-start-a-random-screen-saver/ | |
param ([String]$Include, [String]$Exclude) | |
#Avoid execution if a screen saver is already running | |
if (get-Process *.scr) { | |
return | |
} | |
#If filters are not provided default to user preference. | |
if ( -not $Include -and -not $Exclude) { | |
[String]$DefaultScreenSaver = (Get-ItemProperty 'HKCU:Control Panel\\Desktop').{SCRNSAVE.EXE} | |
if ($DefaultScreenSaver) { | |
& $DefaultScreenSaver | |
return | |
} | |
} | |
#Get a list of available screen savers and filter them. | |
[System.Management.Automation.ApplicationInfo[]]$ScreenSaverCommands = Get-Command *.scr -CommandType Application | | |
Where-Object { | |
$( | |
if ($Include) { $_.Name -like $Include -or $_.Name -eq $Include + '.scr' } | |
else {$true} | |
) -and | |
$( | |
if ($Exclude) { -not ( $_.Name -like $Exclude ) } | |
else {$true} | |
) | |
} | |
#Randomly choose a screen saver and execute it. | |
if ($ScreenSaverCommands) { | |
& $(($ScreenSaverCommands[$(New-Object System.Random).Next($ScreenSaverCommands.Length)]).Definition) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment