func CheckGPGOnRequest(requestGPGCheck chan bool, notifiers *sync.Map) {
	for {
		<-requestGPGCheck
		for i := 0; i < 20; i++ {
			if isGPGCardBusy() {
				notifiers.Range(func(k, v interface{}) bool {
					v.(chan notifier.Message) <- notifier.GPG_ON
					return true
				})
				for isGPGCardBusy() || isGPGCardBusy() {
				}
				notifiers.Range(func(k, v interface{}) bool {
					v.(chan notifier.Message) <- notifier.GPG_OFF
					return true
				})
				break
			}
		}
	}
}
CheckGPGOnRequest checks whether YubiKey is actually waiting for a touch on a GPG request
package detector
import (
	"os/exec"
	"sync"
	"time"
	"github.com/maximbaz/yubikey-touch-detector/notifier"
	"github.com/rjeczalik/notify"
	log "github.com/sirupsen/logrus"
)
func WatchGPG(gpgPubringPath string, requestGPGCheck chan bool) {
	events := make(chan notify.EventInfo)
	initWatcher := func() {
		if err := notify.Watch(gpgPubringPath, events, notify.InOpen, notify.InDeleteSelf, notify.InMoveSelf); err != nil {
			log.Errorf("Cannot establish a watch on gpg's pubring.kbx file '%v': %v", gpgPubringPath, err)
			return
		}
		log.Debug("GPG watcher is successfully established")
	}
	initWatcher()
	defer notify.Stop(events)
	for {
		select {
		case event := <-events:
			switch event.Event() {
			case notify.InOpen:
				select {
				case requestGPGCheck <- true:
				default:
				}
			default:
				log.Debugf("pubring.kbx received file event '%+v', recreating the watcher.", event.Event())
				notify.Stop(events)
				time.Sleep(5 * time.Second)
				initWatcher()
			}
		}
	}
}