Add system-info macOS user service
This commit is contained in:
parent
7379986378
commit
5c78bd1da3
@ -1,4 +1,25 @@
|
|||||||
---
|
---
|
||||||
# TODO: create a launchd module that handles user mode services
|
- name: get list of running launchd services
|
||||||
# cp $script_dir/system-info.plist ~/Library/LaunchAgents/system-info.plist
|
command: launchctl list
|
||||||
# launchctl load -w ~/Library/LaunchAgents/system-info.plist
|
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}}'
|
||||||
|
19
roles/system-info/templates/system-info.plist.j2
Normal file
19
roles/system-info/templates/system-info.plist.j2
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>Label</key>
|
||||||
|
<string>system-info</string>
|
||||||
|
<key>EnvironmentVariables</key>
|
||||||
|
<dict>
|
||||||
|
<key>PATH</key>
|
||||||
|
<string>/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
|
||||||
|
</dict>
|
||||||
|
<key>Program</key>
|
||||||
|
<string>{{ansible_env.HOME}}/.config/tmux/system-info/system-info-macOS.sh</string>
|
||||||
|
<key>RunAtLoad</key>
|
||||||
|
<true/>
|
||||||
|
<key>KeepAlive</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
Loading…
x
Reference in New Issue
Block a user