You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

status.py 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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="\uf240 {percentage}% {time_to_full}",
  33. format_dis="\uf241 {percentage}% {time_to_empty}",
  34. format_dis_alert="\uf244 {percentage}% {time_to_empty}",
  35. format_full="\uf240 {percentage}%",
  36. format_dpl="\uf240",
  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="\uf07d {ping:03.0f} ms",
  104. format_down="\uf07d 000 ms",
  105. format_pause="\uf07d 000 ms")
  106. def get_iface_param(iface):
  107. if isinstance(iface, list):
  108. return iface[0], iface[1]
  109. return iface, iface
  110. ifaces_wireless = ["wlan0", "wlan1"]
  111. ifaces_wired = ["eth0", "usb0", "br0"]
  112. ifaces_tun = [["tap42", "rthoni.com"], ["tun200", "inet"]]
  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. unknown_up=True)
  124. for iface in ifaces_wired:
  125. iface, iface_name = get_iface_param(iface)
  126. status.register("network",
  127. interval=1,
  128. interface=iface,
  129. color_up=g_color_good,
  130. format_down="\uf0e8 " + iface_name,
  131. format_down_hide="\uf0e8",
  132. format_up="\uf0e8 {v4}",
  133. format_up_hide="\uf0e8 " + iface_name,
  134. unknown_up=True)
  135. for iface in ifaces_tun:
  136. iface, iface_name = get_iface_param(iface)
  137. status.register("network",
  138. interval=1,
  139. interface=iface,
  140. color_up=g_color_good,
  141. format_down="\uf070 " + iface_name,
  142. format_down_hide="\uf070",
  143. format_up="\uf070 {v4}",
  144. format_up_hide="\uf070 " + iface_name,
  145. unknown_up=True).switch_hide()
  146. status.run()