Last active
December 13, 2024 19:24
-
-
Save rogeruiz/9ad7a5c565f5b2faa98bd1c50deea05f to your computer and use it in GitHub Desktop.
Es útil pa' cambiar varias configuraciones de varias aplicaciones usando PowerShell.
This file contains hidden or 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
$luna = [char]::ConvertFromUtf32(0x1F31D) | |
$sol = [char]::ConvertFromUtf32(0x1F31E) | |
$murcielago = [char]::ConvertFromUtf32(0x1F987) | |
$nota = [char]::ConvertFromUtf32(0x1F4DD) | |
$cohete = [char]::ConvertFromUtf32(0x1F680) | |
$concha = [char]::ConvertFromUtf32(0x1F41A) | |
$error = [char]::ConvertFromUtf32(0x274C) | |
$marco = [char]::ConvertFromUtf32(0x1F5BC) | |
$exito = [char]::ConvertFromUtf32(0x2705) | |
function Set-DesktopWallpaper { | |
param( | |
[Parameter(Mandatory=$true)] | |
[string]$PicturePath, | |
[ValidateSet('Tiled', 'Centered', 'Stretched', 'Fill', 'Fit', 'Span')] | |
[string]$Style = 'Fill' | |
) | |
$definition = @" | |
[DllImport("user32.dll", CharSet=CharSet.Auto)] | |
public static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni); | |
"@ | |
Add-Type -MemberDefinition $definition -Name "Win32" -Namespace "Win32Functions" | |
$SPIF_UPDATEINIFILE = 0x01 | |
$SPIF_SENDCHANGE = 0x02 | |
$SPI_SETDESKWALLPAPER = 0x14 | |
$styles = @{ | |
'Tiled' = 0 | |
'Centered' = 0 | |
'Stretched' = 2 | |
'Fill' = 10 | |
'Fit' = 6 | |
'Span' = 22 | |
} | |
$tileWallpaper = @{ | |
'Tiled' = 1 | |
'Centered' = 0 | |
'Stretched' = 0 | |
'Fill' = 0 | |
'Fit' = 0 | |
'Span' = 0 | |
} | |
Set-ItemProperty -Path 'HKCU:\Control Panel\Desktop' -Name WallpaperStyle -Value $styles[$Style] | |
Set-ItemProperty -Path 'HKCU:\Control Panel\Desktop' -Name TileWallpaper -Value $tileWallpaper[$Style] | |
[Win32Functions.Win32]::SystemParametersInfo($SPI_SETDESKWALLPAPER, 0, $PicturePath, $SPIF_UPDATEINIFILE -bor $SPIF_SENDCHANGE) *>$null | |
Write-Output "$exito Fondo cambiado con éxito $marco" | |
} | |
$llave = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize" | |
if ('light' -eq $args[0]) | |
{ | |
Set-ItemProperty -Path $llave -Name SystemUsesLightTheme -Value 1 | |
Set-ItemProperty -Path $llave -Name AppsUseLightTheme -Value 1 | |
} | |
elseif ('dark' -eq $args[0]) | |
{ | |
Set-ItemProperty -Path $llave -Name SystemUsesLightTheme -Value 0 | |
Set-ItemProperty -Path $llave -Name AppsUseLightTheme -Value 0 | |
} | |
$modo = (Get-ItemProperty -Path $llave).SystemUsesLightTheme -bxor 1 | |
$nvim_cfn = 'C:\Users\xvo5\AppData\Local\nvim\init.lua' | |
$nvim_guia = '(vim.o.background = )' + "'" + '.+' + "'" | |
$starship_cfn = 'C:\Users\xvo5\.config\starship.toml' | |
$starship_guia = '(palette = )".+"' | |
$pwsh_cfn = 'C:\Users\xvo5\OneDrive - CDC\PowerShell\Microsoft.PowerShell_profile.ps1' | |
$pwsh_guia = '(\$Flavor = \$Catppuccin)' + "\['.+'\]" | |
$pwsh_vs22_cfn = 'C:\Users\xvo5\OneDrive - CDC\WindowsPowerShell\Microsoft.PowerShell_profile.ps1' | |
$pwsh_vs22_guia = '(\$Flavor = \$Catppuccin)' + "\['.+'\]" | |
$terminal_cfn = 'C:\Users\xvo5\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json' | |
$terminal_guia = '("colorScheme": "Catppuccin) ' + '.+' + '(")' | |
$bat_cfn = 'C:\Users\xvo5\AppData\Roaming\bat\config' | |
$bat_guia = '(--theme=gruvbox-).+' | |
if (0 -eq $modo) | |
{ | |
Write-Output "$sol Estamos en el modo de luz" | |
$sabor = 'latte' | |
$modo = 'light' | |
$icono = $sol | |
$fondo = 'C:\Users\xvo5\OneDrive - CDC\Customization\harmony-latte.png' | |
} | |
elseif (1 -eq $modo) | |
{ | |
Write-Output "$luna Estamos en el modo oscuro" | |
$sabor = 'mocha' | |
$modo = 'dark' | |
$icono = $luna | |
$fondo = 'C:\Users\xvo5\OneDrive - CDC\Customization\harmony-mocha.png' | |
} | |
else | |
{ | |
Write-Output "$error No se pudo establecer el tema" | |
Exit 1 | |
} | |
$sabor_titulo = (Get-Culture).TextInfo.ToTitleCase($sabor) | |
$modo_titulo = (Get-Culture).TextInfo.ToTitleCase($modo) | |
Write-Output "$icono Cambiando modo de la aplicación Bat $murcielago" | |
(Get-Content $bat_cfn) | % ` | |
{ $_-replace $bat_guia, ('$1' + $modo) } | | |
Set-Content $bat_cfn -Force | |
bat $bat_cfn -r 1:2 | |
Write-Output "$icono Cambiando modo de la aplicación Terminal $concha" | |
(Get-Content $terminal_cfn) | % ` | |
{ $_-replace $terminal_guia, ('$1 ' + $sabor_titulo + '$2') } | | |
Set-Content $terminal_cfn -Force | |
bat $terminal_cfn -r 55:57 | |
Write-Output "$icono Cambiando modo de la aplicación Neovim $nota" | |
(Get-Content $nvim_cfn) | % ` | |
{ $_-replace $nvim_guia, ('$1' + "'" + $modo + "'") } | | |
Set-Content $nvim_cfn -Force | |
bat $nvim_cfn -r 899:901 | |
Write-Output "$icono Cambiando modo de la aplicación Starship $cohete" | |
(Get-Content $starship_cfn) | % ` | |
{ $_-replace $starship_guia, ('$1' + '"' + $modo + '"') } | | |
Set-Content $starship_cfn -Force | |
bat $starship_cfn -r 7:9 | |
Write-Output "$icono Cambiando modo de la aplicación PowerShell $concha" | |
(Get-Content $pwsh_cfn) | % ` | |
{ $_-replace $pwsh_guia, ('$1' + "['" + $sabor_titulo + "']") } | | |
Set-Content $pwsh_cfn -Force | |
bat $pwsh_cfn -r 16:18 | |
Write-Output "$icono Cambiando modo de la aplicación Windows PowerShell $concha" | |
(Get-Content $pwsh_vs22_cfn) | % ` | |
{ $_-replace $pwsh_vs22_guia, ('$1' + "['" + $sabor_titulo + "']") } | | |
Set-Content $pwsh_vs22_cfn -Force | |
bat $pwsh_vs22_cfn -r 13:15 | |
Write-Output "$icono Cambiando el fondo de la pantalla $marco" | |
Set-DesktopWallpaper -PicturePath $fondo -Style Fill | |
. $PROFILE | |
# Recargar la ruta de mi usario | |
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment