From a1bbeafd8be662303294bdf1e2190af73f8594aa Mon Sep 17 00:00:00 2001 From: cuu Date: Wed, 22 Aug 2018 14:05:07 +0800 Subject: [PATCH] add bluetooth titlebar icon --- .../gameshell/titlebar_icons/bluetooth.png | Bin 0 -> 562 bytes sys.py/UI/title_bar.py | 41 +++++++++++++++--- 2 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 skin/default/sys.py/gameshell/titlebar_icons/bluetooth.png diff --git a/skin/default/sys.py/gameshell/titlebar_icons/bluetooth.png b/skin/default/sys.py/gameshell/titlebar_icons/bluetooth.png new file mode 100644 index 0000000000000000000000000000000000000000..439166b84c44862b6cba68aa7df5997276e7f5ad GIT binary patch literal 562 zcmV-20?qx2P)`%NAiIdKjB|04wMehR*)5CKcI_QP@%{?KMbyMyE@b|e?_GoHoXncTGY*X;SEbH|4n+CI_Lu+zVU zqy9VODCDK+;QLbYcFkUlVxKA@S;mdp40aQRoXjB^#cTxKPW(N5!OPg|;c5gv2;an3DCEqr_iQd1*e8EWay|%tCJH%I zn%b4*-PXg0M0y|P7I``X7L%L38tXT)cYU)L$F4*n#}cXi6ut_Nlhd{bk?pJ5-K5~1 zC=(4aws2LBd+0CjAEUF^Vivj6}907*qoM6N<$f@oU^ AApigX literal 0 HcmV?d00001 diff --git a/sys.py/UI/title_bar.py b/sys.py/UI/title_bar.py index c6fc40b..e2d1a08 100644 --- a/sys.py/UI/title_bar.py +++ b/sys.py/UI/title_bar.py @@ -58,6 +58,7 @@ class TitleBar: self.CheckBatteryStat() self.SyncSoundVolume() self.UpdateWifiStrength() + self.CheckBluetooth() SwapAndShow() # print("TitleBar Gobjectroundrobin") elif self._InLowBackLight >= 0: @@ -66,6 +67,7 @@ class TitleBar: self.CheckBatteryStat() self.SyncSoundVolume() self.UpdateWifiStrength() + self.CheckBluetooth() self._InLowBackLight = 0 return True @@ -95,12 +97,12 @@ class TitleBar: return ge def SyncSoundVolume(self): - try: + try: m = alsaaudio.Mixer() vol = m.getvolume()[0] - except Exception,e: - print(str(e)) - vol = 0 + except Exception,e: + print(str(e)) + vol = 0 snd_segs = [ [0,10],[10,30],[30,70],[70,100] ] @@ -176,6 +178,20 @@ class TitleBar: def SetBatteryStat(self,bat): pass + def CheckBluetooth(self): + out = commands.getstatusoutput("hcitool dev | grep hci0 |cut -f3") + if len(out[1]) < 17: + print("no bluetooth", out) + self._Icons["bluetooth"]._IconIndex = 2 + return + else: + out = commands.getstatusoutput("sudo rfkill list | grep hci0 -A 2 | grep yes") + if len(out[1]) > 10: + self._Icons["bluetooth"]._IconIndex = 1 + return + + self._Icons["bluetooth"]._IconIndex = 0 + def Init(self,screen): @@ -227,7 +243,16 @@ class TitleBar: self.SyncSoundVolume() - + + bluetooth = MultiIconItem() + bluetooth._MyType = ICON_TYPES["STAT"] + bluetooth._Parent = self + bluetooth._ImageName = icon_base_path+"bluetooth.png" + bluetooth.Adjust(start_x+self._icon_width+self._icon_width+8,self._icon_height/2+(self._BarHeight-self._icon_height)/2,self._icon_width,self._icon_height,0) + + self._Icons["bluetooth"] = bluetooth + self.CheckBluetooth() + round_corners = MultiIconItem() round_corners._IconWidth = 10 round_corners._IconHeight = 10 @@ -286,7 +311,9 @@ class TitleBar: start_x = Width-time_text_size[0]-self._ROffset-self._icon_width*3 # near by the time_text - self._Icons["sound"].NewCoord(start_x, self._icon_height/2+(self._BarHeight-self._icon_height)/2) + self._Icons["bluetooth"].NewCoord(start_x - self._icon_width,self._icon_height/2+(self._BarHeight-self._icon_height)/2) + + self._Icons["sound"].NewCoord(start_x, self._icon_height/2+(self._BarHeight-self._icon_height)/2) #self._Icons["wifi"].NewCoord(start_x+self._icon_width+5, self._icon_height/2+(self._BarHeight-self._icon_height)/2) @@ -316,6 +343,8 @@ class TitleBar: self._Icons["battery"].Draw() + self._Icons["bluetooth"].Draw() + pygame.draw.line(self._CanvasHWND,self._SkinManager.GiveColor("Line"),(0,self._BarHeight),(self._Width,self._BarHeight),self._BorderWidth) if self._HWND != None: