#!/bin/bash TARGET_PROGRAM="/home/chris/.gnupg/pinentry-dmenu" inotifywait -m -e access "$TARGET_PROGRAM" | while read; do if [ -f "/home/chris/.gnupg/current_monitor" ]; then rm /home/chris/.gnupg/current_monitor fi swaymsg -t get_outputs | jq -r '.[] | select(.focused==true).name' >> /home/chris/.gnupg/current_monitor done