Skip to content

Instantly share code, notes, and snippets.

/bspwm.py

Created Jan 21, 2016
Embed
What would you like to do?
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