diff options
author | Camil Staps | 2016-04-03 14:34:04 +0200 |
---|---|---|
committer | Camil Staps | 2016-11-30 19:11:08 +0100 |
commit | a11ea3b0f8c65799e0adba34a6eaaef22267446b (patch) | |
tree | 9e8b801bc83969117aff65baf8648a1bca3960b9 /bin/i3ws | |
parent | Bindsyms for moving workspaces (diff) |
Using xmobar instead of i3bar/i3status
Diffstat (limited to 'bin/i3ws')
-rwxr-xr-x | bin/i3ws | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/bin/i3ws b/bin/i3ws new file mode 100755 index 0000000..a1c487a --- /dev/null +++ b/bin/i3ws @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 +from functools import partial +import json +from subprocess import check_output +import sys + +def get_unique(func, wss): + return list(set(map(func, wss))) + +def get_unique_key(key, wss): + return get_unique(lambda ws: ws[key], wss) + +def show_workspace(ws): + color = 'f00' if ws['urgent'] else \ + '00fcff' if ws['focused'] else \ + '6aa3f8' if ws['visible'] else \ + '777' + return '<fc=#%s>%s</fc>' % (color, ws['name']) + +def show_output(wss, op): + wss = list(filter(lambda ws: ws['output'] == op, wss)) + wss.sort(key=lambda ws: ws['name']) + + return op + ' ' + ' '.join(map(show_workspace, wss)) + +def main(): + i3ws = check_output(['i3-msg', '-t', 'get_workspaces']).decode('utf-8') + wss = json.loads(i3ws) + + outputs = sorted(get_unique_key('output', wss)) + print(' * '.join(map(partial(show_output, wss), outputs))) + +if __name__ == '__main__': + main() + |