summaryrefslogtreecommitdiff
path: root/dotfiles-darwin
diff options
context:
space:
mode:
authorGrégoire Duchêne <gduchene@awhk.org>2022-01-29 13:19:35 +0000
committerGrégoire Duchêne <gduchene@awhk.org>2022-01-29 13:19:35 +0000
commitd8b279da154813346631479ed89e107d434f3aae (patch)
treea49e8553f7eabb790f9794b8f0c8e632fc742b92 /dotfiles-darwin
parent0eee4defb09d895b1059eac98f64225f841007ac (diff)
darwin/env.sh: Add logging
Diffstat (limited to 'dotfiles-darwin')
-rwxr-xr-xdotfiles-darwin/bin/env.sh8
-rw-r--r--dotfiles-darwin/launchd/org.awhk.env.plist6
2 files changed, 13 insertions, 1 deletions
diff --git a/dotfiles-darwin/bin/env.sh b/dotfiles-darwin/bin/env.sh
index d291ef9..518962d 100755
--- a/dotfiles-darwin/bin/env.sh
+++ b/dotfiles-darwin/bin/env.sh
@@ -1,7 +1,11 @@
#!/usr/bin/env zsh
+zmodload zsh/datetime
+echo_log() { echo $(strftime %+) - $@ }
+
for env (DOMAIN HOST SSH_AUTH_SOCK UNAME
XDG_{{CACHE,CONFIG,DATA}_HOME,RUNTIME_DIR}); do
+ echo_log Setting ${env} to “${(P)env}”.
launchctl setenv ${env} ${(P)env}
done
@@ -9,6 +13,8 @@ done
# make it work in Emacs only. Yep, it’s pretty bad.
local plist=~/Applications/Emacs.app/Contents/Info.plist
if [[ -f ${plist} ]]; then
- plutil -replace LSEnvironment -json '{"PATH": "'${PATH}'"}' ${plist}
+ local json_path='{"PATH": "'${PATH}'"}'
+ echo_log Setting PATH in Emacs.app to “${json_path}”.
+ plutil -replace LSEnvironment -json ${json_path} ${plist}
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -f ${plist:h:h}
fi
diff --git a/dotfiles-darwin/launchd/org.awhk.env.plist b/dotfiles-darwin/launchd/org.awhk.env.plist
index f2da1d5..49b42d8 100644
--- a/dotfiles-darwin/launchd/org.awhk.env.plist
+++ b/dotfiles-darwin/launchd/org.awhk.env.plist
@@ -8,6 +8,12 @@
<key>Program</key>
<string>${ENV_SH}</string>
+ <key>StandardOutPath</key>
+ <string>${HOME}/Library/Logs/org.awhk.env.log</string>
+
+ <key>StandardErrorPath</key>
+ <string>${HOME}/Library/Logs/org.awhk.env.log</string>
+
<key>RunAtLoad</key>
<true/>
</dict>