AirStatus icon indicating copy to clipboard operation
AirStatus copied to clipboard

Airpods Pro systemd service crashes

Open dodalovic opened this issue 3 years ago • 12 comments

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 avatar Dec 28 '21 08:12 dodalovic

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

dodalovic avatar Dec 28 '21 09:12 dodalovic

Hello @dodalovic,

Does something show up with journalctl?

delphiki avatar Dec 30 '21 23:12 delphiki

My output keeps saying that no module named bleak found even though I installed the requirements.txt.

https://pastebin.com/aMx9d0WW

Movisivi avatar Jan 23 '22 07:01 Movisivi

I figured it out. I was doing pip install instead of sudo pip install on requirements.txt. After doing that and systemctl enable airstatus and a reboot, my percentages look to be displaying properly.

Movisivi avatar Jan 23 '22 07:01 Movisivi

Forgot to mention, you also have to have ControllerMode=dual in /etc/bluetooth/main.conf for the percentages to show up.

Movisivi avatar Jan 24 '22 02:01 Movisivi

@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'

dodalovic avatar Jan 26 '22 14:01 dodalovic

@dodalovic You probably forgot to install the requirements:

pip install -r requirements.txt

delphiki avatar Jan 26 '22 15:01 delphiki

@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 avatar Jan 26 '22 15:01 dodalovic

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

dodalovic avatar Jan 26 '22 15:01 dodalovic

@dodalovic Dude, add SUDO in front of pip install! I literally told you how to get it working.

Movisivi avatar Jan 26 '22 20:01 Movisivi

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

dodalovic avatar Jan 26 '22 21:01 dodalovic

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?

FeryET avatar Sep 18 '22 10:09 FeryET