Skip to content

Instantly share code, notes, and snippets.

Created January 21, 2016 08:48
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save anonymous/b539fbbcb6e5c1afc403 to your computer and use it in GitHub Desktop.
powerline/segments/bspwm.py
#!/usr/bin/env python
from powerline.lib.shell import run_cmd
## Reusing tmux highlight groups for now
highlight_groups = {
'O': 'window:current',
'o': 'window',
'F': 'window:current',
'f': 'window',
'U': 'bell_status',
'u': 'bell_status'
}
def workspaces(pl):
## Couldn't figure out how to take advantage of --subscribe
status = run_cmd(pl, ['bspc', 'control', '--get-status'])
state = []
for desktop in status.rstrip().split(':')[1:-1]:
contents = desktop[1:]
if desktop[0] == 'O':
contents += '*'
elif desktop[0] == 'o':
contents += '-'
state.append(
{
'contents': contents,
'highlight_groups': [highlight_groups[desktop[0]]],
'draw_inner_divider': True
}
)
return state
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment