Merge branch 'main' of https://github.com/iminet/DarkMode into main
This commit is contained in:
		
							
								
								
									
										50
									
								
								DarkMode.ps1
									
									
									
									
									
								
							
							
						
						
									
										50
									
								
								DarkMode.ps1
									
									
									
									
									
								
							@@ -1,3 +1,4 @@
 | 
			
		||||
<<<<<<< HEAD
 | 
			
		||||
##############################################################################
 | 
			
		||||
# DARKMODE POWERSHELL SCRIPT
 | 
			
		||||
# The easiest way to set dark/light theme or switch between of those
 | 
			
		||||
@@ -45,4 +46,53 @@ function Toggle
 | 
			
		||||
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" } ) }
 | 
			
		||||
=======
 | 
			
		||||
##############################################################################
 | 
			
		||||
# 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" } ) }
 | 
			
		||||
>>>>>>> 345d11e52f667be4e06c990f35c19b3143d8e82c
 | 
			
		||||
else { Toggle }
 | 
			
		||||
							
								
								
									
										34
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										34
									
								
								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
 | 
			
		||||
```
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user