Skip to content

Instantly share code, notes, and snippets.

@carpii
Created April 20, 2022 20:37
Show Gist options
  • Save carpii/2acf63434fc951490bed5af1667b51db to your computer and use it in GitHub Desktop.
Save carpii/2acf63434fc951490bed5af1667b51db to your computer and use it in GitHub Desktop.
log 1password filesystem events, to troubleshoot it opening more than one instance
#!/bin/sh
USER=`whoami`
LOGFILE="/home/${USER}/1password.log"
D=`date +"%Y/%m/%d %H:%M:%S"`
echo "=======================================" >> ${LOGFILE}
echo "${D} - LAUNCHING WATCHER" >> ${LOGFILE}
inotifywait -m -e close_write,moved_to,create,delete,modify --format '%:e %f' --excludei "chromium|Network changed|sqlite" ~/.config/1Password | while read -r filename; do
REGEXP='(Singleton[^ ]*)'
D=`date +"%Y/%m/%d %H:%M:%S"`
echo "${D} - INOTIFY - ${filename}" >> ${LOGFILE}
# if event involved a Singleton* file
if [[ "${filename}" =~ $REGEXP ]]; then
echo " [LS]" >> ${LOGFILE}
ls -l ~/.config/1Password/${BASH_REMATCH[1]} 2>/dev/null | sed -e 's/^/ /' >> ${LOGFILE}
# try to identify all top-level 1password processes
echo " [PS]" >> ${LOGFILE}
pgrep -a -f -l "1Password" | grep -v "zygote\|gpu-process\|Keyr\|renderer\|utility\|inotifywait" | sed -e 's/^/ /' >> ${LOGFILE}
echo "--------" >> ${LOGFILE}
fi;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment