Files
tooling/windows-setup.org

234 lines
8.6 KiB
Org Mode

# -*- ii: ii; -*-
#+TITLE: Windows 10 Setup
#+AUTHOR: James Blair
#+EMAIL: mail@jamesblair.net
#+DATE: <2020-09-26 Sat 06:45>
* Install windows subsystem for linux
To get underway we need to enable [[https://docs.microsoft.com/en-us/windows/wsl/install-win10][WSL2]]. This requires a 64bit installation of Windows 10 professional, build 18362 or higher.
#+NAME: Enable the wsl features
#+BEGIN_SRC shell
# The vritual machine platform optional feature is required for wsl2
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
# Once the virtual machine platform is enabled we can enable wsl2
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
#+END_SRC
Once the wsl feature is enabled it is recommended to update the linux kernel package for wsl2.
*Note:* Before proceeding with the installation of WSL 2, you will need to have CPU virtualisation enabled on your machine. Depending on your CPU architecture this may involve updating your bios settings:
- For AMD CPUs, you will look for a feature called: "AMD (AMD Secure Virtual Machine, AMD SVM)"
- For Intel CPUs, you will look for a feature called: "Intel (Intel Virtualization Technology, Intel VT-x)"
Finally, for AMD CPUs you may need to update [[https://www.reddit.com/r/AMDHelp/comments/d4l462/enabling_svm_on_laptop_leads_to_black_boot_screen/][UMA Framebuffer size]] to auto.
#+NAME: Update the linux kernel
#+BEGIN_SRC shell
# Download the update
powershell.exe curl.exe -L -o $env:TEMP\wsl_update_x64.msi https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
# Install the update automatically
Start-Process msiexec.exe -Wait -ArgumentList '/I $env:TEMP\wsl_update_x64.msi /quiet'
#+END_SRC
Before we install a specific distribution of wsl we need to set the default version of wsl to version 2.
*Note:* you may need to reboot your machine before this command will complete successfully.
#+NAME: Set default wsl version
#+BEGIN_SRC
powershell.exe wsl --set-default-version 2
#+END_SRC
After enabling the wsl feature we need to download the distribution installer and open it.
For my tooling setup I currently use the Ubuntu distribution after historically preferring Debian. The reason for the shift is the native apt installation for an up to date ~emacs~ installation available in Ubuntu.
#+NAME: Download and run the ubuntu installer
#+BEGIN_SRC shell
# Download the appx package for ubuntu distribution.
powershell.exe curl.exe -L -o $env:TEMP\ubuntu.appx https://aka.ms/wslubuntu2004
# Install the appx package
powershell.exe Add-AppxPackage $env:TEMP\ubuntu.appx
#+END_SRC
*Note:* If you encounter an error while adding the package, I have needed to use the ~wsreset~ command in the past to first reset the windows store application.
After the installer runs we need to manually enter a username and password for the unix account that wsl will use.
You can use the following command to verify the distribution and version you now have installed ~powershell.exe wsl --list --verbose~.
* Install an x server for wsl
One of the ways we extend standard wsl functionality is installing an x server on windows to allow graphical applications to be run.
This has the added benefit of allowing command line clipboard tools like [[https://github.com/astrand/xclip][xclip]] to be used within wsl.
The x server I've found to be rock solid for this purpose is [[https://sourceforge.net/projects/vcxsrv/][VcXsrv]]. Which is also open source.
#+NAME: Download and install VcXsrv
#+BEGIN_SRC shell
# Download the vcxsrv installer
powershell.exe curl.exe -L -o $env:TEMP\installer.exe https://sourceforge.net/projects/vcxsrv/files/latest/download
# Install vcxsrv
powershell.exe $env:TEMP\installer.exe
#+END_SRC
After following through the installer we want to ensure VcXsrv launches at startup with our desired configuration.
To achieve this we can add an xlaunch configuration which is just xml with a fancy extension to our machines startup folder.
#+NAME: Apply our VcXsrv configuration
#+BEGIN_SRC shell
cd /mnt/c/ProgramData/Microsoft/Windows/Start\ Menu/Programs/Startup
cat > VcXsrv.xlaunch << EOF
<?xml version="1.0" encoding="UTF-8"?>
<XLaunch WindowMode="MultiWindow" ClientMode="NoClient" LocalClient="False" Display="-1" LocalProgram="xcalc" RemoteProgram="xterm" RemotePassword="" PrivateKey="" RemoteHost="" RemoteUser="" XDMCPHost="" XDMCPBroadcast="False" XDMCPIndirect="False" Clipboard="True" ClipboardPrimary="True" ExtraParams="" Wgl="True" DisableAC="True" XDMCPTerminate="False"/>
EOF
cmd.exe /c VcXsrv.xlaunch
#+END_SRC
* Configure windows ten
Enable all tray icons to be visible and restart explorer
#+NAME: Configure tray icons
#+BEGIN_SRC shell
# Ensure all tray icons are visible
powershell.exe Set-ItemProperty HKLM:\SOFTWARE\Micorosoft\Windows\CurrentVersion\Explorer EnableAutoTray 0
# Restart explorer
powershell.exe ps explorer | kill
#+END_SRC
Additionally I normally take the following actions:
** Update taskbar layout
I normally take the following steps immediately for a new installtion, I have not found an easy way of automating this as yet:
- Hide the search box.
- Hide the task view button.
- Unpin all but explorer.
** Update start menu layout
I prefer to have no pinned "tiles" in my start menu. The script below will unpin all applications from start.
*Note:* In subsequent versions of Windows 10 this script seems to fail so I am back to doing this manually for now...
#+begin_src shell
powershell.exe -NoLogo
(New-Object -Com Shell.Application).
NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').
Items() |
%{ $_.Verbs() } |
?{$_.Name -match 'Un.*pin from Start'} |
%{$_.DoIt()}
#+end_src
** Lock screen configuration
I prefer a simple lock screen with no clutter so normally take the following steps:
- Untick show tips
- Set background to be picture and use in folder
- Remove status detailed or otherwise for apps on lock screen
** Fix inactive window title colors
One of the annoyances I have in windows ten is after setting a title bar color for windows as part of standard theming any inactive windows have an awful white glare instead of retaining that color. Thankfully there is a [[ https://winaero.com/blog/change-color-of-inactive-title-bars-in-windows-10][registry tweak]] we can do to fix this.
#+NAME: Configure inactive window title color
#+BEGIN_SRC shell
powershell.exe Set-ItemProperty HKCU:\SOFTWARE\Micorosoft\Windows\DWM AccentColorInactive ff484a4c
#+END_SRC
* Configure a web browser
My current browser of choice is [[https://www.mozilla.org/en-US/firefox/new/][Firefox]]. This is primarily due to their respect for open source, user privacy and security and customisation.
#+NAME: Download and run firefox installer
#+begin_src shell
# Download the firefox installer
powershell.exe curl.exe -L -o $env:TEMP\firefox.exe https://download.mozilla.org/?product=firefox
# Launch the installer
#env:TEMP\firefox.exe
#+end_src
One of the customisations we apply is to update the color of the newtab page in firefox to match the rest of the theme we use and prevent white glare. To achieve this we use [[https://superuser.com/questions/1235975/change-firefox-new-tab-background#][usercss]].
Note there is an about:config setting that needs to be set to enable these stylesheets to be used ~toolkit.legacyUserProfileCustomizations.stylesheets~
#+NAME: Configure usercss
#+begin_src shell
cd /c/Users/$USER/AppData/Roaming/Mozilla/Firefox/Profiles/[Default Profile]/chrome/
cat > userContent.css << EOF
/* https://userstyles.org/styles/90565/firefox-adjust-white-flash-when-opening-new-tab */
/* https://userstyles.org/styles/142191/remove-new-tab-flash */
@-moz-document url-prefix(about:preferences), url-prefix(about:blank), url-prefix(about:newtab) {
html, body, #newtab-customize-overlay {
background: #323232 !important;
color: #b2b2b2 !important;
}
}
@-moz-document url(chrome://browser/content/browser.xul)
{
browser[type="content-primary"]
{
background: #323232 !important;
color: #b2b2b2 !important;
}
}
@-moz-document url(chrome://browser/content/browser.xul)
{
browser[type="content-primary"], tabbrowser tabpanels, #appcontent > #content
{
background: #1B1B1B url("chrome://global/skin/media/imagedoc-darknoise.png") repeat fixed !important;
color: #b2b2b2 !important;
}
}
@-moz-document url(about:blank),
url(about:preferences),
url(about:config),
url(about:newtab)
{
#newtab-window,
html,
body,
#newtab-customize-overlay
{
background: #1B1B1B url("chrome://global/skin/media/imagedoc-darknoise.png") repeat fixed;
color: #b2b2b2 !important;
}
}
EOF
#+end_src