deragon / autopoweroff

Manage automatic poweroff and other actions (suspend / custom) when specific conditions are reunited.
GNU General Public License v2.0
52 stars 7 forks source link

Not working on Macbook 5,5 because of SMC event #23

Closed robinmayol closed 3 years ago

robinmayol commented 3 years ago

Hi,

Is there a way to blacklist some of the devices that are watched by autopoweroffd? Autopoweroff won't consider my laptop to be idle, I believe because of this:

apo.observer.device.thread - DEBUG - ApoObserverDevice.run(): Activity detected on /dev/input/by-path/platform-applesmc.768-event at 1630337482.709687

Thank you for your work and dedication on this piece of software :)

robinmayol commented 3 years ago

I realised reading the logs that you need to ignore the speaker from the devs as well, so I did a dpkg -L autopoweroff to find the ApoObserver bits, searched the folder for the text "speaker" in /usr/share/python/modules/ and found the condition in ApoObserverDevice.py. Copy pasted and changed spkr for smc:

if "smc" in devicePath:
      # On Macbook 5.5 (maybe others) the SMC is constantly sending
      # events, probably from the light sensor or something so
      # we want to ignore this.
      self.logger.warn("devicePath = " + devicePath + " REJECTED because it is a smc.")
      return

And it works, yay! Feel free to close if you think its the best way of sorting it.

deragon commented 3 years ago

Thanks for the solution! It is now in the source code, commit ee108be25bfaa41688c9a5861889af9cfaff95b0. I have thanked you in the commit also. Best regards, -- Hans.