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

57 lines
2.2 KiB
YAML
Raw Permalink Normal View History

---
2023-01-21 19:42:51 +00:00
# Copyright 2021-2023 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"
- 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
- 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'
2022-08-18 15:37:57 +00:00
dest: '{{ ansible_env.XDG_CONFIG_HOME }}/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"
2022-08-18 15:37:57 +00:00
dest: "{{ ansible_env.XDG_DATA_HOME }}/applications/emacs.desktop"
remote_src: yes
2020-07-11 16:11:19 +00:00
when: emacs_binary.stat.exists == True