From 87a88bb122e04c59ef755c5d45223d7879b0519d Mon Sep 17 00:00:00 2001 From: delphiki Date: Wed, 21 Oct 2020 22:44:47 +0200 Subject: [PATCH 01/21] Remove low level alert for windows --- main.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/main.py b/main.py index b98f7f5..aba9a0a 100644 --- a/main.py +++ b/main.py @@ -4,7 +4,6 @@ from pystray import Icon, Menu, MenuItem as Item from multiprocessing import Process from time import sleep -from win10toast import ToastNotifier # Configure update duration (update after n seconds) UPDATE_DURATION = 30 @@ -183,13 +182,6 @@ def create_icon(status, left, right, case, model): # Creating icon Icon(data["model"], Image.open(image), menu=menu).run() - -# Simple method for notification show -def low_level_notification(model, percent): - notifer = ToastNotifier() - notifer.show_toast(model, "Your battery is going low ({}%)".format(percent), "./icons/low_n.ico", 5, True) - - def run(): data = get_data() connected = True @@ -218,10 +210,6 @@ def run(): cached_process = proc cache = data["charge"] - # Checking for low level for notify show - if int(data["charge"]["left"]) <= LOW_LEVEL or int(data["charge"]["right"]) <= LOW_LEVEL: - low_level_notification(data["model"], data["charge"]["right"]) - elif data["status"] == 0: # Checking cache and current data for avoid Windows duplicate tray icon bug if connected: From 8210a6d510d4e00e5bf8d1e2dc86aa8292a22076 Mon Sep 17 00:00:00 2001 From: delphiki Date: Wed, 21 Oct 2020 22:45:37 +0200 Subject: [PATCH 02/21] Fix data hex data reading for linux --- main.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/main.py b/main.py index aba9a0a..2b3443a 100644 --- a/main.py +++ b/main.py @@ -4,6 +4,7 @@ from pystray import Icon, Menu, MenuItem as Item from multiprocessing import Process from time import sleep +from binascii import hexlify # Configure update duration (update after n seconds) UPDATE_DURATION = 30 @@ -17,12 +18,12 @@ async def get_device(): devices = await discover() for d in devices: # Checking for AirPods - if d.rssi >= -690 and 76 in d.metadata['manufacturer_data'] and len( - d.metadata['manufacturer_data'][76].hex()) == 54: - data = d.metadata['manufacturer_data'][76].hex() - return data - else: - return False + if d.rssi >= -690 and 76 in d.metadata['manufacturer_data']: + data_hex = hexlify(bytearray(d.metadata['manufacturer_data'][76])) + data_length = len(hexlify(bytearray(d.metadata['manufacturer_data'][76]))) + if data_length == 54: + return data_hex + return False # Same as get_device() but it's standalone method instead of async @@ -42,32 +43,32 @@ def get_data(): if not raw: return dict(status=0, model="AirPods not found") - # On 7th position we can get AirPods model, Pro or standart - if raw[7] == 'e': + # On 7th position we can get AirPods model, Pro or standard + if chr(raw[7]) == 'e': model = " Pro" else: model = "" # Checking left AirPod for availability and storing charge in variable try: - left = int(raw[12]) * 10 + left = int(chr(raw[12])) * 10 except ValueError: left = -1 # Checking right AirPod for availability and storing charge in variable try: - right = int(raw[13]) * 10 + right = int(chr(raw[13])) * 10 except ValueError: right = -1 # Checking AirPods case for availability and storing charge in variable try: - case = int(raw[15]) * 10 + case = int(chr(raw[15])) * 10 except ValueError: case = -1 # On 14th position we can get charge status of AirPods, I found it with some tests :) - charge_raw = raw[14] + charge_raw = chr(raw[14]) if charge_raw == "a": charging = "one" elif charge_raw == "b": From 76cdeb556a5257665e7a781eb481e4fa5aa45e99 Mon Sep 17 00:00:00 2001 From: delphiki Date: Wed, 21 Oct 2020 23:32:47 +0200 Subject: [PATCH 03/21] Remove icon logic to ouput json only --- main.py | 144 ++------------------------------------------------------ 1 file changed, 5 insertions(+), 139 deletions(-) diff --git a/main.py b/main.py index 2b3443a..2360a60 100644 --- a/main.py +++ b/main.py @@ -1,16 +1,11 @@ from bleak import discover -from PIL import Image from asyncio import new_event_loop, set_event_loop, get_event_loop -from pystray import Icon, Menu, MenuItem as Item -from multiprocessing import Process from time import sleep from binascii import hexlify +from json import dumps # Configure update duration (update after n seconds) -UPDATE_DURATION = 30 -# Configure battery level when you get toast notification of discharging -LOW_LEVEL = 20 - +UPDATE_DURATION = 10 # Getting data with hex format async def get_device(): @@ -89,144 +84,15 @@ def get_data(): ) -# Checking AirPods availability and create icon in tray -def create_icon(status, left, right, case, model): - # Rewriting data dict because cant pass all dict with multiprocessing lib - data = dict( - status=status, - charge=dict( - left=left, - right=right, - case=case - ), - model=model - ) - # Blank values - a_left = True - a_right = True - a_case = True - charges = dict( - left=-1, - right=-1, - case=-1 - ) - - if data["status"] == 0: - # Setting false availability for all devices and setting icon path - a_left = False - a_right = False - a_case = False - image = "./icons/no.png" - else: - # Checking for availability and errors for connected devices - charges = data["charge"] - if charges["left"] == -1 or charges["left"] == 150: - a_left = False - if charges["right"] == -1 or charges["right"] == 150: - a_right = False - if charges["case"] == -1: - a_case = False - - # Right click menu - menu = Menu( - Item( - text=data["model"], - action="", - enabled=False - ), - Item( - text="Left: {}%".format(charges["left"]), - action="", - enabled=False, - visible=a_left - ), - Item( - text="Right: {}%".format(charges["right"]), - action="", - enabled=False, - visible=a_right - ), - Item( - text="Case: {}%".format(charges["case"]), - action="", - enabled=False, - visible=a_case - ) - ) - - # Selecting lowest charge level for comparing and icon select - if a_left and charges["left"] > charges["right"]: - lowest = charges["left"] - elif a_right and charges["right"] > charges["left"]: - lowest = charges["right"] - elif charges["right"] == charges["left"]: - lowest = charges["right"] - else: - lowest = -1 - - # Selecting icon for charge levels - if lowest == -1: - image = "./icons/no.png" - elif lowest < 20: - image = "./icons/empty.png" - elif lowest < 40: - image = "./icons/low.png" - elif lowest < 60: - image = "./icons/middle.png" - elif lowest < 80: - image = "./icons/much.png" - elif lowest < 100: - image = "./icons/full.png" - else: - image = "./icons/no.png" - - # Creating icon - Icon(data["model"], Image.open(image), menu=menu).run() - def run(): - data = get_data() - connected = True - cache = None - cached_process = None - while True: + data = get_data() + if data["status"] == 1: - # Checking cache and current data for avoid Windows duplicate tray icon bug - if cache != data["charge"] or not connected: - # Flushing process(tray icon) and handling error that might be on start - try: - cached_process.terminate() - except AttributeError: - pass - - # Starting new thread(process) - proc = Process(target=create_icon, args=(1, - data["charge"]["left"], - data["charge"]["right"], - data["charge"]["case"], - data["model"])) - proc.start() - - # Setting cache vars - cached_process = proc - cache = data["charge"] - - elif data["status"] == 0: - # Checking cache and current data for avoid Windows duplicate tray icon bug - if connected: - # Flushing process(tray icon) and handling error that might be on start - try: - cached_process.terminate() - except AttributeError: - pass - # Creating process and setting cache var - proc = Process(target=create_icon, args=(0, -1, -1, -1, data["model"])) - connected = False - proc.start() + print(dumps(data)) sleep(UPDATE_DURATION) - if __name__ == '__main__': run() From 65c1f08bf467cee1acad58c3facc4537356b8d61 Mon Sep 17 00:00:00 2001 From: delphiki Date: Wed, 21 Oct 2020 23:40:30 +0200 Subject: [PATCH 04/21] Update README and clean up repo --- README.md | 20 ++++++++++---------- icons/empty.png | Bin 1470 -> 0 bytes icons/full.png | Bin 1613 -> 0 bytes icons/low.png | Bin 1500 -> 0 bytes icons/low_n.ico | Bin 370070 -> 0 bytes icons/middle.png | Bin 1535 -> 0 bytes icons/much.png | Bin 1605 -> 0 bytes icons/no.png | Bin 2433 -> 0 bytes requirements.txt | 3 +-- 9 files changed, 11 insertions(+), 12 deletions(-) delete mode 100644 icons/empty.png delete mode 100644 icons/full.png delete mode 100644 icons/low.png delete mode 100644 icons/low_n.ico delete mode 100644 icons/middle.png delete mode 100644 icons/much.png delete mode 100644 icons/no.png diff --git a/README.md b/README.md index d136aa5..c37f21f 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,19 @@ -# **AirStatus** -#### Check your AirPods battery level from tray in Windows +# **AirStatus for Linux** +#### Check your AirPods battery level on Linux #### What is it? -This is Python 3.6 script that allows you to check AirPods battery level **just by looking on icon** or get percents **by clicking _right button_** on icon +This is a Python 3.6 script, forked from [faglo/AirStatus](https://github.com/faglo/AirStatus) that allows you to check AirPods battery level from your terminal, as JSON output. + +### Example output: + +``` +{"status": 1, "charge": {"left": 90, "right": 90, "case": 50}, "charging": "one", "model": "AirPods Pro"} +``` #### Can I customize it easily? **Yes, you can!** -You can customize icons and replace it with certain names or change **update frequency** and **low level warning percent** in start of main.py file +You can change the **update frequency** within the main.py file #### Why percents are displayed in dozens? This is Apple restrictions, only genius or Apple can fix that :( @@ -15,9 +21,3 @@ This is Apple restrictions, only genius or Apple can fix that :( #### Used materials * Some code from [this repo](https://github.com/ohanedan/Airpods-Windows-Service) * Battery icons from [Icons8](https://icons8.com/icon/set/battery/windows) - -#### TODO -* Improve icons -* Display more info -* Fix bugs -* Port to Linux \ No newline at end of file diff --git a/icons/empty.png b/icons/empty.png deleted file mode 100644 index caa401113bf9c3755a1e9c7f8eb95c554c42feea..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1470 zcmZuxX*iS#0RBGrh+L_0u45+3F>b~YF_Zanj6AuLtB_-DDoR8%NtAJo$vHAMk_Z)v z!e%xX_hcN00Skr^cQ@z^`4+G zJu~vuO*Kry9YP04%px#P$!~D*P2FY|LH!M*9n3Qp);cMM>ygT!D9I}Q-#gkYXKGtz z5uvH#mGsNP_K>kK>x?c3tX(&%9m__c5k;Dj9hG>hHQLP}J|_Hog-Ef~Gz{!~f=EET zEA>wqAoZidCnYaQ&`pH3gj~e}rCLWvNlY`mjWSZFCV(|C$4!J@qp}Lk+*!WRNtD{n zxZ^AYluS)TEfjn!tt_LSx0*Le=BIyD0VoAcf-9Y^{hvZ?^dmDX4WSvU`Sad3>_!uy zNINpE@*}nW-a)1s)q-%0L!T)3rzHknB|m^4!JD4e(Xd~zcB54Tv>RO*JX>;%>;=y% zqp`FYSW@Gup;HZ^Sd>s5hH8|zqK2@tg_GeN&^W(3=S z-MNd%)?}+O6e0!*&MHf~OXjhA(+WCCHun&!gQQT_gpf|+?svJUA1r#j8+c3XeD(0E za&Cueb{Mb(#Oep1)ghZZ_)nMIh)@M5Wj2rzILp}haSd}zAi?Bf)c$2-BLkvA1@MxT z43@0DpBV2FemekM@>%{!f;Joj<1Z)z1~4CX5dF~((~CN3oxRvKzdT=4bW9<4XxB~c zAcWmK{a+n3WQUzGk!4^VH04^z6%V+>Z)bpz^PFClI@Ec1{0p6f$hz5GivFwsS<+g+ z@`t;4>_wC1-S4CMj+CbI!F*1F?3ru4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^{0xX2nz{?fMVbB~%* zoTW&rUDHr_odCXKx&eqS9mo2x2-sUhfcR{umcSo^>RG630Tx%#hdSU@F3rBS16Nea zkId+CCo}?y9-NKvV@bD*p|MY2`8~;runxbI71Dkbunc$$Um89FoXiEU4cL$0V1EI) zg}}XCU^@O~-+zK11AalbiQKu(2!6wt9Y$t7hnfVRLT-u-dOq5L$3pK2LlST&zJi)0 zja0#D?5YQNnDlBx`+;k+o@3R5KOWwZQt;2SF$rI5wiZ+hV7{a+D!j9HP|{XOKT2wm zKM_4f{*$9yCDj+{yG_z!=iJF8eeQDr3%GQ}{24Gepl==UB$rlN`&XV{F5N^p4&2*| z{zHL{x#0Kh@hH+8mTk>~#p7d3w#B$zBR00000 LNkvXXu0mjfKEveZ diff --git a/icons/low.png b/icons/low.png deleted file mode 100644 index 44000b9af9a9efc610b7250d54ec6795e3dd434c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1500 zcmV<21ta>2P)lG|6`_`nrNk_Xi%v^h=__A)G=$v*&$x z_MG$lV6S#&o@bu_`@ZwcGjk-vFbu;m48t%C!!QiPFbu;m48t%C!!QiPFd7XP(g+}L zN9q~pTu>ZKF)T|*jCf3d#FzkyF#!@|0wiX5EuCvw{p*oDvO#+T5@P}+#so-=36K~Q zATc#%LFI_e7Md-a>WjSri7^2ZlglTl*(mqP4f(X%8;}?iATcIDVoZRZ zB*p|tj0q6O(X0oo>0(y7on9js@OP7>sglM? z8Y5}6q*0QNOFAj(l%y_6os#xS`c2YqNxPhLnZB_N`33+ZB`xjqH(%L2Y{w*hC#hZ1 z*Uq`!wGP-&0s!+Qt(Md#>6$FYtimoynNYY!9W=D2CFX?AV9r9UCr=)$7x}0;zi)@ULG*;3yNi!r(FW6fw zY4QNJ^7g5OkHdfm zfFA>e=m4&bH8SV|08bX4nreImOwH4mP=J-dfdHTPx!LJjwa0qxGXaz0{v_A@XugrMcfN~F6zk%{#O%b2Ku`IpADVO$@fFR zI^e26f1cpd^(;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;jK)76LaL@bIF9fC zlzpcHbBRrU&IUk$2^F+80DtAIF_f=?u`&8ne7Es+N$VBjdx}(~p4I)^V(cCBT6) z2EUR-K(#iz|Fm-BN<)pgeG8gA|1;*T?|cq`pWN0!Gz8D zove`KM*%B=_wlXa^4joUV>AM<0{0WRw+l?izwG-@@?*d+=(gjlq8R?fw;e{N zo(7R0bZbcr?r38`PI_NgfqZnJve_T{$pY2>+OZS0OkYbHpfH8SY^pK3?oB; z2Z0^<#o9&uk32S!@g9Ov1j>JX*9y$&4ITZtukoe)9&s@aNIKk$TKXpx-_+?Jn<=$I l7ZWV`DZp>)G^VKY{|5&7&jS^vYX<-T002ovPDHLkV1mE<#gYI3 diff --git a/icons/much.png b/icons/much.png deleted file mode 100644 index d06b02a746cc05746c8296f0e9bda86cd80c7239..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1605 zcmZvde>l?#9LK-=nVCs`ln}Fvt`IrqXMVNV*GfW;PE4Ykx<}EKHm*%XtS;XjM)Kpa z=xQr1F0SP36h)R6N4wK4D%8#G+-37M+tpupf86u=yx*_qc|XtR{qN^&bW{Y%*v1$D z01`;2#e5+1qm1w$d{TJA_XF_z84)zV@NpWtS_A-qLqJ++TyCxE;uj?qdo246cXsUD z*%tlGt967-qdnly%gwfDrpI9^U3+Nh@68s-8J7EAcv7V1k;Vh|?2@~2KMTEAR@fBY zwji^M)?e$0Q9+>%*4t z31-!$(uS~+NYxb^sV@ifF?Sa1itgGyBe0!6d&`IH`QM&@uh`=yj;wl-1UgRlC(kyB zmecv86jlQJ`kve^*M_6qv$xFM6}drFI+84>PXGF68-7I}SmVh0LDUI_TV>ixE#};rdl3>oEdw`ta6d9zah9i(*;LY1Yv4;Yk2Qss=vemrX3`$k#DSP z&});rDv>Jom5(x2IX~iDO@WP=Cu=bAWk5IjL^Ji~riOTF!!{_nvTeX`ti0_r54zkE zw8%c?1KPN;N<^U$KGKFf+aVG_QDA1ph%4*1DA-B$U0bhT)mtQ9Ri-`(W`TR()CO27 z2s0a4Q7zr9$m!I8O|uc;Ip|)FOtmBRv7ClrmvN85ndvwtZWw}AULH4fUC|eB_sZO2 zkRe|nBorAA7iy_yx%Tb}uKwKi^?A&KjR(A0OMo6ziAB7u6VP@NIC=G9ls!)F@|UIb zJ1G#sI|HO3Kp8JBUGb#s+DaEFhIL+#t zKE(QqCtf=!_1Mr3d@g#tBxS>$FXropB5c*ps3j8} zO1>7t2aox=gwcfYnFX+iZrXAEp@D*4EwbyWw^c`xsOL!nU}V-pc`S~WVZJ9K4 zLz5x=YLa@i?{g=&-CEo&Di{nRiTd-=w?w^=;!=(Zj$Y({Db8#5+O9_)-N#Z*>FoP{ zW0vFh764?@hv`_03c|gK%{Ym+#swCql!f_{TJs(+Ta$8^yQNEpR-jo|Oy{d%q@lT$~GdLxTC-d&|6oGs!H;jlk|0|FcKXxea_hhCAA+)XdF? z#RH%5_7_h%rnyR$wr9#I@C59y%TT%MBkW!1izYn}F%PnSYX=0JpT1>ZKP0XS{zTTl z8RT$=tB^unvH$y{!Wg$>t9l9?FuF#W!uq7%kXMsy<)_lJKKum$+#W@{9>y&A2TRWG ArT_o{ diff --git a/icons/no.png b/icons/no.png deleted file mode 100644 index 83408e69f44dd51cea7caf4ab23c924e1868b9cb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2433 zcmV-{34Zp8P)kGzx$ zf`+0I5!8Sn2?9|ISSzuZ7%M^uqy=SZim(+$MYPmNqopOFLMa8iV5z()yFWh6IdJ#x zowswIbMM*R^G`OL+&lAso_YQ=bLPz36=~3*L4yVj8Z>Coph1HM4H`6PFi~K%34v)M z@-Y$ll!$y#M2-}Z*&?#Ph`b>pyR*NoBJvv%*=UT}s_jRluSbc<5)nBm^Yh^BZ?cH& z6_H&c^0<|9atT5WqrU6);FT9sy1Vrgp*4slXY)p9=Un2&~M6s|SF2 zz-_=#fdaMTap1%XeLV@-rr_rg@N-~pRldd+=v?4sg#xu=7+3-9qv+>8!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!3 z&CwD;BlvfqcwRXg1qA?mQ`HFp?!|;x<;sen5&X4134Z2aQ2_v61iZU3uv=hukG7y9 zf=2M8raLM_Nddqv3wlqx1IGjZRu(}c_#05(IhYIu0RV!>O@U(x-|rJEf=2M~N8$Fb z(ohm0b~f~A>?q0y@1`p35H&Q^Tph6SAXVR_6^m{PkmWy;(R(@D@x6j&G1$A}d{9~T zR71A~$T$uIp41c}GWd_8xbUxnUI>u!%qM)+Sd<8n!T$^J&Qw1uN3R6PxDF@$#{9(y zo+|a2L`#mDEGr%!NMEW{?fvtf*5RuOn@aVdM=cF05$rB_{Y6_AXi#Awh(N5y2mE);LxK;6oEK_&JE{j$D_5=XeU3 z*MWO3;qJ)CJ-)gf7l>;KE;haD ze|O@J6=7lqKS!hpFA&&)?cffHFtLN5BOtA;L?*M-{l+MQDQG z32h?m1wNt3or}-}--k?udo+XJ!abJ)zbN=7Z`zE_M5G;=00000NkvXXu0mjfwx55p diff --git a/requirements.txt b/requirements.txt index 9346456..31631ce 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ pystray~=0.16.0 bleak~=0.7.1 -Pillow~=7.2.0 -win10toast~=0.9 \ No newline at end of file +Pillow~=7.2.0 \ No newline at end of file From 908a96f3379f79ee009371a92422948fbfddab4b Mon Sep 17 00:00:00 2001 From: delphiki Date: Thu, 22 Oct 2020 18:30:15 +0200 Subject: [PATCH 05/21] Add option to save output into file --- main.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 2360a60..9ea9293 100644 --- a/main.py +++ b/main.py @@ -3,6 +3,7 @@ from time import sleep from binascii import hexlify from json import dumps +from sys import argv # Configure update duration (update after n seconds) UPDATE_DURATION = 10 @@ -85,11 +86,19 @@ def get_data(): def run(): + output_file = argv[-1] + while True: data = get_data() if data["status"] == 1: - print(dumps(data)) + json_data = dumps(data) + if len(argv) > 1: + f = open(output_file, "a") + f.write(json_data+"\n") + f.close() + else: + print(json_data) sleep(UPDATE_DURATION) From f071b4312a7f257de7457b1ab5345e82b03d467a Mon Sep 17 00:00:00 2001 From: delphiki Date: Thu, 22 Oct 2020 18:36:09 +0200 Subject: [PATCH 06/21] Update README with Usage section --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c37f21f..8e556ed 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,15 @@ #### What is it? This is a Python 3.6 script, forked from [faglo/AirStatus](https://github.com/faglo/AirStatus) that allows you to check AirPods battery level from your terminal, as JSON output. -### Example output: +### Usage + +``` +python3 main.py [output_file] +``` + +Output will be stored in `output_file` if specified. + +#### Example output ``` {"status": 1, "charge": {"left": 90, "right": 90, "case": 50}, "charging": "one", "model": "AirPods Pro"} From 651aba4039eef3e4ef659e846cbac2a2b554c565 Mon Sep 17 00:00:00 2001 From: delphiki Date: Fri, 23 Oct 2020 23:37:14 +0200 Subject: [PATCH 07/21] Add date of beacon discovery in JSON output --- main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 9ea9293..c785263 100644 --- a/main.py +++ b/main.py @@ -4,6 +4,7 @@ from binascii import hexlify from json import dumps from sys import argv +from datetime import datetime # Configure update duration (update after n seconds) UPDATE_DURATION = 10 @@ -81,7 +82,8 @@ def get_data(): case=case ), charging=charging, - model="AirPods"+model + model="AirPods"+model, + date=datetime.now().strftime('%Y-%m-%d %H:%M:%S') ) From 0786a96194583281342110ad4319460184163ab9 Mon Sep 17 00:00:00 2001 From: delphiki Date: Fri, 23 Oct 2020 23:48:18 +0200 Subject: [PATCH 08/21] Update README with proper example output with date --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8e556ed..bc28ff7 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Output will be stored in `output_file` if specified. #### Example output ``` -{"status": 1, "charge": {"left": 90, "right": 90, "case": 50}, "charging": "one", "model": "AirPods Pro"} +{"status": 1, "charge": {"left": 90, "right": 90, "case": 50}, "charging": "one", "model": "AirPods Pro", "date": "2020-10-23 09:10:11"} ``` #### Can I customize it easily? From 9d519b2c37962fba60c4dcea5f048729e16bf264 Mon Sep 17 00:00:00 2001 From: delphiki Date: Sat, 24 Oct 2020 23:51:32 +0200 Subject: [PATCH 09/21] Fix memory leak --- main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/main.py b/main.py index c785263..9d17a82 100644 --- a/main.py +++ b/main.py @@ -29,6 +29,7 @@ def get_data_hex(): set_event_loop(new_loop) loop = get_event_loop() a = loop.run_until_complete(get_device()) + loop.close() return a From 966678366197c58d321efcfd2d50f97d3a5bdd42 Mon Sep 17 00:00:00 2001 From: delphiki Date: Sat, 24 Oct 2020 23:52:09 +0200 Subject: [PATCH 10/21] Add raw data in output --- main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 9d17a82..adef0bc 100644 --- a/main.py +++ b/main.py @@ -84,7 +84,8 @@ def get_data(): ), charging=charging, model="AirPods"+model, - date=datetime.now().strftime('%Y-%m-%d %H:%M:%S') + date=datetime.now().strftime('%Y-%m-%d %H:%M:%S'), + raw=raw.decode("utf-8") ) From 29bbef27b9fdcd9fd4589205cd7afcabf4169e4a Mon Sep 17 00:00:00 2001 From: delphiki Date: Sun, 8 Nov 2020 19:15:44 +0100 Subject: [PATCH 11/21] Update README with service instructions --- README.md | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index bc28ff7..88e8959 100644 --- a/README.md +++ b/README.md @@ -18,14 +18,34 @@ Output will be stored in `output_file` if specified. {"status": 1, "charge": {"left": 90, "right": 90, "case": 50}, "charging": "one", "model": "AirPods Pro", "date": "2020-10-23 09:10:11"} ``` +### Installing as a service + +Create the file `/etc/systemd/system/airstatus.service` (as root) containing: +``` +[Unit] +Description=AirPods Battery Monitor + +[Service] +ExecStart=/usr/bin/python3 /PATH/TO/AirStatus/main.py /tmp/airstatus.out + +[Install] +WantedBy=default.target +``` + +Start the service: +``` +sudo systemctl start airstatus +``` + +Enable service on boot: + ``` +sudo systemctl enable airstatus +``` + #### Can I customize it easily? **Yes, you can!** You can change the **update frequency** within the main.py file -#### Why percents are displayed in dozens? -This is Apple restrictions, only genius or Apple can fix that :( - #### Used materials * Some code from [this repo](https://github.com/ohanedan/Airpods-Windows-Service) -* Battery icons from [Icons8](https://icons8.com/icon/set/battery/windows) From 9b41373af4fce5312d0343e95f675c7147c9ae75 Mon Sep 17 00:00:00 2001 From: ju Date: Tue, 9 Feb 2021 09:05:25 +0100 Subject: [PATCH 12/21] Add auto restart in service example --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 88e8959..2ef516b 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,8 @@ Description=AirPods Battery Monitor [Service] ExecStart=/usr/bin/python3 /PATH/TO/AirStatus/main.py /tmp/airstatus.out +Restart=always +RestartSec=3 [Install] WantedBy=default.target From f5dc9d44332f00ba02009bd97176467dd22d7304 Mon Sep 17 00:00:00 2001 From: lgoette Date: Wed, 22 Dec 2021 11:09:26 +0100 Subject: [PATCH 13/21] add best result filter which filters out the best signal in the last 10 seconds decrease min_rssi to -60 for less signal-pollution from other devices change data interpretation to do it the correct way --- main.py | 113 +++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 75 insertions(+), 38 deletions(-) diff --git a/main.py b/main.py index adef0bc..b6fccc7 100644 --- a/main.py +++ b/main.py @@ -1,13 +1,41 @@ from bleak import discover from asyncio import new_event_loop, set_event_loop, get_event_loop -from time import sleep +from time import sleep, time_ns from binascii import hexlify from json import dumps from sys import argv from datetime import datetime # Configure update duration (update after n seconds) -UPDATE_DURATION = 10 +UPDATE_DURATION = 1 +MIN_RSSI = -60 +AIRPODS_MANUFACTURER = 76 +AIRPODS_DATA_LENGTH = 54 +RECENT_BEACONS_MAX_T_NS = 10000000000 # 10 Seconds + +recent_beacons = [] + + +def get_best_result(device): + recent_beacons.append({ + "time": time_ns(), + "device": device + }) + strongest_beacon = None + i = 0 + while i < len(recent_beacons): + if(time_ns() - recent_beacons[i]["time"] > RECENT_BEACONS_MAX_T_NS): + recent_beacons.pop(i) + continue + if (strongest_beacon == None or strongest_beacon.rssi < recent_beacons[i]["device"].rssi): + strongest_beacon = recent_beacons[i]["device"] + i += 1 + + if (strongest_beacon != None and strongest_beacon.address == device.address): + strongest_beacon = device + + return strongest_beacon + # Getting data with hex format async def get_device(): @@ -15,10 +43,11 @@ async def get_device(): devices = await discover() for d in devices: # Checking for AirPods - if d.rssi >= -690 and 76 in d.metadata['manufacturer_data']: - data_hex = hexlify(bytearray(d.metadata['manufacturer_data'][76])) - data_length = len(hexlify(bytearray(d.metadata['manufacturer_data'][76]))) - if data_length == 54: + d = get_best_result(d) + if d.rssi >= MIN_RSSI and AIRPODS_MANUFACTURER in d.metadata['manufacturer_data']: + data_hex = hexlify(bytearray(d.metadata['manufacturer_data'][AIRPODS_MANUFACTURER])) + data_length = len(hexlify(bytearray(d.metadata['manufacturer_data'][AIRPODS_MANUFACTURER]))) + if data_length == AIRPODS_DATA_LENGTH: return data_hex return False @@ -33,6 +62,7 @@ def get_data_hex(): return a +# Getting data from hex string and converting it to dict(json) # Getting data from hex string and converting it to dict(json) def get_data(): raw = get_data_hex() @@ -41,54 +71,62 @@ def get_data(): if not raw: return dict(status=0, model="AirPods not found") - # On 7th position we can get AirPods model, Pro or standard + flip: bool = is_flipped(raw) + + # On 7th position we can get AirPods model, gen1, gen2, Pro or Max if chr(raw[7]) == 'e': - model = " Pro" + model = "AirPodsPro" + elif chr(raw[7]) == 'f': + model = "AirPods2" + elif chr(raw[7]) == '2': + model = "AirPods1" + elif chr(raw[7]) == 'a': + model = "AirPodsMax" else: - model = "" + model = "unknown" # Checking left AirPod for availability and storing charge in variable - try: - left = int(chr(raw[12])) * 10 - except ValueError: - left = -1 + status_tmp = int("" + chr(raw[12 if flip else 13]), 16) + left_status = (100 if status_tmp == 10 else (status_tmp * 10 + 5 if status_tmp <= 10 else -1)) # Checking right AirPod for availability and storing charge in variable - try: - right = int(chr(raw[13])) * 10 - except ValueError: - right = -1 + status_tmp = int("" + chr(raw[13 if flip else 12]), 16) + right_status = (100 if status_tmp == 10 else (status_tmp * 10 + 5 if status_tmp <= 10 else -1)) # Checking AirPods case for availability and storing charge in variable - try: - case = int(chr(raw[15])) * 10 - except ValueError: - case = -1 - - # On 14th position we can get charge status of AirPods, I found it with some tests :) - charge_raw = chr(raw[14]) - if charge_raw == "a": - charging = "one" - elif charge_raw == "b": - charging = "both" - else: - charging = "N/A" + status_tmp = int("" + chr(raw[15]), 16) + case_status = (100 if status_tmp == 10 else (status_tmp * 10 + 5 if status_tmp <= 10 else -1)) + + # On 14th position we can get charge status of AirPods + charging_status = int("" + chr(raw[14]), 16) + charging_left:bool = (charging_status & (0b00000010 if flip else 0b00000001)) != 0 + charging_right:bool = (charging_status & (0b00000001 if flip else 0b00000010)) != 0 + charging_case:bool = (charging_status & 0b00000100) != 0 + charging_single:bool = (charging_status & 0b00000001) != 0 # Return result info in dict format return dict( status=1, charge=dict( - left=left, - right=right, - case=case + left=left_status, + right=right_status, + case=case_status ), - charging=charging, - model="AirPods"+model, + charging_left=charging_left, + charging_right=charging_right, + charging_case=charging_case, + charging_single=charging_single, + model=model, date=datetime.now().strftime('%Y-%m-%d %H:%M:%S'), raw=raw.decode("utf-8") ) +# Return if left and right is flipped in the data +def is_flipped(raw): + return (int("" + chr(raw[10]),16) & 0x02) == 0 + + def run(): output_file = argv[-1] @@ -106,7 +144,6 @@ def run(): sleep(UPDATE_DURATION) -if __name__ == '__main__': - run() - +if __name__ == '__main__': + run() \ No newline at end of file From 0855920291f398b74dcdadd32795ac1cc8fbaf1f Mon Sep 17 00:00:00 2001 From: lgoette Date: Wed, 22 Dec 2021 11:13:53 +0100 Subject: [PATCH 14/21] update readme --- README.md | 2 +- main.py | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 2ef516b..a7a2a95 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Output will be stored in `output_file` if specified. #### Example output ``` -{"status": 1, "charge": {"left": 90, "right": 90, "case": 50}, "charging": "one", "model": "AirPods Pro", "date": "2020-10-23 09:10:11"} +{"status": 1, "charge": {"left": 95, "right": 95, "case": -1}, "charging_left": false, "charging_right": false, "charging_case": false, "model": "AirPodsPro", "date": "2021-12-22 11:09:05"} ``` ### Installing as a service diff --git a/main.py b/main.py index b6fccc7..a6b2e4f 100644 --- a/main.py +++ b/main.py @@ -102,7 +102,6 @@ def get_data(): charging_left:bool = (charging_status & (0b00000010 if flip else 0b00000001)) != 0 charging_right:bool = (charging_status & (0b00000001 if flip else 0b00000010)) != 0 charging_case:bool = (charging_status & 0b00000100) != 0 - charging_single:bool = (charging_status & 0b00000001) != 0 # Return result info in dict format return dict( @@ -115,7 +114,6 @@ def get_data(): charging_left=charging_left, charging_right=charging_right, charging_case=charging_case, - charging_single=charging_single, model=model, date=datetime.now().strftime('%Y-%m-%d %H:%M:%S'), raw=raw.decode("utf-8") @@ -124,7 +122,7 @@ def get_data(): # Return if left and right is flipped in the data def is_flipped(raw): - return (int("" + chr(raw[10]),16) & 0x02) == 0 + return (int("" + chr(raw[10]), 16) & 0x02) == 0 def run(): @@ -146,4 +144,4 @@ def run(): if __name__ == '__main__': - run() \ No newline at end of file + run() From 943d420b99035e34a8ffacf9648a0ff71c128b60 Mon Sep 17 00:00:00 2001 From: Klaus Umbach <939160+treibholz@users.noreply.github.com> Date: Mon, 3 Jan 2022 19:05:47 +0100 Subject: [PATCH 15/21] Cleanup unused dependencies and update bleak Pillow and pysystray are not used/needed here. Also bleak 0.7 has a bug with not closing open file-handles which results in crashes (may also fix #1 and #3) --- requirements.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index 31631ce..739a751 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1 @@ -pystray~=0.16.0 -bleak~=0.7.1 -Pillow~=7.2.0 \ No newline at end of file +bleak~=0.13.0 From db9de007035d2696373b578f6da589fc66fcbd63 Mon Sep 17 00:00:00 2001 From: ju Date: Sun, 9 Jan 2022 12:30:43 +0100 Subject: [PATCH 16/21] Add LICENSE closes #5 --- LICENSE | 674 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 674 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. From 2a283546a00d0e9c83653a92fbdac74343071ad6 Mon Sep 17 00:00:00 2001 From: Abdallah Abdelazim Date: Wed, 22 Jun 2022 21:20:37 +0200 Subject: [PATCH 17/21] Add python shebang line --- main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/main.py b/main.py index a6b2e4f..eedf494 100644 --- a/main.py +++ b/main.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 from bleak import discover from asyncio import new_event_loop, set_event_loop, get_event_loop from time import sleep, time_ns From 2e09948af153dfbf7d26d4445d8d8552c376ff07 Mon Sep 17 00:00:00 2001 From: Abdallah Abdelazim Date: Wed, 22 Jun 2022 21:22:24 +0200 Subject: [PATCH 18/21] Fix deprecation warning on Python newer than v3.6 --- main.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index eedf494..fe15c07 100644 --- a/main.py +++ b/main.py @@ -6,6 +6,8 @@ from json import dumps from sys import argv from datetime import datetime +import sys +import asyncio # Configure update duration (update after n seconds) UPDATE_DURATION = 1 @@ -55,11 +57,14 @@ async def get_device(): # Same as get_device() but it's standalone method instead of async def get_data_hex(): - new_loop = new_event_loop() - set_event_loop(new_loop) - loop = get_event_loop() - a = loop.run_until_complete(get_device()) - loop.close() + if sys.version_info < (3, 7): + new_loop = new_event_loop() + set_event_loop(new_loop) + loop = get_event_loop() + a = loop.run_until_complete(get_device()) + loop.close() + else: + a = asyncio.run(get_device()) return a From 2446422d783e7d5c5d6f7b72d327db455032ec0a Mon Sep 17 00:00:00 2001 From: Abdallah Abdelazim Date: Wed, 22 Jun 2022 21:24:39 +0200 Subject: [PATCH 19/21] Support breaking of loop with CTRL-C with no exceptions --- main.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/main.py b/main.py index fe15c07..e79d566 100644 --- a/main.py +++ b/main.py @@ -134,19 +134,22 @@ def is_flipped(raw): def run(): output_file = argv[-1] - while True: - data = get_data() - - if data["status"] == 1: - json_data = dumps(data) - if len(argv) > 1: - f = open(output_file, "a") - f.write(json_data+"\n") - f.close() - else: - print(json_data) - - sleep(UPDATE_DURATION) + try: + while True: + data = get_data() + + if data["status"] == 1: + json_data = dumps(data) + if len(argv) > 1: + f = open(output_file, "a") + f.write(json_data+"\n") + f.close() + else: + print(json_data) + + sleep(UPDATE_DURATION) + except KeyboardInterrupt: + pass if __name__ == '__main__': From 2d31eda7a8f9ab501d4b7fdde68bbff2c2e461be Mon Sep 17 00:00:00 2001 From: Abdallah Abdelazim Date: Wed, 22 Jun 2022 21:31:01 +0200 Subject: [PATCH 20/21] Add execute permission to --- main.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 main.py diff --git a/main.py b/main.py old mode 100644 new mode 100755 From 6d37599a23ed221760a18691791138713418fbb1 Mon Sep 17 00:00:00 2001 From: Abdallah Abdelazim Date: Wed, 22 Jun 2022 21:51:33 +0200 Subject: [PATCH 21/21] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a7a2a95..ac9ae02 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # **AirStatus for Linux** #### Check your AirPods battery level on Linux -#### What is it? +### What is it? This is a Python 3.6 script, forked from [faglo/AirStatus](https://github.com/faglo/AirStatus) that allows you to check AirPods battery level from your terminal, as JSON output. ### Usage @@ -12,6 +12,8 @@ python3 main.py [output_file] Output will be stored in `output_file` if specified. +This script requires `bleak` package. Install it with: `pip3 install bleak`. + #### Example output ```