This repository has been archived on 2024-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/bin/bspwm_load_state_canvas

28 lines
624 B
Python
Executable file

#! /usr/bin/env python3
import sys
import json
source = open(sys.argv[1]) if len(sys.argv) > 1 else sys.stdin
state = json.load(source)
def nullify_clients(node):
if node is None:
return
elif node['client'] is None:
nullify_clients(node['firstChild'])
nullify_clients(node['secondChild'])
else:
node['client'] = None
state['clientsCount'] = 0
state['focusHistory'] = []
state['stackingList'] = []
for monitor in state['monitors']:
for desktop in monitor['desktops']:
desktop['focusedNodeId'] = 0
nullify_clients(desktop['root'])
print(json.dumps(state))