config.py 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. # -*- coding: utf-8 -*-
  2. import os
  3. import platform
  4. from UI.util_funcs import FileExists,ArmSystem,ReadTheFileContent
  5. from pyaria2_rpc.pyaria2 import Xmlrpc
  6. CurKeySet = "GameShell" ## >>> PC or GameShell <<<
  7. DontLeave = False
  8. BackLight = "/proc/driver/backlight"
  9. Battery = "/sys/class/power_supply/axp20x-battery/uevent"
  10. FB_Modes = "/sys/class/graphics/fb0/modes"
  11. MPD_socket = "/tmp/mpd.socket"
  12. UPDATE_URL="https://raw.githubusercontent.com/clockworkpi/CPI/master/launcher_ver0.4.json"
  13. VERSION="stable 1.25"
  14. SKIN=None
  15. ButtonsLayout="xbox"
  16. RPC = None
  17. ## three timer values in seconds: dim screen, close screen,PowerOff
  18. ## zero means no action
  19. PowerLevels = {}
  20. PowerLevels["supersaving"] = [10,30,120]
  21. PowerLevels["powersaving"] = [40,120,300]
  22. PowerLevels["server"] = [40,120,0]
  23. PowerLevels["balance_saving"] = [40,0,0]
  24. PowerLevel = "balance_saving"
  25. GlobalCanvas=None
  26. GlobalScale = 1
  27. def PreparationInAdv():
  28. global SKIN,ButtonsLayout,FB_Modes,GlobalScale
  29. global PowerLevel
  30. global RPC
  31. if SKIN != None:
  32. return
  33. SKIN= "../skin/default"
  34. if FileExists("%s/.gameshell_skin" % os.path.expanduser('~')) == True:
  35. with open("%s/.gameshell_skin" % os.path.expanduser('~'),"r") as f:
  36. gameshell_skin = f.read()
  37. gameshell_skin = gameshell_skin.strip()
  38. SKIN= gameshell_skin
  39. if FileExists(".buttonslayout") == True:
  40. with open(".buttonslayout") as f:
  41. btnlayout = f.read()
  42. btnlayout = btnlayout.strip()
  43. ButtonsLayout = btnlayout
  44. if ButtonsLayout != "xbox" and ButtonsLayout != "snes":
  45. ButtonsLayout = "xbox"
  46. if FileExists(".powerlevel") == False:
  47. os.system("touch .powerlevel")
  48. with open(".powerlevel","r") as f:
  49. powerlevel = f.read()
  50. powerlevel = powerlevel.strip()
  51. if powerlevel != "":
  52. PowerLevel = powerlevel
  53. if powerlevel != "supersaving":
  54. ArmSystem("sudo iw wlan0 set power_save off >/dev/null")
  55. else:
  56. ArmSystem("sudo iw wlan0 set power_save on > /dev/null")
  57. else:
  58. ArmSystem("sudo iw wlan0 set power_save off >/dev/null")
  59. if FileExists(FB_Modes):
  60. modes = ReadTheFileContent(FB_Modes)
  61. if "320x240" in modes:
  62. GlobalScale = 1
  63. if "640x480" in modes:
  64. GlobalScale = 2
  65. if "480x640" in modes:
  66. GlobalScale = 2
  67. RPC = Xmlrpc('localhost', 6800)
  68. PreparationInAdv()
  69. ##sys.py/.powerlevel