2024-08-28 03:05:55 +00:00
|
|
|
& {
|
|
|
|
. "$PSScriptRoot/../../Scripts/Restoration.ps1";
|
2024-09-23 01:33:17 +00:00
|
|
|
. "$PSScriptRoot/../../Scripts/SoftwareManagement.ps1";
|
2024-08-28 03:05:55 +00:00
|
|
|
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
|
|
|
$configPath = "$env:LocalAppData/LGHUB";
|
2024-08-08 11:25:21 +00:00
|
|
|
|
2024-08-28 03:05:55 +00:00
|
|
|
<#
|
|
|
|
.SYNOPSIS
|
|
|
|
Stops the running Logitech G Hub instance.
|
|
|
|
#>
|
|
|
|
function Stop-LGHub {
|
|
|
|
[OutputType([string])]
|
|
|
|
param()
|
2024-08-08 11:25:21 +00:00
|
|
|
|
2024-08-28 03:05:55 +00:00
|
|
|
$hubName = "lghub_system_tray.exe";
|
|
|
|
|
|
|
|
$candidates = Get-Process | Where-Object { $_.Path -and ((Split-Path -Leaf $_.Path) -eq $hubName) };
|
|
|
|
|
|
|
|
if ($candidates.Count -gt 0) {
|
|
|
|
$lghubPath = $candidates[0].Path;
|
|
|
|
} else {
|
|
|
|
$lghubPath = $null;
|
|
|
|
}
|
|
|
|
|
|
|
|
$mainProcesses = Get-Process | Where-Object {
|
|
|
|
$_.Path -and
|
|
|
|
(@("lghub.exe", "lghub_agent.exe", "lghub_updater.exe", $hubName) -contains (Split-Path -Leaf $_.Path)) -and
|
|
|
|
(($_.Parent.ProcessName -eq "explorer") -or ($null -eq $_.Parent))
|
|
|
|
};
|
|
|
|
|
|
|
|
$null = $mainProcesses | ForEach-Object { $_.Kill($true) };
|
|
|
|
return $lghubPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
<#
|
|
|
|
.SYNOPSIS
|
|
|
|
Edits the Logitech G Hub configuration.
|
|
|
|
#>
|
|
|
|
function Edit-LGHubConfig {
|
|
|
|
param(
|
|
|
|
[scriptblock] $Action
|
|
|
|
)
|
|
|
|
|
|
|
|
Write-Host "Stopping Logitech G Hub";
|
|
|
|
$path = Stop-LGHub;
|
|
|
|
& $Action;
|
|
|
|
|
|
|
|
if ($path) {
|
|
|
|
Write-Host "Restarting Logitech G Hub";
|
|
|
|
Start-Process $path;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-30 03:00:20 +00:00
|
|
|
Start-SoftwareInstaller @args `
|
2024-08-28 03:05:55 +00:00
|
|
|
-Installer {
|
|
|
|
Install-ChocoPackage lghub;
|
|
|
|
Remove-DesktopIcon "*G HUB*";
|
|
|
|
} `
|
|
|
|
-UserBackup {
|
|
|
|
param(
|
2024-09-23 00:10:42 +00:00
|
|
|
[string] $Name,
|
2024-08-28 03:05:55 +00:00
|
|
|
[hashtable] $Arguments
|
|
|
|
)
|
|
|
|
|
|
|
|
Edit-LGHubConfig {
|
2024-09-23 00:10:42 +00:00
|
|
|
Add-BackupArtifacts -User $Arguments.Name -Source $configPath -Path "$Name" `
|
2024-08-28 03:05:55 +00:00
|
|
|
-Include @("settings.db", "icon_cache")
|
|
|
|
};
|
|
|
|
} `
|
|
|
|
-UserConfigurator {
|
|
|
|
param(
|
2024-09-23 00:10:42 +00:00
|
|
|
[string] $Name,
|
2024-08-28 03:05:55 +00:00
|
|
|
[hashtable] $Arguments
|
|
|
|
)
|
|
|
|
|
|
|
|
Edit-LGHubConfig {
|
2024-09-23 00:10:42 +00:00
|
|
|
Expand-BackupArtifacts -User $Arguments.Name -Path "$Name" -Target $configPath;
|
2024-08-28 03:05:55 +00:00
|
|
|
};
|
|
|
|
};
|
2024-09-30 03:00:20 +00:00
|
|
|
} @args;
|