delphiki / AirStatus

Check AirPods battery levels on Linux
GNU General Public License v3.0
130 stars 23 forks source link

Airpods Pro systemd service crashes #3

Open dodalovic opened 2 years ago

dodalovic commented 2 years ago

Maybe this could help:

● airstatus.service - AirPods Pro Battery Monitor
     Loaded: loaded (/etc/systemd/system/airstatus.service; enabled; vendor preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Tue 2021-12-28 09:51:09 CET; 571ms ago
    Process: 58060 ExecStart=/usr/bin/python3 /home/dodalovic/me/projects/opensource/AirStatus/main.py /tmp/airstatus.out (code=exited, status=1/FAILURE)
   Main PID: 58060 (code=exited, status=1/FAILURE)
        CPU: 52ms
dodalovic commented 2 years ago

When I execute the command /usr/bin/python3 /home/dodalovic/me/projects/opensource/AirStatus/main.py /tmp/airstatus.out, it works just fine, stays running indefinitely

Pop!_OS 21.10

uname -a
Linux pop-os 5.15.8-76051508-generic #202112141040~1639505278~21.10~0ede46a SMP Tue Dec 14 22:38:29 U x86_64 x86_64 x86_64 GNU/Linux
delphiki commented 2 years ago

Hello @dodalovic,

Does something show up with journalctl?

dodalovic commented 2 years ago

@delphiki I'm getting this via journalctl:

Jan 26 15:35:56 pop-os systemd[1]: Started AirPods Battery Monitor.
Jan 26 15:35:56 pop-os python3[473254]: Traceback (most recent call last):
Jan 26 15:35:56 pop-os python3[473254]:   File "/home/dodalovic/me/tools/AirStatus/main.py", line 1, in <module>
Jan 26 15:35:56 pop-os python3[473254]:     from bleak import discover
Jan 26 15:35:56 pop-os python3[473254]: ModuleNotFoundError: No module named 'bleak'
delphiki commented 2 years ago

@dodalovic You probably forgot to install the requirements:

pip install -r requirements.txt
dodalovic commented 2 years ago

@delphiki After doing that, and restarting service, i still have:

Jan 26 16:38:11 pop-os systemd[1]: airstatus.service: Scheduled restart job, restart counter is at 32.
Jan 26 16:38:11 pop-os systemd[1]: Stopped AirPods Battery Monitor.
Jan 26 16:38:11 pop-os systemd[1]: Started AirPods Battery Monitor.
Jan 26 16:38:11 pop-os python3[498384]: Traceback (most recent call last):
Jan 26 16:38:11 pop-os python3[498384]:   File "/home/dodalovic/me/tools/AirStatus/main.py", line 1, in <module>
Jan 26 16:38:11 pop-os python3[498384]:     from bleak import discover
Jan 26 16:38:11 pop-os python3[498384]: ModuleNotFoundError: No module named 'bleak'
Jan 26 16:38:11 pop-os systemd[1]: airstatus.service: Main process exited, code=exited, status=1/FAILURE
Jan 26 16:38:11 pop-os systemd[1]: airstatus.service: Failed with result 'exit-code'.
Jan 26 16:38:15 pop-os systemd[1]: airstatus.service: Scheduled restart job, restart counter is at 33.
Jan 26 16:38:15 pop-os systemd[1]: Stopped AirPods Battery Monitor.
Jan 26 16:38:15 pop-os systemd[1]: Started AirPods Battery Monitor.
dodalovic commented 2 years ago

Also, the numbers read are way different from the ones i see on my IPad. Not sure why though.

dodalovic commented 2 years ago

Thx @Movisivi, but it's not related to that. Also, I prefer not to use sudo for installing dependencies. :)

FeryET commented 1 year ago

I get the following error:

 /usr/bin/python3: can't open file '/tmp/airstatus.out': [Errno 2] No such file or directory

What might cause the problem?