Advertisement
Guest User

i3-workspaces.py

a guest
Jun 16th, 2016
432
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.88 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import i3ipc
  4.  
  5. i3 = i3ipc.Connection()
  6.  
  7. # define colors
  8. focus_bg_color = "#008b8b"
  9. bg_color = "#556b2f"
  10. inactive_bg_color = "#393939"
  11. text_color = "#f3f4f5"
  12. inactive_text_color = "#676E7D"
  13. urgent_bg_color = "#E53935"
  14. seperator_color = "#cae1ff"
  15. seperator_text_color = "#393939"
  16.  
  17. def lemon_escape(ws):
  18.     return ws.replace(':', '\\:')
  19.  
  20. def lemon_click(ws):
  21.     return "%{A:i3-msg workspace "+lemon_escape(ws)+":}"+ws+"%{A}"
  22.  
  23. def decorate_normal(ws):
  24.     return "%{B"+bg_color+"} "+lemon_click(ws)+" %{B-}"
  25.  
  26. def decorate_urgent(ws):
  27.     return "%{B"+urgent_bg_color+"} "+lemon_click(ws)+" %{B-}"
  28.  
  29. def decorate_focused(ws):
  30.     return "%{B"+focus_bg_color+"} "+lemon_click(ws)+" %{B-}"
  31.  
  32. def print_workspaces():
  33.     workspaces = i3.get_workspaces()
  34.     output0=[]
  35.     output1=[]
  36.     for i in workspaces:
  37.         if i['focused']==True:
  38.             tmp = decorate_focused(i['name'])
  39.         elif i['urgent']==True:
  40.             tmp = decorate_urgent(i['name'])
  41.         else:
  42.             tmp = decorate_normal(i['name'])
  43.         if i['output']=="LVDS1":
  44.             if i['name'] != "♪:Music":
  45.                 output0.append(tmp)
  46.             else:
  47.                 output0.insert(0,tmp)
  48.         else:
  49.             if i['name'] != "♪:Music":
  50.                 output1.append(tmp)
  51.             else:
  52.                 output1.insert(0,tmp)
  53.     print("WS%{B"+seperator_color+"}%{F"+seperator_text_color+"}  %{F-}"+"".join(output0)+"%{B"+seperator_color+"}%{F"+seperator_text_color+"}  %{F-}"+"".join(output1))
  54.  
  55. print_workspaces()
  56.  
  57. def on_workspace_focus(self, e):
  58.     print_workspaces()
  59.  
  60.  
  61. # Show current mode
  62. def on_mode_change(self, event):
  63.     out = event.change
  64.     if out != "default":
  65.         print ("EV"+out+" ")
  66.     else:
  67.         print ("EV")
  68.  
  69.  
  70. i3.on('workspace::', on_workspace_focus)
  71.  
  72. i3.on('mode::', on_mode_change)
  73.  
  74. i3.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement