Skip to content
Snippets Groups Projects
Commit a375f7d0 authored by Jiří Kalvoda's avatar Jiří Kalvoda
Browse files

Swap masters

parent 5f131f95
Branches
No related tags found
No related merge requests found
......@@ -52,6 +52,35 @@ def move_container(master, slave):
shared.i3_cmd(f'move container to workspace {workspace(master, slave)}')
shared.qt_task("ws_changed", master, slave)
def swap_master(a, b):
do_after = []
def proc_one_direction(a, b):
for i in shared.master_on:
if a == shared.master_on[i]:
@do_after.append
def _():
shared.master_on[i] = b
for i in shared.slave_on_for:
x = shared.slave_on_for[i][a]
@do_after.append
def _():
shared.slave_on_for[i][b] = x
x = shared.slave_for[a]
@do_after.append
def _():
shared.slave_for[b] = x
proc_one_direction(a, b)
proc_one_direction(b, a)
for slave in range(MIN_SLAVE, MAX_MASTERED_SLAVE+1):
swap_workspace(a, slave, b, slave)
for f in do_after:
f()
for slave in range(MIN_SLAVE, MAX_MASTERED_SLAVE+1):
shared.qt_task("ws_metadata_changed", a, slave)
shared.qt_task("ws_metadata_changed", b, slave)
def swap_workspace(a_master, a_slave, b_master, b_slave):
if (a_master, a_slave) == (b_master, b_slave):
......
......@@ -111,6 +111,18 @@ def mf_goto_workspace(params):
n_master, n_slave = params_workspace(params)
goto_workspace(n_master, n_slave)
@main_function(["swap-master-with", "sm"], [
arg('-m', "--master", type=MasterType, help="Switch master workspace"),
arg('-n', "--notify", action='store_true'),
] , "Swap current master with specified master.")
def mf_swap_master_with(params):
current = shared.workspace_on[shared.output]
if current[0] is not None and current != GUI_WORKSPACE:
n_master, n_slave = get_workspace(params.master)
if params.notify:
osd.notify(f"MASTER {n_master}", color="magenta", to='display', min_duration=0, duration=500)
swap_master(n_master, current[0])
@main_function(["swap-with-workspace", "s"], std_parser, "Swap current workspace with specified workspace.")
def mf_swap_with_workspace(params):
current = shared.workspace_on[shared.output]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment