diff --git a/roles/system-info/tasks/Darwin.yaml b/roles/system-info/tasks/Darwin.yaml index 19d4cab..8b4a0d7 100644 --- a/roles/system-info/tasks/Darwin.yaml +++ b/roles/system-info/tasks/Darwin.yaml @@ -1,4 +1,25 @@ --- -# TODO: create a launchd module that handles user mode services -# cp $script_dir/system-info.plist ~/Library/LaunchAgents/system-info.plist -# launchctl load -w ~/Library/LaunchAgents/system-info.plist +- name: get list of running launchd services + command: launchctl list + register: launchd_running_services + changed_when: false + +- name: determine if system-info is currently running + set_fact: + system_info_debug: true + system_info_plist_path: '{{ansible_env.HOME}}/Library/LaunchAgents/system-info.plist' + system_info_running: "{{'system-info' in launchd_running_services.stdout}}" + +- name: install system-info launchd plist + template: + src: system-info.plist.j2 + dest: '{{system_info_plist_path}}' + register: system_info_plist + +- name: unload running system-info launchd service + when: system_info_plist.changed and system_info_running + command: 'launchctl unload -w {{system_info_plist_path}}' + +- name: load system-info launchd service + when: system_info_plist.changed or not system_info_running + command: 'launchctl load -w {{system_info_plist_path}}' diff --git a/roles/system-info/templates/system-info.plist.j2 b/roles/system-info/templates/system-info.plist.j2 new file mode 100644 index 0000000..c3bb75f --- /dev/null +++ b/roles/system-info/templates/system-info.plist.j2 @@ -0,0 +1,19 @@ + + + + + Label + system-info + EnvironmentVariables + + PATH + /opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin + + Program + {{ansible_env.HOME}}/.config/tmux/system-info/system-info-macOS.sh + RunAtLoad + + KeepAlive + + +