-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglobal.ps1
60 lines (50 loc) · 1.74 KB
/
global.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
Import-Module -Name "$PSScriptRoot\..\common\common.psm1"
$plugin_name = "WindowsSearchNext"
$flowlauncher_exe_path="${env:USERPROFILE}\AppData\Local\FlowLauncher\Flow.Launcher.exe"
$flowlauncher_plugin_path="${env:USERPROFILE}\AppData\Roaming\FlowLauncher\Plugins"
$plugin_path="$flowlauncher_plugin_path\$plugin_name"
function install() {
$fl_procs=Get-Process | Where-Object { $_.ProcessName -like "*Flow.Launcher*" }
# if running, stop the flow launcher process (assumes at most one istance)
if ($fl_procs) {
Stop-Process -Id $fl_procs[0].Id
write-output "Flow launcher stopped"
}
if (test-path $plugin_path) {
remove-item $plugin_path -recurse -force
}
copy-item "$PSScriptRoot\bin\Debug" -recurse -destination $plugin_path
write-output "Plugin files deployed to Flow Launcher plugin dir"
# if stopped, then relaunch
if ($fl_procs) {
Start-Process -NoNewWindow $flowlauncher_exe_path
write-output "Flow Launcher restarted"
}
}
function uninstall() {
$fl_procs=Get-Process | Where-Object { $_.ProcessName -like "*Flow.Launcher*" }
# if running, stop the flow launcher process (assumes at most one istance)
if ($fl_procs) {
Stop-Process -Id $fl_procs[0].Id
write-output "Flow launcher stopped"
}
if (test-path $plugin_path) {
remove-item $plugin_path -recurse -force
write-output "Plugin removed from Flow Launcher plugins dir"
}
# if stopped, then relaunch
if ($fl_procs) {
Start-Process -NoNewWindow $flowlauncher_exe_path
write-output "Flow Launcher restarted"
}
}
if ($args.count -ne 1) {
write-error "Bad arguments. syntax: global [install|uninstall]"
exit 1
}
switch ($args[0].ToLower())
{
"install" { install }
"uninstall" { uninstall }
default { write-error "Bad arguments. syntax: global [install|uninstall]" }
}