diff --git a/roles/pc_application-caffeine/tasks/main.yml b/roles/pc_application-caffeine/tasks/main.yml deleted file mode 100644 index 738d4211..00000000 --- a/roles/pc_application-caffeine/tasks/main.yml +++ /dev/null @@ -1,5 +0,0 @@ -- name: Install caffeine - kewlfft.aur.aur: - use: yay - name: - - caffeine-ng \ No newline at end of file diff --git a/roles/pc_application_caffeine/defaults/main.yml b/roles/pc_application_caffeine/defaults/main.yml new file mode 100644 index 00000000..33ebdaf6 --- /dev/null +++ b/roles/pc_application_caffeine/defaults/main.yml @@ -0,0 +1,2 @@ +# Defaults for caffeine_auto_start role +caffeine_executable_path: "/usr/bin/caffeine" diff --git a/roles/pc_application_caffeine/handlers/main.yml b/roles/pc_application_caffeine/handlers/main.yml new file mode 100644 index 00000000..691b5cae --- /dev/null +++ b/roles/pc_application_caffeine/handlers/main.yml @@ -0,0 +1,10 @@ +# handlers file for caffeine_auto_start +- name: reload systemd + command: systemctl daemon-reload + +- name: enable and start caffeine + systemd: + name: caffeine.service + state: started + enabled: yes + daemon_reload: yes diff --git a/roles/pc_application-caffeine/meta/main.yml b/roles/pc_application_caffeine/meta/main.yml similarity index 100% rename from roles/pc_application-caffeine/meta/main.yml rename to roles/pc_application_caffeine/meta/main.yml diff --git a/roles/pc_application_caffeine/tasks/main.yml b/roles/pc_application_caffeine/tasks/main.yml new file mode 100644 index 00000000..1482282f --- /dev/null +++ b/roles/pc_application_caffeine/tasks/main.yml @@ -0,0 +1,19 @@ +- name: install caffeine + kewlfft.aur.aur: + use: yay + name: + - caffeine-ng + +- name: Check if caffeine is installed + command: command -v caffeine + register: caffeine_installed + changed_when: False + failed_when: caffeine_installed.rc != 0 + +- name: Copy caffeine systemd service file + template: + src: caffeine.service.j2 + dest: /etc/systemd/system/caffeine.service + notify: + - reload systemd + - enable and start caffeine diff --git a/roles/pc_application_caffeine/templates/caffeine.service.j2 b/roles/pc_application_caffeine/templates/caffeine.service.j2 new file mode 100644 index 00000000..0db8da26 --- /dev/null +++ b/roles/pc_application_caffeine/templates/caffeine.service.j2 @@ -0,0 +1,8 @@ +[Unit] +Description=Caffeine auto start + +[Service] +ExecStart={{ caffeine_executable_path }} + +[Install] +WantedBy=multi-user.target