diff --git a/LaunchAgents/sh.dana.dim_when_not_working.plist b/LaunchAgents/sh.dana.dim_when_not_working.plist
new file mode 100644
index 0000000..ce6110e
--- /dev/null
+++ b/LaunchAgents/sh.dana.dim_when_not_working.plist
@@ -0,0 +1,23 @@
+
+
+
+
+ EnvironmentVariables
+
+ PATH
+ $PATH
+
+ Label
+ sh.dana.dim_when_not_working
+ ProgramArguments
+ $HOME/.dotfiles/scripts/dim_when_not_working.applescript
+ RunAtLoad
+
+ KeepAlive
+
+ StandardErrorPath
+ /tmp/sh.dana.dim_when_not_working.err
+ StandardOutPath
+ /tmp/sh.dana.dim_when_not_working.out
+
+
diff --git a/LaunchAgents/sh.dana.dont_sit_in_silence.plist b/LaunchAgents/sh.dana.dont_sit_in_silence.plist
new file mode 100644
index 0000000..20bb8f0
--- /dev/null
+++ b/LaunchAgents/sh.dana.dont_sit_in_silence.plist
@@ -0,0 +1,23 @@
+
+
+
+
+ EnvironmentVariables
+
+ PATH
+ $PATH
+
+ Label
+ sh.dana.dont_sit_in_silence
+ ProgramArguments
+ $HOME/.dotfiles/scripts/dont_sit_in_silence.sh
+ RunAtLoad
+
+ KeepAlive
+
+ StandardErrorPath
+ /tmp/sh.dana.dont_sit_in_silence.err
+ StandardOutPath
+ /tmp/sh.dana.dont_sit_in_silence.out
+
+
diff --git a/bash_profile b/bash_profile
index bd17412..c7c5b25 100755
--- a/bash_profile
+++ b/bash_profile
@@ -7,8 +7,9 @@ set +H
export PYENV_SHELL=bash
export PATH="$HOME/.cargo/bin:/Users/dana/.pyenv/shims:/usr/local/heroku/bin:/usr/local/bin:/usr/local/sbin:/usr/local/lib/node:$PATH"
-export EDITOR='/usr/local/bin/code --wait'
+export EDITOR='code --wait'
export GUI_EDITOR=$EDITOR
+export THOR_MERGE=$EDITOR' -d $1 $2'
export GPG_TTY=$(tty)
export BASH_SILENCE_DEPRECATION_WARNING=1
if [[ -f /opt/homebrew/bin/brew ]]; then
diff --git a/bundle_config b/bundle_config
index c4c6c11..dd1471e 100644
--- a/bundle_config
+++ b/bundle_config
@@ -6,3 +6,4 @@ BUNDLE_BUILD__MYSQL2: "--with-opt-dir=/usr/local/opt/openssl@1.1"
BUNDLE_GEM__CI: "github"
BUNDLE_GEM__CHANGELOG: "true"
BUNDLE_GEM__LINTER: "rubocop"
+BUNDLE_BUILD__PUMA: "--with-pkg-config=/opt/homebrew/opt/openssl@1.1/lib/pkgconfig"
diff --git a/gitconfig b/gitconfig
index 9b94cc9..28bfe52 100644
--- a/gitconfig
+++ b/gitconfig
@@ -10,7 +10,6 @@
excludesfile = ~/.gitignore
mergeoptions = --no-edit
hooksPath = ~/.dotfiles/hooks
- editor = mate --wait
[help]
autocorrect = -1
[push]
@@ -57,12 +56,12 @@
diff = diffr | less
[core]
- editor = code --wait
+ editor = code --wait
[diff]
- tool = vscode
-[difftool "vscode"]
- cmd = code --wait --diff $LOCAL $REMOTE
+ tool = vscode
[merge]
- tool = vscode
+ tool = vscode
[mergetool "vscode"]
- cmd = code --wait $MERGED
+ cmd = code --wait --merge $REMOTE $LOCAL $BASE $MERGED
+[difftool "vscode"]
+ cmd = code --wait --diff $LOCAL $REMOTE
diff --git a/scripts/dim_when_not_working.applescript b/scripts/dim_when_not_working.applescript
new file mode 100755
index 0000000..b6ee1c1
--- /dev/null
+++ b/scripts/dim_when_not_working.applescript
@@ -0,0 +1,108 @@
+#!/usr/bin/osascript
+
+-- reading calendar is from:
+-- https://www.macscripter.net/t/faster-way-to-find-a-calendar-event/69257/5
+-- Setting greyscale is from:
+-- https://stackoverflow.com/questions/75152094/applescript-ventura-toggle-accessibility-grayscale-on-off
+
+use AppleScript version "2.4"
+use scripting additions
+use framework "Foundation"
+use framework "EventKit"
+
+set listOfCalNames to {} -- list of one or more calendar names
+
+--gain access to Event Kit.
+set theEKEventStore to create_event_store_access()
+
+--if no access is allowed to Event Kit, then exit script
+if theEKEventStore is false then return
+
+-- get calendars that can store events
+set theCalendars to theEKEventStore's calendarsForEntityType:0
+
+repeat
+ checkGreyscale(listOfCalNames, theCalendars, theEKEventStore)
+ delay 1
+end repeat
+
+on checkGreyscale(listOfCalNames, theCalendars, theEKEventStore)
+ -- prepare times
+ set nowDate to current application's NSDate's |date|()
+
+ -- filter the find to events in the calendar named "Home"
+ set theNSPredicate to current application's NSPredicate's predicateWithFormat_("title IN %@", listOfCalNames)
+ set calsToSearch to theCalendars's filteredArrayUsingPredicate:theNSPredicate
+
+ -- find matching events
+ set thePred to theEKEventStore's predicateForEventsWithStartDate:nowDate endDate:nowDate calendars:calsToSearch
+ set theEvents to (theEKEventStore's eventsMatchingPredicate:thePred)
+
+ -- sort by date
+ set theEvents to (theEvents's sortedArrayUsingSelector:("compareStartDateWithEvent:" as list))
+ -- read isGreyScale
+ set isGreyScale to do shell script "defaults read com.apple.universalaccess grayscale -bool"
+ set prohibitedEmoji to ((character id 128683) as Unicode text)
+ set currentlyProhibited to false
+ -- log prohibitedString
+ repeat with index from 1 to length of (theEvents as list)
+ set theCurrentEvent to item index of (theEvents as list)
+ -- Process the current event itemexit repeat
+ set theCurrentEventTitle to (theCurrentEvent's title as Unicode text)
+ -- log theCurrentEventTitle
+ if theCurrentEventTitle contains prohibitedEmoji then
+ -- log "currentlyProhibited"
+ set currentlyProhibited to true
+ if isGreyScale is equal to "0" then
+ toggleGreyscale()
+ end if
+ exit repeat
+ end if
+ end repeat
+
+ if not currentlyProhibited then
+ if isGreyScale is equal to "1" then
+ toggleGreyscale()
+ end if
+ -- log "Not currently prohibited"
+ end if
+end checkGreyscale
+
+on toggleGreyscale()
+ -- log "toggling greyscale"
+ current application's NSWorkspace's sharedWorkspace()'s openURL:(current application's NSURL's URLWithString:"x-apple.systempreferences:com.apple.preference.universalaccess?Seeing_Display")
+ tell application "System Events" to tell application process "System Settings"
+ repeat until exists window "Display"
+ end repeat
+ set colourFiltersGroup to group 4 of scroll area 1 of group 1 of group 2 of splitter group 1 of group 1 of window "Display"
+ set filterTypePopup to pop up button 1 of colourFiltersGroup
+ click filterTypePopup
+ click menu item 1 of menu 1 of filterTypePopup
+ click checkbox 1 of colourFiltersGroup
+ end tell
+ if application "System Settings" is running then
+ tell application "System Settings" to quit
+ end if
+end toggleGreyscale
+
+--sub routine to gain access to Event Kit
+on create_event_store_access()
+
+ -- create event store and get the OK to access Calendars
+ set theEKEventStore to current application's EKEventStore's alloc()'s init()
+ theEKEventStore's requestAccessToEntityType:0 completion:(missing value)
+
+ -- check if app has access; this will still occur the first time you OK authorization
+ set authorizationStatus to current application's EKEventStore's authorizationStatusForEntityType:0 -- work around enum bug
+ if authorizationStatus is not 3 then
+ display dialog "Access must be given in System Preferences" & linefeed & "-> Security & Privacy first." buttons {"OK"} default button 1
+ tell application "System Settings"
+ activate
+ tell pane id "com.apple.preference.security" to reveal anchor "Privacy"
+ end tell
+ error number -128
+ false
+ else
+ theEKEventStore
+ end if
+end create_event_store_access
diff --git a/scripts/dont_sit_in_silence.sh b/scripts/dont_sit_in_silence.sh
index 7defa11..3e692cd 100755
--- a/scripts/dont_sit_in_silence.sh
+++ b/scripts/dont_sit_in_silence.sh
@@ -1,4 +1,6 @@
-#!/usr/bin/env bash
+#!/bin/bash
+
+set -e
# whenever you find yourself sitting in silence after a zoom meeting or etc
# it will give a notification you can click to play whatever was last playing in spotify
@@ -11,19 +13,15 @@ fi
function alert_if_no_audio {
# from https://apple.stackexchange.com/questions/363416/how-to-check-if-any-audio-is-currently-playing-via-terminal
if [[ "$(pmset -g | grep -F ' sleep')" == *"coreaudiod"* ]]; then
- echo "Audio is playing"
+ # alerter -remove ALL -sender com.spotify.client
else
- echo "Audio is not playing"
-
# from: https://github.com/vjeantet/alerter
case "$(alerter -title "Silence Detector" \
-message "You are sitting in silence" \
-sender com.spotify.client \
-activate com.spotify.client \
-actions Play \
- -remove "Silence Detector" \
- -timeout 5 \
- -group "Silence Detector")" in
+ -group "sh.dana.dont_sit_in_silence")" in
"@TIMEOUT"|"@CLOSED");;
# from: https://stackoverflow.com/questions/8901556/controlling-spotify-with-applescript
"@CONTENTCLICKED"|"@ACTIONCLICKED"|"Play") osascript -e "tell application \"Spotify\"
@@ -34,7 +32,7 @@ function alert_if_no_audio {
fi
- sleep 60
+ sleep 10
alert_if_no_audio
}
diff --git a/scripts/install_launchagents.sh b/scripts/install_launchagents.sh
new file mode 100755
index 0000000..fa9f5da
--- /dev/null
+++ b/scripts/install_launchagents.sh
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+
+launchagents=(~/.dotfiles/LaunchAgents/*)
+
+for agent in "${launchagents[@]##*/}"; do
+ cat ~/.dotfiles/LaunchAgents/$agent | sed s^'$HOME'^$HOME^g | sed s^'$PATH'^$PATH^g > ~/Library/LaunchAgents/$agent
+ echo launchctl unload "~/Library/LaunchAgents/$agent"
+ echo launchctl load "~/Library/LaunchAgents/$agent"
+done
diff --git a/scripts/update.sh b/scripts/update.sh
index 084ea31..67a360f 100755
--- a/scripts/update.sh
+++ b/scripts/update.sh
@@ -54,4 +54,6 @@ if [[ -z "$CI" ]]; then
ruby-install ruby 3.0
fi
+install_launchagents.sh
+
resource
diff --git a/scripts/watch_prefs.sh b/scripts/watch_prefs.sh
new file mode 100755
index 0000000..7ef92ed
--- /dev/null
+++ b/scripts/watch_prefs.sh
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+domains=($(defaults domains))
+
+before=$(mktemp -d)
+for domain in ${domains[@]//,}; do
+ set +e
+ defaults read $domain >"$before/$domain" 2>/dev/null
+ set -e
+done
+
+echo "Change preference, then hit enter"
+
+read enter
+
+after=$(mktemp -d)
+
+for domain in ${domains[@]//,}; do
+ set +e
+ defaults read $domain >"$after/$domain" 2>/dev/null
+ set -e
+done
+
+echo "The diff between defaults entries is:"
+
+diff -r "$before" "$after"
+