Improve performance

This commit is contained in:
Manuel Thalmann 2024-09-08 17:41:30 +02:00
parent eae19dab1f
commit 4b09cd1f87
3 changed files with 24 additions and 49 deletions

View file

@ -458,21 +458,6 @@ $null = New-Module {
Set-SetupOption $finishedOption $true; Set-SetupOption $finishedOption $true;
} }
<#
.SYNOPSIS
Checks whether the specified software collection is enabled.
.PARAMETER Name
The name of the collection to check.
#>
function Test-Collection {
param(
[string] $Name
)
Get-Config "$(Get-ConfigRootName).software.$Name";
}
<# <#
.SYNOPSIS .SYNOPSIS
Checks whether the running system is a QEMU virtual machine. Checks whether the running system is a QEMU virtual machine.

View file

@ -28,20 +28,7 @@ $null = New-Module {
$configArgs = @("--system"); $configArgs = @("--system");
} }
<# $config = Get-Config "$root.git";
.SYNOPSIS
Gets the specified git configuration.
.PARAMETER Name
THe name of the configuration to get.
#>
function Get-GitConfig {
param(
[string] $Name
)
Get-Config "$root.git.$Name";
}
<# <#
.SYNOPSIS .SYNOPSIS
@ -52,7 +39,7 @@ $null = New-Module {
} }
if ((-not $IsWindows) -or $User) { if ((-not $IsWindows) -or $User) {
$branch = Get-GitConfig "defaultBranch"; $branch = $config.defaultBranch;
if ($branch) { if ($branch) {
Set-GitConfig "init.defaultBranch" $branch; Set-GitConfig "init.defaultBranch" $branch;
@ -76,8 +63,8 @@ $null = New-Module {
. { . {
$dir = New-TemporaryDirectory; $dir = New-TemporaryDirectory;
$key = "flow"; $key = "flow";
$mainBranch = Get-GitConfig "$key.mainBranch"; $mainBranch = $config."$key".mainBranch;
$devBranch = Get-GitConfig "$key.devBranch"; $devBranch = $config."$key".devBranch;
& { & {
git -C "$dir" init; git -C "$dir" init;
@ -103,7 +90,7 @@ $null = New-Module {
}; };
# Aliases # Aliases
[PSCustomObject] $aliases = Get-GitConfig "aliases"; [PSCustomObject] $aliases = $config.aliases;
if ($aliases) { if ($aliases) {
foreach ($alias in ($aliases | Get-Member -MemberType Properties)) { foreach ($alias in ($aliases | Get-Member -MemberType Properties)) {

View file

@ -24,13 +24,16 @@ function Deploy-SoftwareAction {
$install = $true; $install = $true;
} }
$hardware = Get-Config "valhalla.hardware";
$collections = Get-Config "valhalla.windows.software";
# Drivers # Drivers
& { & {
$driverPath = "$PSScriptRoot/../Drivers"; $driverPath = "$PSScriptRoot/../Drivers";
$mbPath = "$driverPath/ROG Zenith Extreme Alpha"; $mbPath = "$driverPath/ROG Zenith Extreme Alpha";
if ($install) { if ($install) {
if (Get-Config "valhalla.hardware.elgatoWave") { if ($hardware.elgatoWave) {
if (-not (Test-ChocoPackage wavelink)) { if (-not (Test-ChocoPackage wavelink)) {
Install-ChocoPackage wavelink -ArgumentList '--install-arguments="/norestart"'; Install-ChocoPackage wavelink -ArgumentList '--install-arguments="/norestart"';
Remove-DesktopIcon "*Wave Link*"; Remove-DesktopIcon "*Wave Link*";
@ -40,7 +43,7 @@ function Deploy-SoftwareAction {
} }
} }
foreach ($component in (Get-Config "valhalla.hardware.components")) { foreach ($component in $hardware.components) {
switcH ($component) { switcH ($component) {
("ROG Zenith Extreme Alpha") { ("ROG Zenith Extreme Alpha") {
& "$mbPath/MarvellEthernet/Manage.ps1" @arguments; & "$mbPath/MarvellEthernet/Manage.ps1" @arguments;
@ -56,22 +59,22 @@ function Deploy-SoftwareAction {
} }
if ($install) { if ($install) {
if (Get-Config "valhalla.hardware.amdCPU") { if ($hardware.amdCPU) {
Install-ChocoPackage amd-ryzen-master; Install-ChocoPackage amd-ryzen-master;
# ToDo: backup Ryzen energy saving plan # ToDo: backup Ryzen energy saving plan
} }
if (Get-Config "valhalla.hardware.nvidiaGPU") { if ($hardware.nvidiaGPU) {
Install-ChocoPackage geforce-game-ready-driver; Install-ChocoPackage geforce-game-ready-driver;
Remove-DesktopIcon "*Geforce*"; Remove-DesktopIcon "*Geforce*";
} }
if (Get-Config "valhalla.hardware.corsairDevice") { if ($hardware.corsairDevice) {
Install-ChocoPackage icue; Install-ChocoPackage icue;
} }
} }
if (Get-Config "valhalla.hardware.eyeX") { if ($hardware.eyeX) {
& "$driverPath/Tobii EyeX/Manage.ps1" @arguments; & "$driverPath/Tobii EyeX/Manage.ps1" @arguments;
} }
}; };
@ -83,12 +86,12 @@ function Deploy-SoftwareAction {
# Windows Config # Windows Config
& "$softwarePath/Windows/Manage.ps1" @arguments; & "$softwarePath/Windows/Manage.ps1" @arguments;
if (Get-Config "valhalla.hardware.logitechG") { if ($hardware.logitechG) {
& "$softwarePath/LGHub/Manage.ps1" @arguments; & "$softwarePath/LGHub/Manage.ps1" @arguments;
} }
# Essentials # Essentials
if (Test-Collection "essential") { if ($collections.essential) {
& "$softwarePath/aliae/Main.ps1" @arguments; & "$softwarePath/aliae/Main.ps1" @arguments;
& "$softwarePath/git/Manage.ps1" @arguments; & "$softwarePath/git/Manage.ps1" @arguments;
& "$softwarePath/OpenSSH/Manage.ps1" @arguments; & "$softwarePath/OpenSSH/Manage.ps1" @arguments;
@ -116,7 +119,7 @@ function Deploy-SoftwareAction {
} }
# Common Software # Common Software
if (Test-Collection "common") { if ($collections.common) {
& "$softwarePath/WinSCP/Manage.ps1" @arguments; & "$softwarePath/WinSCP/Manage.ps1" @arguments;
& "$softwarePath/Thunderbird/Manage.ps1" @arguments; & "$softwarePath/Thunderbird/Manage.ps1" @arguments;
& "$softwarePath/PuTTY/Manage.ps1" @arguments; & "$softwarePath/PuTTY/Manage.ps1" @arguments;
@ -138,7 +141,7 @@ function Deploy-SoftwareAction {
} }
} }
if (Test-Collection "desktopExperience") { if ($collections.desktopExperience) {
if ($install) { if ($install) {
# Fonts # Fonts
Install-ChocoPackage nerd-fonts-CascadiaCode; Install-ChocoPackage nerd-fonts-CascadiaCode;
@ -171,7 +174,7 @@ function Deploy-SoftwareAction {
Remove-DesktopIcon "GIMP*"; Remove-DesktopIcon "GIMP*";
Remove-DesktopIcon "GPU-Z*"; Remove-DesktopIcon "GPU-Z*";
Remove-DesktopIcon "WinDirStat*"; Remove-DesktopIcon "WinDirStat*";
Remove-DesktopIcon "*HWMonior*"; Remove-DesktopIcon "*HWMonitor*";
Remove-DesktopIcon "ImgBurn*"; Remove-DesktopIcon "ImgBurn*";
Remove-DesktopIcon "InkScape*"; Remove-DesktopIcon "InkScape*";
Remove-DesktopIcon "Krita*"; Remove-DesktopIcon "Krita*";
@ -193,12 +196,12 @@ function Deploy-SoftwareAction {
& "$softwarePath/Firefox/Manage.ps1" @arguments; & "$softwarePath/Firefox/Manage.ps1" @arguments;
& "$softwarePath/MSEdgeRedirect/Manage.ps1" @arguments; & "$softwarePath/MSEdgeRedirect/Manage.ps1" @arguments;
if (Test-Collection "fileSync") { if ($collections.fileSync) {
& "$softwarePath/Nextcloud/Main.ps1" @arguments; & "$softwarePath/Nextcloud/Main.ps1" @arguments;
} }
} }
if (Test-Collection "socialMedia") { if ($collections.socialMedia) {
if ($install) { if ($install) {
Install-ChocoPackage ` Install-ChocoPackage `
signal ` signal `
@ -215,7 +218,7 @@ function Deploy-SoftwareAction {
} }
} }
if (Test-Collection "media") { if ($collections.media) {
if ($install) { if ($install) {
Install-ChocoPackage ` Install-ChocoPackage `
k-litecodecpackmega ` k-litecodecpackmega `
@ -231,7 +234,7 @@ function Deploy-SoftwareAction {
} }
} }
if (Test-Collection "coding") { if ($collections.coding) {
if ($install) { if ($install) {
Install-ChocoPackage ` Install-ChocoPackage `
@ -257,7 +260,7 @@ function Deploy-SoftwareAction {
} }
# Gaming # Gaming
if (Test-Collection "gaming") { if ($collections.gaming) {
if ($install) { if ($install) {
Install-ChocoPackage ` Install-ChocoPackage `
goggalaxy ` goggalaxy `