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 0000000..439166b Binary files /dev/null and b/skin/default/sys.py/gameshell/titlebar_icons/bluetooth.png differ 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: