#Mejorar el autocompletado con TAB en PowerShell

if (!(Test-Path $PROFILE.AllUsersAllHosts)) {
New-Item -ItemType File -Path $PROFILE.AllUsersAllHosts -Force
}

Add-Content $PROFILE.AllUsersAllHosts 'Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete'

#Descargar archivos de personalización


$zip = "https://archlinux.tail9bd2a9.ts.net/Scripts/Win-Tux/Extras/zip"

$dir = "C:\Windows\Setup"

$dir2 = "C:\Windows\Setup\Extras"

mkdir $dir\Extras

mkdir $dir2\Imagenes

mkdir $dir2\KDE

wget -O $dir2\Imagenes\Imagenes.zip $zip/Imagenes.zip

unzip.exe -o $dir2\Imagenes\Imagenes.zip -d $dir2\Imagenes

rm $dir2\Imagenes\Imagenes.zip

wget -O $dir2\KDE\KDE.zip $zip/KDE.zip

unzip.exe -o $dir2\KDE\KDE.zip -d $dir2\KDE

rm $dir2\KDE\KDE.zip


#Cambiar fondo de pantalla

reg add "HKCU\Control Panel\Desktop" /v Wallpaper /t REG_SZ /d "$dir2\Imagenes\ScarletTree.png" /f
reg add "HKCU\Control Panel\Desktop" /v WallpaperStyle /t REG_SZ /d 10 /f
reg add "HKCU\Control Panel\Desktop" /v TileWallpaper /t REG_SZ /d 0 /f
RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters

#Cambiar el fondo de bloqueo

New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization" -Force | Out-Null

Set-ItemProperty `
-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization" `
-Name "LockScreenImage" `
-Value "$dir2\Imagenes\FallenLeaf.jpg"

#Cambiar Cursores por los de KDE Plasma

$cursorPath = "$dir2\KDE"

reg add "HKCU\Control Panel\Cursors" /v Arrow /t REG_SZ /d "$cursorPath\default.cur" /f
reg add "HKCU\Control Panel\Cursors" /v Help /t REG_SZ /d "$cursorPath\help.cur" /f
reg add "HKCU\Control Panel\Cursors" /v AppStarting /t REG_SZ /d "$cursorPath\wait.ani" /f
reg add "HKCU\Control Panel\Cursors" /v Wait /t REG_SZ /d "$cursorPath\wait.ani" /f
reg add "HKCU\Control Panel\Cursors" /v IBeam /t REG_SZ /d "$cursorPath\text.cur" /f
reg add "HKCU\Control Panel\Cursors" /v Crosshair /t REG_SZ /d "$cursorPath\crosshair.cur" /f
reg add "HKCU\Control Panel\Cursors" /v SizeWE /t REG_SZ /d "$cursorPath\size_hor.cur" /f
reg add "HKCU\Control Panel\Cursors" /v SizeNS /t REG_SZ /d "$cursorPath\size_ver.cur" /f
reg add "HKCU\Control Panel\Cursors" /v SizeNWSE /t REG_SZ /d "$cursorPath\size_fdiag.cur" /f
reg add "HKCU\Control Panel\Cursors" /v SizeNESW /t REG_SZ /d "$cursorPath\size_bdiag.cur" /f
reg add "HKCU\Control Panel\Cursors" /v Hand /t REG_SZ /d "$cursorPath\pointer.cur" /f

RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters

#Cambiar la foto de perfil del usuario por Konqi

$User = "$env:USERPROFILE"
$ImagePath = "$dir2\Imagenes\Mascot_konqi-dev-kde.png"

$DestinationFolder = "C:\ProgramData\Microsoft\User Account Pictures"
$DestinationPath = Join-Path $DestinationFolder "$User.png"

Copy-Item $ImagePath $DestinationPath -Force

reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\AccountPicture\Users\$((whoami /user /fo csv | ConvertFrom-Csv).SID)" `
/v Image192 /t REG_SZ /d $DestinationPath /f

#Activar compresión de memoria RAM.

Enable-MMAgent -MemoryCompression

#Instalación de dependencias y Winget

scoop install extras/vcredist
scoop install winget

#Descargar DirectX en el directorio temporal

$zipUrl = "https://specifics-warranty-cricket-image.trycloudflare.com/Scripts/Win-Tux/ps1-Main/Dependencias/DirectX.zip"
$zipPath = "$env:TEMP\DirectX.zip"

curl.exe -k --http1.1 -L $zipUrl -o $zipPath

#Descomprimir el ZIP en el mismo directorio

Expand-Archive -Path $zipPath -DestinationPath $env:TEMP -Force

#Ejecutar el instalador de DirectX

$exePath = Join-Path $env:TEMP "DXSETUP.exe"
Start-Process -FilePath $exePath -ArgumentList "/silent" -Wait


winget --version

winget list --accept-source-agreements

winget upgrade --all

Clear-Host

fastfetch

#Limpieza de Scoop

rm "$env:USERPROFILE\scoop\cache\*"


#Eliminar el directorio de DirectX ya usado

$temp = "$env:USERPROFILE\AppData\Local\Temp"

rm $temp\*.dll
rm $temp\*.cab
rm $temp\DXSETUP.exe
rm $temp\*.zip

#Descargar el Manager y eliminar el Setup

$dir3 = "$env:USERPROFILE\Desktop"
$link = "https://archlinux.tail9bd2a9.ts.net/BootStraps/exe"

wget -O $dir3\Win-Tux-Manager.exe $link/Win-Tux-Manager.exe

rm $dir3\Win-Tux-Setup.exe

#Interacción final del usuario

Write-Host "Presione S para terminar la Instalacion..."

do {
$key = [System.Console]::ReadKey($true)
} until ($key.Key -eq "S")

shutdown /l
