Skip to content

Commit 59eeb4a

Browse files
committed
Initial swag at WSL support
1 parent 9efa0ad commit 59eeb4a

File tree

21 files changed

+150
-30
lines changed

21 files changed

+150
-30
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
*.retry
2+
.*.swp

.vscode/settings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
"*.retry": true
66
},
77
"files.associations": {
8-
"*.yaml": "ansible"
8+
"*.yaml": "ansible"
99
}
1010
}

alacritty/core.yaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
connection: local
44

55
tasks:
6+
- set_fact: is_wsl={{ lookup('file', '/proc/version') is search('microsoft') }}
7+
68
- name: Install Alacritty (Pop!_OS)
79
become: yes
810
apt:
911
package: alacritty
10-
when: "'Pop!_OS' in hostvars[inventory_hostname].ansible_facts.lsb.description"
12+
when: "not is_wsl and 'Pop!_OS' in hostvars[inventory_hostname].ansible_facts.lsb.description"
1113

1214
- name: Install Alacritty (Ubuntu)
1315
become: yes
1416
apt:
1517
deb: https://github.com/jwilm/alacritty/releases/download/v0.3.2/Alacritty-v0.3.2-ubuntu_18_04_amd64.deb
16-
when: "'Pop!_OS' not in hostvars[inventory_hostname].ansible_facts.lsb.description"
18+
when: "not is_wsl and 'Pop!_OS' not in hostvars[inventory_hostname].ansible_facts.lsb.description"

alacritty/customization.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
connection: local
44

55
tasks:
6+
- set_fact: is_wsl={{ lookup('file', '/proc/version') is search('microsoft') }}
7+
68
- name: Ensure Alacritty configuration folder exists
79
file:
810
path: ~/.config/alacritty
911
state: directory
12+
when: not is_wsl
1013

1114
- name: Update ~/.config/alacritty/alacritty.yml
1215
copy:
@@ -215,3 +218,4 @@
215218
- { key: F11, mods: Super, chars: "\x1b[23;3~" }
216219
- { key: F12, mods: Super, chars: "\x1b[24;3~" }
217220
- { key: NumpadEnter, chars: "\n" }
221+
when: not is_wsl

azure/storage-explorer.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,23 @@
66
connection: local
77

88
tasks:
9+
- set_fact: is_wsl={{ lookup('file', '/proc/version') is search('microsoft') }}
10+
911
- name: Install pre-requisites
1012
become: yes
1113
apt:
1214
package:
1315
- libgconf-2-4
1416
- libgnome-keyring-common
1517
- libgnome-keyring-dev
18+
when: not is_wsl
1619

1720
- name: Create Storage Explorer download location
1821
become: yes
1922
file:
2023
path: /opt/microsoft/storage-explorer
2124
state: directory
25+
when: not is_wsl
2226

2327
- name: Download Storage Explorer
2428
become: yes
@@ -27,15 +31,18 @@
2731
dest: /opt/microsoft/storage-explorer
2832
remote_src: yes
2933
creates: /opt/microsoft/storage-explorer/StorageExplorer
34+
when: not is_wsl
3035

3136
- name: Ensure local applications folder exists
3237
become: yes
3338
file:
3439
path: /usr/local/share/applications
3540
state: directory
41+
when: not is_wsl
3642

3743
- name: Add Storage Explorer desktop file
3844
become: yes
3945
copy:
4046
src: storage-explorer.desktop
4147
dest: /usr/local/share/applications/storage-explorer.desktop
48+
when: not is_wsl

customization-text.yaml

+25-9
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,32 @@
7171
path: ~/.bashrc
7272
marker: "### {mark} Ansible managed: prompt enhancement"
7373
block: |
74+
# Set up support for X server in WSL
75+
if [ -z "$WSL_DISTRO_NAME" ]; then
76+
# Write current path in the terminal title bar
77+
function writeCwdInTitlebar() {
78+
case "$TERM" in
79+
xterm*|rxvt*)
80+
echo -ne "\e]0;`whoami`@`hostname`$([ -z "$WSL_DISTRO_NAME" ] || echo -n " (WSL: $WSL_DISTRO_NAME)"): `dirs +0`\a"
81+
;;
82+
*)
83+
;;
84+
esac
85+
}
86+
else
7487
# Write current path in the terminal title bar
75-
function writeCwdInTitlebar() {
76-
case "$TERM" in
77-
xterm*|rxvt*)
78-
echo -ne "\e]0;`whoami`@`hostname`: `dirs +0`\a"
79-
;;
80-
*)
81-
;;
82-
esac
83-
}
88+
function writeCwdInTitlebar() {
89+
case "$TERM" in
90+
xterm*|rxvt*)
91+
echo -ne "\e]0;[WSL] $WSL_DISTRO_NAME: `dirs +0`\a"
92+
;;
93+
*)
94+
;;
95+
esac
96+
}
97+
98+
export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}'):0.0
99+
fi
84100
85101
# Force newline when things don't end cleanly
86102
clear_newline() {

customization-ui.yaml

+12-3
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,15 @@
1717
url: https://extensions.gnome.org/extension-data/topicons-redux%40pop-planet.info.v6.shell-extension.zip
1818

1919
tasks:
20+
- set_fact: is_wsl={{ lookup('file', '/proc/version') is search('microsoft') }}
21+
2022
- name: Create GNOME extension directory
2123
file:
2224
path: ~/.local/share/gnome-shell/extensions/{{ item.name }}
2325
state: directory
2426
register: new_extensions
2527
loop: "{{ gnome_extensions }}"
28+
when: not is_wsl
2629

2730
- name: Extract GNOME extension
2831
unarchive:
@@ -31,12 +34,12 @@
3134
creates: "~/.local/share/gnome-shell/extensions/{{ item.item.name }}/metadata.json"
3235
remote_src: yes
3336
loop: "{{ new_extensions.results }}"
34-
when: item.changed
37+
when: not is_wsl and item.changed
3538

3639
- name: Enable GNOME extension
3740
command: gnome-shell-extension-tool -e "{{ item.item.name }}"
3841
loop: "{{ new_extensions.results }}"
39-
when: item.changed
42+
when: not is_wsl and item.changed
4043

4144
- name: Install Ubuntu Mono Nerd Fonts
4245
become: yes
@@ -54,6 +57,7 @@
5457
apt_key:
5558
keyserver: hkp://keyserver.ubuntu.com:80
5659
id: 89993A70
60+
when: not is_wsl
5761

5862
- name: Add Gnome themes APT package repository
5963
become: yes
@@ -62,12 +66,13 @@
6266
filename: snwh
6367
update_cache: no
6468
register: apt_repository
69+
when: not is_wsl
6570

6671
- name: Update APT package list
6772
become: yes
6873
apt:
6974
update_cache: yes
70-
when: apt_repository.changed
75+
when: not is_wsl and apt_repository.changed
7176
register: apt_update
7277
retries: 5
7378
until: apt_update is success
@@ -78,18 +83,21 @@
7883
package:
7984
- numix-gtk-theme
8085
- paper-icon-theme
86+
when: not is_wsl
8187

8288
- name: Install PIP
8389
become: yes
8490
apt:
8591
package:
8692
- python-pip
8793
- python3-pip
94+
when: not is_wsl
8895

8996
- name: Install psutil Python package
9097
become: yes
9198
pip:
9299
name: psutil
100+
when: not is_wsl
93101

94102
- name: Update customization with dconf
95103
dconf:
@@ -326,3 +334,4 @@
326334
value: "true"
327335
- key: /org/gnome/shell/keybindings/open-application-menu
328336
value: "@as []"
337+
when: not is_wsl

google-chrome/core.yaml

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
connection: local
44

55
tasks:
6+
- set_fact: is_wsl={{ lookup('file', '/proc/version') is search('microsoft') }}
7+
68
- name: Add Google APT package key
79
become: yes
810
apt_key:
911
url: https://dl.google.com/linux/linux_signing_key.pub
12+
when: not is_wsl
1013

1114
- name: Add Google Chrome APT package repository
1215
become: yes
@@ -15,12 +18,13 @@
1518
filename: google-chrome
1619
update_cache: no
1720
register: apt_repository
21+
when: not is_wsl
1822

1923
- name: Update APT package list
2024
become: yes
2125
apt:
2226
update_cache: yes
23-
when: apt_repository.changed
27+
when: not is_wsl and apt_repository.changed
2428
register: apt_update
2529
retries: 5
2630
until: apt_update is success
@@ -29,3 +33,4 @@
2933
become: yes
3034
apt:
3135
package: google-chrome-stable
36+
when: not is_wsl

insync/core.yaml

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
connection: local
44

55
tasks:
6+
- set_fact: is_wsl={{ lookup('file', '/proc/version') is search('microsoft') }}
7+
68
- name: Add Insync APT package key
79
become: yes
810
apt_key:
911
keyserver: hkp://keyserver.ubuntu.com:80
1012
id: ACCAF35C
13+
when: not is_wsl
1114

1215
- name: Add Insync APT package repository
1316
become: yes
@@ -16,12 +19,13 @@
1619
filename: insync
1720
update_cache: no
1821
register: apt_repository
22+
when: not is_wsl
1923

2024
- name: Update APT package list
2125
become: yes
2226
apt:
2327
update_cache: yes
24-
when: apt_repository.changed
28+
when: not is_wsl and apt_repository.changed
2529
register: apt_update
2630
retries: 5
2731
until: apt_update is success
@@ -32,4 +36,4 @@
3236
package:
3337
- insync
3438
- insync-nautilus
35-
39+
when: not is_wsl

jetbrains/core.yaml

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
toolbox_ver: 1.14.5179
77

88
tasks:
9+
- set_fact: is_wsl={{ lookup('file', '/proc/version') is search('microsoft') }}
10+
911
- name: Determine if Toolbox is installed
1012
stat:
1113
path: /usr/local/bin/jetbrains-toolbox
1214
register: toolbox_path
15+
when: not is_wsl
1316

1417
- block:
1518

@@ -37,4 +40,4 @@
3740
- name: Launch Jetbrains Toolbox (first run experience)
3841
command: jetbrains-toolbox
3942

40-
when: toolbox_path.stat.exists == False
43+
when: not is_wsl and toolbox_path.stat.exists == False

kvm/core.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
connection: local
44

55
tasks:
6+
- set_fact: is_wsl={{ lookup('file', '/proc/version') is search('microsoft') }}
7+
68
- name: Install QEMU/KVM
79
become: yes
810
apt:
@@ -13,10 +15,12 @@
1315
- ovmf
1416
- qemu-kvm
1517
- virt-manager
18+
when: not is_wsl
1619

1720
- name: Enable QEMU/KVM for current user
1821
become: yes
1922
user:
2023
name={{ lookup('env', "USER") }}
2124
groups=libvirt
2225
append=yes
26+
when: not is_wsl

no-screen-blank/core.yaml

+8-5
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,32 @@
55
connection: local
66

77
tasks:
8+
- set_fact: is_wsl={{ lookup('file', '/proc/version') is search('microsoft') }}
9+
810
- name: Create extension directory
911
file:
1012
path: ~/.local/share/gnome-shell/extensions/no-screen-blank@localhost
1113
state: directory
1214
register: folder
15+
when: not is_wsl
1316

1417
- name: Copy extension code
1518
copy:
1619
src: extension.js
1720
dest: ~/.local/share/gnome-shell/extensions/no-screen-blank@localhost
18-
when: folder.changed
21+
when: not is_wsl and folder.changed
1922

2023
- name: Get GNOME shell version
2124
shell: gnome-shell --version
22-
when: folder.changed
25+
when: not is_wsl and folder.changed
2326
register: gnome_shell_raw
2427

2528
- name: Extraction GNOME shell version
2629
set_fact:
2730
gnome_shell_version: "{{ gnome_shell_raw.stdout | regex_search(regexp, '\\1') }}"
2831
vars:
2932
regexp: 'GNOME Shell ((\d+)\.(\d+))\.\d+'
30-
when: folder.changed
33+
when: not is_wsl and folder.changed
3134

3235
- name: Create extension manifest
3336
blockinfile:
@@ -41,9 +44,9 @@
4144
"uuid": "no-screen-blank@localhost",
4245
"name": "No Screen Blank",
4346
"description": "Disable blanking the screen after showing the lock screen"
44-
when: folder.changed
47+
when: not is_wsl and folder.changed
4548
register: metadata
4649

4750
- name: Enable extension
4851
command: gnome-shell-extension-tool -e no-screen-blank@localhost
49-
when: folder.changed and metadata.changed
52+
when: not is_wsl and folder.changed and metadata.changed

0 commit comments

Comments
 (0)