Thanks for this, I have checked my permissions and they were all correct however I deleted everything and started again following your instructions however still got the same problem
Have taken a screenshot of my log file. Seems that I am getting an error after running:
sudo launchctl load -w -F /Library/LaunchDaemons/de.bernhard-baehr.sleepwatcher.plist
(2021-12-19 11:06:29.459399+0000 0x373ba)
tccd: [com.apple.TCC:access] Failed to validate dynamic code signature of accessing process <TCCDProcess: identifier=<ID of InvalidCode>, pid=1017, auid=0, euid=0, binary_path=/usr/local/sbin/sleepwatcher>: #-67062: Error Domain=NSOSStatusErrorDomain Code=-67062 "(null)"
Then I tried putting my system to sleep and get this error when waking up:
kernel: (IOHIDFamily) IOHIDLibUserClient:0x1000009af sleepwatcher is not entitled for IOHIDLibUserClient keyboard access
(2021-12-19 11:10:06.986798+0000 0x160)