2019-10-03 10:50:19 +00:00
|
|
|
---
|
2023-01-21 19:42:51 +00:00
|
|
|
# Copyright 2021-2023 Anthony Perkins
|
2021-02-19 22:55:57 +00:00
|
|
|
#
|
|
|
|
# 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
|
2019-10-03 10:50:19 +00:00
|
|
|
dest: "{{ ansible_env.HOME }}/.emacs.d"
|
2020-02-28 14:20:29 +00:00
|
|
|
- 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
|
2022-08-18 15:37:57 +00:00
|
|
|
dest: "{{ ansible_env.XDG_CONFIG_HOME }}/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
|
2020-02-28 14:20:29 +00:00
|
|
|
- name: Add Emacs server to autostart (FreeBSD)
|
2021-02-19 20:32:22 +00:00
|
|
|
ansible.builtin.copy:
|
2020-02-28 14:20:29 +00:00
|
|
|
src: '{{ ansible_env.HOME }}/.emacs.d/emacs-server.desktop'
|
2022-08-18 15:37:57 +00:00
|
|
|
dest: '{{ ansible_env.XDG_CONFIG_HOME }}/autostart'
|
2020-02-28 14:20:29 +00:00
|
|
|
remote_src: yes
|
2020-07-11 16:11:19 +00:00
|
|
|
when: ansible_system == 'FreeBSD' and emacs_binary.stat.exists == True
|
2020-02-28 14:20:29 +00:00
|
|
|
- name: Start Emacs user service
|
2021-02-19 20:32:22 +00:00
|
|
|
ansible.builtin.systemd:
|
2020-02-28 14:20:29 +00:00
|
|
|
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
|
2020-02-28 14:20:29 +00:00
|
|
|
- name: Create Emacs client launcher
|
2021-02-19 20:32:22 +00:00
|
|
|
ansible.builtin.copy:
|
2020-02-28 14:20:29 +00:00
|
|
|
src: "{{ ansible_env.HOME }}/.emacs.d/emacs-client.desktop"
|
2022-08-18 15:37:57 +00:00
|
|
|
dest: "{{ ansible_env.XDG_DATA_HOME }}/applications/emacs.desktop"
|
2020-02-28 14:20:29 +00:00
|
|
|
remote_src: yes
|
2020-07-11 16:11:19 +00:00
|
|
|
when: emacs_binary.stat.exists == True
|