workstation/roles/home-gui/tasks/emacs.yml

65 lines
2.5 KiB
YAML
Raw Normal View History

---
# Copyright 2021 Anthony Perkins
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
2020-07-11 16:11:19 +00:00
- name: Detect Emacs binary
2021-02-19 20:32:22 +00:00
ansible.builtin.stat:
2020-07-11 16:04:46 +00:00
path: "{{ prefix }}/bin/emacs"
vars:
prefix: "{{ '/usr' if ansible_system == 'Linux' else '/usr/pkg' if ansible_system == 'NetBSD' else '/usr/local' }}"
register: emacs_binary
2020-07-11 18:58:15 +00:00
- name: Remove ~/.emacs file
2021-02-19 20:32:22 +00:00
ansible.builtin.file:
2020-07-11 18:58:15 +00:00
path: "{{ ansible_env.HOME }}/.emacs"
state: absent
2019-10-03 14:24:33 +00:00
- name: Clone Emacs settings
2021-02-19 20:32:22 +00:00
ansible.builtin.git:
2021-03-31 11:28:56 +00:00
repo: https://github.com/acperkins/emacs.d.git
dest: "{{ ansible_env.HOME }}/.emacs.d"
2020-07-11 18:56:11 +00:00
- name: Install NotoSansMono-Regular font
2021-02-19 20:32:22 +00:00
ansible.builtin.copy:
2020-07-11 18:56:11 +00:00
src: NotoSansMono-Regular.ttf
dest: "{{ ansible_env.HOME }}/.local/share/fonts/NotoSansMono-Regular.ttf"
- name: Install NotoSansMono-Bold font
2021-02-19 20:32:22 +00:00
ansible.builtin.copy:
2020-07-11 18:56:11 +00:00
src: NotoSansMono-Bold.ttf
dest: "{{ ansible_env.HOME }}/.local/share/fonts/NotoSansMono-Bold.ttf"
- name: Create Emacs user service (Linux)
2021-02-19 20:32:22 +00:00
ansible.builtin.template:
2020-03-08 22:09:14 +00:00
src: emacs.service
dest: "{{ ansible_env.HOME }}/.config/systemd/user/emacs.service"
2020-07-11 16:22:27 +00:00
vars:
prefix: "{{ '/usr' if ansible_system == 'Linux' else '/usr/pkg' if ansible_system == 'NetBSD' else '/usr/local' }}"
2020-07-11 16:11:19 +00:00
when: ansible_system == 'Linux' and emacs_binary.stat.exists == True
- name: Add Emacs server to autostart (FreeBSD)
2021-02-19 20:32:22 +00:00
ansible.builtin.copy:
src: '{{ ansible_env.HOME }}/.emacs.d/emacs-server.desktop'
dest: '{{ ansible_env.HOME }}/.config/autostart'
remote_src: yes
2020-07-11 16:11:19 +00:00
when: ansible_system == 'FreeBSD' and emacs_binary.stat.exists == True
- name: Start Emacs user service
2021-02-19 20:32:22 +00:00
ansible.builtin.systemd:
name: emacs.service
scope: user
daemon_reload: yes
enabled: yes
state: started
2020-07-11 16:11:19 +00:00
when: ansible_system == 'Linux' and emacs_binary.stat.exists == True
- name: Create Emacs client launcher
2021-02-19 20:32:22 +00:00
ansible.builtin.copy:
src: "{{ ansible_env.HOME }}/.emacs.d/emacs-client.desktop"
dest: "{{ ansible_env.HOME }}/.local/share/applications/emacs.desktop"
remote_src: yes
2020-07-11 16:11:19 +00:00
when: emacs_binary.stat.exists == True