Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

status.py 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. #!/bin/python3
  2. # coding=utf-8
  3. from i3pystatus import Status
  4. from i3status.upower import UPower
  5. from i3status.network_traffic import NetworkTraffic
  6. from i3status.ping import Ping
  7. from i3status.arch_updates import ArchUpdates
  8. from i3status.my_ip import MyIP
  9. # We change i3pystatus
  10. import i3status.change_i3pystatus
  11. i3status.change_i3pystatus.change_all()
  12. ###############################################################################
  13. # COLORS
  14. ###############################################################################
  15. g_color_normal = "#AEAEAE"
  16. g_color_second = "#66E0FF"
  17. g_color_good = "#8DE28D"
  18. g_color_warn = "#D68533"
  19. g_color_alert = "#FF5555"
  20. ###############################################################################
  21. # Clock
  22. ###############################################################################
  23. status = Status(standalone=True)
  24. status.register("clock",
  25. color=g_color_second,
  26. format="%d/%m/%y %H:%M:%S")
  27. ###############################################################################
  28. # Battery, sound and light
  29. ###############################################################################
  30. status.register(UPower,
  31. alert_percent=30,
  32. format_chr="\uf214↑ {percentage}% {time_to_full}",
  33. format_dis="\uf214↓ {percentage}% {time_to_empty}",
  34. format_dis_alert="\uf215↓ {percentage}% {time_to_empty}",
  35. format_full="\uf213 {percentage}%",
  36. format_dpl="\uf212",
  37. color_chr=g_color_second,
  38. color_dis=g_color_warn,
  39. color_dis_alert=g_color_alert,
  40. color_full=g_color_good,
  41. color_dpl=g_color_alert)
  42. status.register("alsa",
  43. mixer="Master",
  44. card=0,
  45. color_muted=g_color_warn,
  46. format_muted="\uf026 0%",
  47. format="\uf028 {volume:.0f}%")
  48. #status.register("backlight",
  49. # interval=1,
  50. # backlight="acpi_video0",
  51. # format="\uf39b {percentage}%")
  52. ###############################################################################
  53. # Processor and memory status
  54. ###############################################################################
  55. #status.register("temp",
  56. # file="/sys/class/thermal/thermal_zone1/temp",
  57. #alert_temp=55,
  58. # color=g_color_good,
  59. #alert_color=g_color_alert,
  60. # format="\uf3b6 {temp:.0f}°C")
  61. status.register("cpu_usage",
  62. format="\uf0e4 {usage:02}%")
  63. status.register("mem",
  64. color=g_color_good,
  65. warn_color=g_color_warn,
  66. alert_color=g_color_alert,
  67. format="\uf085 {avail_mem:.0f}M")
  68. ###############################################################################
  69. # Pacman
  70. ###############################################################################
  71. #status.register(ArchUpdates,
  72. # format=u"\uf500{count_pacman}|{count_yaourt}")
  73. ###############################################################################
  74. # disk usage
  75. ###############################################################################
  76. status.register("disk",
  77. path="/",
  78. critical_limit=7,
  79. format="\uf07b {avail}G")
  80. status.register("disk",
  81. path="/home",
  82. critical_limit=5,
  83. format="\uf015 {avail}G")
  84. ###############################################################################
  85. # Network
  86. ###############################################################################
  87. ifaces_traffic = ["eth0", "wlan0"]
  88. status.register(NetworkTraffic,
  89. interfaces=ifaces_traffic,
  90. divisor=1024**2,
  91. round_size=2,
  92. color=g_color_second,
  93. format="\uf063 {bytes_recv:.2f}")
  94. status.register(NetworkTraffic,
  95. interfaces=ifaces_traffic,
  96. divisor=1024**2,
  97. round_size=2,
  98. color=g_color_warn,
  99. format="\uf062 {bytes_sent:.2f}")
  100. status.register(Ping,
  101. color=g_color_good,
  102. color_down=g_color_alert,
  103. format="\uf368 {ping:03.0f} ms",
  104. format_down="\uf368 ∞ ms")
  105. def get_iface_param(iface):
  106. if isinstance(iface, list):
  107. return iface[0], iface[1]
  108. return iface, iface
  109. ifaces_wireless = ["wlan0"]
  110. ifaces_wired = ["eth0"]
  111. ifaces_tun = [["tun0", "rthoni.com"], ["tun1", "inet"],
  112. ["tun2", "epimafia-inet"], ["tun3", "betaclean"]]
  113. for iface in ifaces_wireless:
  114. iface, iface_name = get_iface_param(iface)
  115. status.register("network",
  116. interval=1,
  117. interface=iface,
  118. color_up=g_color_good,
  119. format_down="\uf1eb " + iface_name,
  120. format_down_hide="\uf1eb",
  121. format_up="\uf1eb {essid} ({quality:03.0f}%) {v4}",
  122. format_up_hide="\uf1eb " + iface_name)
  123. for iface in ifaces_wired:
  124. iface, iface_name = get_iface_param(iface)
  125. status.register("network",
  126. interval=1,
  127. interface=iface,
  128. color_up=g_color_good,
  129. format_down="\uf0e8 " + iface_name,
  130. format_down_hide="\uffe8",
  131. format_up="\uf0e8 {v4}",
  132. format_up_hide="\uf0e8 " + iface_name)
  133. for iface in ifaces_tun:
  134. iface, iface_name = get_iface_param(iface)
  135. status.register("network",
  136. interval=1,
  137. interface=iface,
  138. color_up=g_color_good,
  139. format_down="\uf070 " + iface_name,
  140. format_down_hide="\uf070",
  141. format_up="\uf070 {v4}",
  142. format_up_hide="\uf070 " + iface_name,
  143. unknown_up=True).switch_hide()
  144. status.run()