macos-wm/.config/bitbar/chunkwm-ws.1s.py

36 lines
977 B
Python
Executable File

#!/usr/bin/env python3
import json
import subprocess
CYAN='\033[0;36m'
BLUE='\033[0;34m'
NC='\033[0m'
YABAI = '/usr/local/bin/yabai'
desktops = json.loads(subprocess.check_output(
[YABAI, '-m', 'query', '--spaces']))
recent_desktop = json.loads(subprocess.check_output(
[YABAI, '-m', 'query', '--spaces', '--space', 'recent']))
def pick_color(desktop):
if desktop['focused']:
return CYAN
elif desktop == recent_desktop:
return BLUE
else:
return ''
print(' '.join([pick_color(d) + str(d['index']) + NC for d in desktops]))
# TODO: convert to python when yabai supports serialization
# echo '---'
# for i in ~/.chunkwm_layouts/*
# do
# echo "Load $(basename $i) | terminal=false bash='/usr/local/bin/chunkc' param1='tiling::desktop' param2='--deserialize' param3='$i'"
# echo "Save $(basename $i) | alternate=true terminal=false bash='/usr/local/bin/chunkc' param1='tiling::desktop' param2='--serialize' param3='$i'"
# done