From 3f4ff2dc367bd180483f1365d43542fc70681b6e Mon Sep 17 00:00:00 2001 From: Imi <27138272+iminet@users.noreply.github.com> Date: Wed, 21 Apr 2021 08:46:10 +0200 Subject: [PATCH 1/3] Initial release --- DarkMode.ps1 | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 DarkMode.ps1 diff --git a/DarkMode.ps1 b/DarkMode.ps1 new file mode 100644 index 0000000..f577774 --- /dev/null +++ b/DarkMode.ps1 @@ -0,0 +1,48 @@ +############################################################################## +# DARKMODE POWERSHELL SCRIPT +# The easiest way to set dark/light theme or switch between of those +# Prerequisites: PowerShell 5.0 or later +# Version: 1.0 +# Author: Iminetsoft +# GitHub: https://github.com/iminet/DarkMode +# License: CreativeCommons (CC BY 4.0) +# Usage: DarkMode.ps1 [status|dark|light|toggle] +# (without the optional switches, the toggle command will be performed) +############################################################################## + +$regkey = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize" +$property = "AppsUseLightTheme" +$darkvalue = 0 +$lightvalue = 1 +function SetDark +{ + Set-ItemProperty -Path $regkey -Name $property -Value $darkvalue +} + +function SetLight +{ + Set-ItemProperty -Path $regkey -Name $property -Value $lightvalue +} + +function IsDark +{ + if ($(Get-ItemPropertyValue -Path $regkey -Name $property) -eq $darkvalue) + { + return $true + } + else + { + return $false + } +} + +function Toggle +{ + if (IsDark -eq $true) { SetLight } + else { SetDark } +} + +if ($args.Count -ge 1 -and $args[0] -eq "dark") { SetDark } +elseif ($args.Count -ge 1 -and $args[0] -eq "light") { SetLight } +elseif ($args.Count -ge 1 -and $args[0] -eq "status") { Write-Host $(if (IsDark -eq $true) { "Dark theme" } else { "Light theme" } ) } +else { Toggle } \ No newline at end of file From c035dbb88b0124aea522ce2930df9f6ae60d6f89 Mon Sep 17 00:00:00 2001 From: Imi <27138272+iminet@users.noreply.github.com> Date: Wed, 21 Apr 2021 08:53:23 +0200 Subject: [PATCH 2/3] Update README.md --- README.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/README.md b/README.md index 604abe7..2c161b3 100644 --- a/README.md +++ b/README.md @@ -1 +1,35 @@ # DarkMode + +The easiest way to set dark/light theme or switch between of those + +## Prerequisites: +- Windows operating system +- PowerShell 5.0 or later +- +# License +Creative Commons (CC BY 4.0) + +# Usage: +``` +DarkMode.ps1 [status|dark|light|toggle] +#(without the optional switches, the toggle command will be performed) +``` + +## Examples +``` +# Check status +PS S:\> .\DarkMode.ps1 status +Light theme + +# Toggle (switch between light and dark) +PS S:\> .\DarkMode.ps1 toggle +# Or without arguments: +PS S:\> .\DarkMode.ps1 + +# Set dark theme +PS S:\> .\DarkMode.ps1 dark + + +# Set light theme +PS S:\> .\DarkMode.ps1 light +``` From 345d11e52f667be4e06c990f35c19b3143d8e82c Mon Sep 17 00:00:00 2001 From: Imi <27138272+iminet@users.noreply.github.com> Date: Wed, 21 Apr 2021 08:54:46 +0200 Subject: [PATCH 3/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2c161b3..e2eddbc 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ The easiest way to set dark/light theme or switch between of those ## Prerequisites: - Windows operating system - PowerShell 5.0 or later -- + # License Creative Commons (CC BY 4.0)