fork download
  1. #!/usr/bin/env python
  2.  
  3. #imports
  4. import i3ipc,re,subprocess,time
  5. # <Settings>
  6. I3_CONNECTION = i3ipc.Connection()
  7. PRIMARY_SOUND_DEV = "alsa_output.usb-Logitech_Logitech_USB_Headset-00.analog-stereo"
  8. SECONDARY_SOUND_DEV = "alsa_output.pci-0000_00_1b.0.analog-stereo"
  9. # Colors in hex
  10. WS_COLOR_UNDERLINE = "#62AFEE"
  11. WS_COLOR_NORMAL = "#dddddd"
  12. WS_COLOR_HIGHLIGHT = "#ffffff"
  13. WS_COLOR_ICON = "#62AFEE"
  14. COLOR_UNDERLINE = "%{F#62AFEE}"
  15. COLOR_ICON = "%{F#62AFEE}"
  16. COLOR_TEXT = "%{F#dddddd}"
  17. COLOR_RED = "%{F#FF0000}"
  18. END_COLOR = "%{F-}"
  19. # Align bar objects
  20. LEFT = "%{l}"
  21. CENTER = "%{c}"
  22. RIGHT = "%{r}"
  23. GAP = "%{O10}"
  24. SEP = " "
  25. UNDERLINE_INIT = "%{+u}%{U#62AFEE}"
  26. UNDERLINE_END = "%{U-}%{-u}"
  27. OVERLINE_INIT = "%{+o}%{O#62AFEE}"
  28. OVERLINE_END = "%{O-}%{-o}"
  29. #icons - AwesomeFont
  30. WORKSPACES = ""
  31. TIME = ""
  32. DATE = ""
  33. VOLUME = ""
  34. HEADPHONES = ""
  35. PLAY = ""
  36. PAUSE = ""
  37. NEXT = ""
  38. BACK = ""
  39. STOP = ""
  40. WALLPAPER = ""
  41. BATTERY_CRITICAL = "" # 5%
  42. BATTERY_LOW = "" # 25%
  43. BATTERY_HALF = "" # 50%
  44. BATTERY_ALMOST = "" # 75%
  45. BATTERY_FULL = "" # 100%
  46. WIRED = ""
  47. #</Settings>
  48.  
  49.  
  50. def get_volume(pdev,sdev):
  51. raw = run("pactl list sinks"); icon = ""; action = "" ; nn = 0
  52. if pdev in raw:
  53. dev = pdev; icon = HEADPHONES; nn = 150
  54. actions = "%{A1:pavucontrol:}%{A4:amixer -q -D sysdefault sset Headphone 10%+ unmute:}%{A5:amixer -q -D sysdefault sset Headphone 10%- unmute:}"
  55. elif sdev in raw:
  56. dev = sdev; icon = VOLUME; nn = 100
  57. actions = "%{A1:pavucontrol:}%{A4:amixer -q sset Master 10%+ unmute:}%{A5:amixer -q sset Master 10%- unmute:}"
  58. else:
  59. return COLOR_ICON + VOLUME + COLOR_TEXT + "nosnd"
  60.  
  61. find = raw.splitlines()[8]
  62. sraw = raw.splitlines()
  63. y = 0; x = 0; n = 0
  64. for x in range (0,nn):
  65. if dev in sraw[x]:
  66. y = x
  67. for y in range (x,nn):
  68. if find in sraw[y]:
  69. n = y
  70. break
  71. break
  72. num = n+1
  73. s = sraw[num:num+1][0]
  74. m = sraw[num-1:num][0]
  75.  
  76. value = s[s.find("/ ")+2:s.find("%")]
  77. if m[m.find("Звук выключен: ")+15:]=="yes":
  78. value = "muted"
  79. return COLOR_ICON + actions + icon + "%{A}%{A}%{A}" + COLOR_TEXT + value
  80. elif m[m.find("Звук выключен: ")+15:]=="no":
  81. return COLOR_ICON + actions + icon + "%{A}%{A}%{A}" + COLOR_TEXT + value +"%"
  82.  
Runtime error #stdin #stdout #stderr 0.01s 9024KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "prog.py", line 4, in <module>
ImportError: No module named i3ipc