Automatic Espanso Restart When Connecting a Keyboard

I implemented a small addition to my Espanso setup . Whenever I plug in a new keyboard Espanso needs a restart to work. So until today I had to go to the terminal and type in espanso restart . But since I connect and disconnect keyboards regularly (e.g. when arriving at the office, or back at home) I wanted an automated solution. In my initial tests espanso restarted too quickly and potentially…