-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.ps1
194 lines (169 loc) · 7.05 KB
/
install.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
if(!([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
# NOTE: im aware of '#Requires -RunAsAdministrator' instruction, but it does not work with Invoke Web Request.
throw "You must run this script as Administrator!"
}
# =====================
# * CONSTANTS *
# =====================
$temp = "$env:TEMP/files/"
$fontUrl = "https://github.com/ryanoasis/nerd-fonts/releases/latest/download/jetbrainsmono.zip"
$altGrUrl = "https://github.com/thomasfaingnaert/win-us-intl-altgr/releases/download/v1.0/us-inter.zip"
$repoUrl = "https://github.com/alanfzf/dotfiles/archive/main.zip"
New-Item -ItemType Directory -Path $temp -Force | Out-Null
# =====================
# * UTILITY FUNCTIONS *
# =====================
function DownloadAndDecompress {
param(
[String]$Url,
[Switch]$CreateFolder
)
$fileName = [System.IO.Path]::GetFileName($Url)
$fileNameNoExt = [System.IO.Path]::GetFileNameWithoutExtension($fileName)
$outFile = "$temp/$fileName"
$outFolder = "$temp/$fileNameNoExt"
curl.exe -Lo $outFile $Url
Expand-Archive $outFile -DestinationPath $outFolder -Force
if($CreateFolder){
# if there's a need to create a folder, we search in the temp directory
# otherwise we search the first folder inside the outFolder
# NOTE: this only works if extracted archives are single directory
$outFolder = $temp
}
return Get-ChildItem -Path $outFolder -Directory | Sort-Object CreationTime -Descending | Select-Object -First 1
}
function InstallFonts {
param ([String]$fontFolder)
$destFolder = (New-Object -ComObject Shell.Application).Namespace(0x14)
$foundFonts = Get-ChildItem -Path "$fontFolder/*" -Include '*.ttf','*.ttc','*.otf' -Recurse
$systemFontsPath = "$env:LOCALAPPDATA/Microsoft/Windows/Fonts"
foreach($fontFile in $foundFonts){
$fontDestPath = Join-Path $systemFontsPath $fontFile.Name
if(Test-Path -Path $fontDestPath){ continue }
$destFolder.CopyHere($fontFile.FullName, 0x14)
}
}
function CleanTemp {
Get-ChildItem -Path $temp -Force | ForEach-Object { $_ | Remove-Item -Force -Recurse -ErrorAction SilentlyContinue }
Stop-Process -ProcessName explorer
}
# =====================
# * SETUP FUNCTIONS *
# =====================
function InstallPrograms {
# **** INSTALL WINGET PACKAGES ****
$Packages = @(
"Microsoft.WindowsTerminal"
"7zip.7zip"
"Discord.Discord"
"VideoLAN.VLC"
"Microsoft.PowerToys"
)
foreach ($package in $packages) {
winget install -e --accept-source-agreements --accept-package-agreements --silent $package
}
# **** INSTALL NON WINGET STUFF ****
$fontFolder = DownloadAndDecompress $fontUrl -CreateFolder
InstallFonts $fontFolder.FullName
$altGrlFolder = DownloadAndDecompress $altGrUrl
$altGrlFolder = Join-Path $altGrlFolder.FullName "us-inter_amd64.msi"
Start-Process 'msiexec.exe' -ArgumentList "/i `"$altGrlFolder`" /passive"
}
function SetupDotFiles{
$repo = DownloadAndDecompress $repoUrl
$dotfiles = "$HOME/.dotfiles/"
Move-item -Path $repo.FullName -Destination $dotfiles
# WEIRD WINDOWS FUCKING PATHS
$wtPath = Get-ChildItem "$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_*" | Select-Object -First 1 -Expand FullName
$wtPath = "$wtPath/LocalState/"
$symLinks = @{
# realPath targetPath
"$wtPath" = "$dotfiles/.config/windows_terminal/"
}
foreach ($entry in $symLinks.GetEnumerator()) {
$symPath = $entry.Key
$symTarget = $entry.Value
Remove-Item -Path $symPath -Force -Recurse -ErrorAction SilentlyContinue
New-Item -ItemType SymbolicLink -Path $symPath -Target $symTarget -Force
}
}
function WindowsTweaks {
$RegPathCM = "HKCU:\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32"
$RegPathEx = "HKCU:\SOFTWARE\Policies\Microsoft\Windows\Explorer"
$RegPathTheme = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize"
$RegPathExCurrent = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer"
$RegPathDate = "HKCU:\Control Panel\International"
# **** UI Tweaks ****
# Activate old context menu
New-Item -Path $RegPathCM -Force | Out-Null
Set-ItemProperty -Path $RegPathCM -Name "(default)" -Value "" -Force
# Deactivate bing search
New-Item -Path $RegPathEx -Force | Out-Null
Set-ItemProperty -Path $RegPathEx -Name "DisableSearchBoxSuggestions" -Value 1
# Multitasking view disable multiple tabs
Set-ItemProperty -Path $RegPathEx -Name "MultiTaskingAltTabFilter" -Type Dword -Value "4"
# Hide frequent folders
Set-ItemProperty "$RegPathExCurrent" -Name ShowFrequent -Value 0
# Show file extensions
Set-ItemProperty "$RegPathExCurrent\Advanced" -Name HideFileExt -Value 0
# Enable dark mode
Set-ItemProperty -Path $RegPathTheme -Name "SystemUsesLightTheme" -Type DWord -Value 0
Set-ItemProperty -Path $RegPathTheme -Name "AppsUseLightTheme" -Type DWord -Value 0
# **** TASKBAR TWEAKS ****
# Remove task view from taskbar
Set-ItemProperty -Path "$RegPathExCurrent\Advanced" -Name "ShowTaskViewButton" -type "Dword" -Value "0"
# Remove chat from taskbar
Set-ItemProperty -Path "$RegPathExCurrent\Advanced" -Name "TaskbarMn" -type "Dword" -Value "0"
# Remove widgets from taskbar
Set-ItemProperty -Path "$RegPathExCurrent\Advanced" -Name "TaskbarDa" -type "Dword" -Value "0"
# Remove search from taskbar
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Search" -Name "SearchboxTaskbarMode" -type "Dword" -Value "0"
# Unpin taskbar icons
Set-ItemProperty -Path "$RegPathExCurrent\Taskband" -Name "Favorites" -Type Binary -Value ([byte[]](255))
Remove-ItemProperty -Path "$RegPathExCurrent\Taskband" -Name "FavoritesResolve" -ErrorAction SilentlyContinue
# **** DATE TWEAKS ****
Set-ItemProperty -Path $RegPathDate -Name sShortDate -Value "yyyy-MM-dd"
Set-ItemProperty -Path $RegPathDate -Name sShortTime -Value "HH:mm"
}
function RemovePrograms{
$MsCrap = @(
"Clipchamp.Clipchamp"
"Microsoft.BingFinance"
"Microsoft.BingNews"
"Microsoft.BingSports"
"Microsoft.BingWeather"
"Microsoft.GamingApp"
"Microsoft.GetHelp"
"Microsoft.MicrosoftOfficeHub"
"Microsoft.MicrosoftSolitaireCollection"
"Microsoft.MicrosoftStickyNotes"
"Microsoft.People"
"Microsoft.PowerAutomateDesktop"
"Microsoft.Todos"
"Microsoft.WindowsAlarms"
"Microsoft.WindowsFeedbackHub"
"Microsoft.WindowsMaps"
"Microsoft.WindowsNotepad"
"Microsoft.WindowsSoundRecorder"
"Microsoft.ZuneMusic"
"Microsoft.ZuneVideo"
"MicrosoftCorporationII.QuickAssist"
"MicrosoftTeams"
"getstarted"
"microsoft.windowscommunicationsapps"
)
foreach ($package in $MsCrap){
Get-AppxPackage -AllUsers "*$package*" | Remove-AppxPackage
Get-AppxProvisionedPackage -Online | Where-Object { $_.PackageName -Like "*$package*"} | ForEach-Object {
Remove-AppxProvisionedPackage -Online -PackageName $_.PackageName
}
}
}
# =====================
# DO THE SETUP
# =====================
InstallPrograms
SetupDotFiles
WindowsTweaks
RemovePrograms
CleanTemp