Skip to content

Commit

Permalink
Added JetBrainsMono Nerd Font (#113)
Browse files Browse the repository at this point in the history
For improved support for icons in console output.
  • Loading branch information
freemanjp authored Jan 16, 2022
1 parent 0b9c39e commit 95e641b
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 13 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ are shown below):
```yaml
# The position of the dockbar
xdesktop_dock_position: LEFT

# Nerd Font version number
xdesktop_nerd_font_version: '2.1.0'

# The SHA256 of the Nerd Font redistributable package
xdesktop_nerd_font_redis_sha256sum: '842013fa44b6896d4eb91635a81ef75244d78d7f61ff866c9dfd3315a67788cd'

# Directory to store files downloaded
xdesktop_download_dir: "{{ x_ansible_download_dir | default(ansible_env.HOME + '/.ansible/tmp/downloads') }}"
```
Example Playbook
Expand Down
9 changes: 9 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
---
# The position of the dockbar
xdesktop_dock_position: LEFT

# Nerd Font version number
xdesktop_nerd_font_version: '2.1.0'

# The SHA256 of the Nerd Font redistributable package
xdesktop_nerd_font_redis_sha256sum: '842013fa44b6896d4eb91635a81ef75244d78d7f61ff866c9dfd3315a67788cd'

# Directory to store files downloaded
xdesktop_download_dir: "{{ x_ansible_download_dir | default(ansible_env.HOME + '/.ansible/tmp/downloads') }}"
8 changes: 7 additions & 1 deletion handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
---
# handlers file for xdesktop
- name: 'xdesktop: apply glib schemas changes'
become: yes
command: '/usr/bin/glib-compile-schemas {{ xdesktop_glib_schemas_directory }}'

- name: update font-cache
become: yes
command: fc-cache -fv
3 changes: 2 additions & 1 deletion molecule/default/tests/test_gnome.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ def test_for_config_dirs(host, dir_path):
'/usr/share/X11/xorg.conf.d/60-ansible-screensaver.conf',
'/usr/share/glib-2.0/schemas/20_ansible_screensaver.gschema.override',
'/usr/share/glib-2.0/schemas/20_ansible_lockscreen.gschema.override',
'/usr/share/glib-2.0/schemas/20_ansible_dock.gschema.override'
'/usr/share/glib-2.0/schemas/20_ansible_dock.gschema.override',
'/usr/share/glib-2.0/schemas/20_ansible_monospace_font.gschema.override'
])
def test_for_config(host, config_path):
config_file = host.file(config_path)
Expand Down
12 changes: 1 addition & 11 deletions tasks/gnome-desktop-configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,4 @@
owner: root
group: root
mode: 'u=rw,go=r'
register: dock_config

- name: apply glib schemas changes
tags:
# Suppress warning: [ANSIBLE0016] Tasks that run when changed should likely be handlers
# Since the command is invoked with an argument that is role specific it
# doesn't make sense to use a handler, which are global to the playbook.
- skip_ansible_lint
become: yes
command: '/usr/bin/glib-compile-schemas {{ xdesktop_glib_schemas_directory }}'
when: screensaver_config.changed or lockscreen_config.changed or dock_config.changed
notify: 'xdesktop: apply glib schemas changes'
2 changes: 2 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
- import_tasks: gnome-desktop.yml

- import_tasks: accessories.yml

- import_tasks: nerd-font.yml
43 changes: 43 additions & 0 deletions tasks/nerd-font.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
- name: create download directory
file:
state: directory
mode: 'u=rwx,go=rx'
dest: '{{ xdesktop_download_dir }}'

- name: download Nerd Font
get_url:
url: '{{ xdesktop_nerd_font_redis_url }}'
checksum: 'sha256:{{ xdesktop_nerd_font_redis_sha256sum }}'
dest: '{{ xdesktop_download_dir }}/{{ xdesktop_nerd_font_local_filename }}'
force: no
mode: 'u=rw,go=r'

- name: create font directory
become: yes
file:
state: directory
mode: 'u=rwx,g=rwxs,o=rx'
dest: '{{ xdesktop_font_install_directory }}'

- name: install Nerd Font
become: yes
unarchive:
src: '{{ xdesktop_download_dir }}/{{ xdesktop_nerd_font_local_filename }}'
remote_src: yes
dest: '{{ xdesktop_font_install_directory }}'
include: '{{ xdesktop_nerd_font_install_files }}'
mode: 'ug=rw,o=r'
owner: root
group: staff
notify: update font-cache

- name: write monospace font config
become: yes
template:
src: monospace_font.gschema.override.j2
dest: '{{ xdesktop_glib_schemas_directory }}/20_ansible_monospace_font.gschema.override'
owner: root
group: root
mode: 'u=rw,go=r'
notify: 'xdesktop: apply glib schemas changes'
4 changes: 4 additions & 0 deletions templates/monospace_font.gschema.override.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{{ ansible_managed | comment }}

[org.gnome.desktop.interface:ubuntu]
monospace-font-name='{{ xdesktop_monospace_font_name }}'
45 changes: 45 additions & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,48 @@
---
# Directory where GLib schemas are located
xdesktop_glib_schemas_directory: /usr/share/glib-2.0/schemas

# Directory where local fonts are installed
xdesktop_font_install_directory: /usr/local/share/fonts

# Mirror to download the Nerd Font from
xdesktop_nerd_font_mirror: 'https://github.com/ryanoasis/nerd-fonts/releases/download/v{{ xdesktop_nerd_font_version }}'

# Name of the default monospace font name
xdesktop_monospace_font_name: 'JetBrainsMono Nerd Font Mono 12'

# File name of the Nerd Font redistributable package
xdesktop_nerd_font_redis_filename: 'JetBrainsMono.zip'

# File name of the Nerd Font local package
xdesktop_nerd_font_local_filename: 'JetBrainsMono_{{ xdesktop_nerd_font_version }}.zip'

# The files to install from the Nerd Font package
xdesktop_nerd_font_install_files:
- 'JetBrains Mono Extra Bold Nerd Font Complete.ttf'
- 'JetBrains Mono Regular Nerd Font Complete.ttf'
- 'JetBrains Mono Italic Nerd Font Complete.ttf'
- 'JetBrains Mono Medium Medium Nerd Font Complete Mono.ttf'
- 'JetBrains Mono ExtraBold ExtBd Nerd Font Complete Mono.ttf'
- 'JetBrains Mono Medium Italic Nerd Font Complete Mono.ttf'
- 'JetBrains Mono Medium Italic Nerd Font Complete.ttf'
- 'JetBrains Mono ExtraBold ExtBd Nerd Font Complete.ttf'
- 'JetBrains Mono Medium Med Ita Nerd Font Complete.ttf'
- 'JetBrains Mono ExtBd Ita Nerd Font Complete Mono.ttf'
- 'JetBrains Mono ExtBd Ita Nerd Font Complete.ttf'
- 'JetBrains Mono Medium Med Ita Nerd Font Complete Mono.ttf'
- 'JetBrains Mono Bold Nerd Font Complete Mono.ttf'
- 'JetBrains Mono Medium Nerd Font Complete.ttf'
- 'JetBrains Mono ExtraBold ExBd I Nerd Font Complete.ttf'
- 'JetBrains Mono Bold Italic Nerd Font Complete.ttf'
- 'JetBrains Mono Medium Medium Nerd Font Complete.ttf'
- 'JetBrains Mono Italic Nerd Font Complete Mono.ttf'
- 'JetBrains Mono Bold Italic Nerd Font Complete Mono.ttf'
- 'JetBrains Mono Medium Nerd Font Complete Mono.ttf'
- 'JetBrains Mono Extra Bold Nerd Font Complete Mono.ttf'
- 'JetBrains Mono ExtraBold ExBd I Nerd Font Complete Mono.ttf'
- 'JetBrains Mono Regular Nerd Font Complete Mono.ttf'
- 'JetBrains Mono Bold Nerd Font Complete.ttf'

# URL of the Nerd Font redistributable package
xdesktop_nerd_font_redis_url: '{{ xdesktop_nerd_font_mirror }}/{{ xdesktop_nerd_font_redis_filename }}'

0 comments on commit 95e641b

Please sign in to comment.