From 5dc72ab291d8b4435c3733db02c5ac25c7bf2754 Mon Sep 17 00:00:00 2001 From: Siarhei Siniak Date: Tue, 31 May 2022 11:51:39 +0300 Subject: [PATCH] [~] Refactor --- dotfiles/.local/bin/commands | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/dotfiles/.local/bin/commands b/dotfiles/.local/bin/commands index 450a0ae..3b76c09 100755 --- a/dotfiles/.local/bin/commands +++ b/dotfiles/.local/bin/commands @@ -336,14 +336,30 @@ def eternal_firefox( #assert os.system('wmctrl -i -r %s -e %s' % (t2, window_position)) == 0 #assert os.system('wmctrl -i -r %s -b add,below' % t2) == 0 def reposition(): - assert os.system(r''' - swaymsg '[pid="{{PID}}"] move absolute position {{X}}px {{Y}}px' && \ - swaymsg '[pid="{{PID}}"] move window to workspace {{WORKSPACE}}' - '''.replace('{{PID}}', str(p.pid)) \ + t1 = lambda s: \ + s \ + .replace('{{PID}}', str(p.pid)) \ .replace('{{X}}', str(window_position[1])) \ .replace('{{Y}}', str(window_position[2])) \ - .replace('{{WORKSPACE}}', str(window_position[0]))) == 0 - reposition() + .replace('{{W}}', str(window_position[3])) \ + .replace('{{H}}', str(window_position[4])) \ + .replace('{{WORKSPACE}}', str(window_position[0])) + + assert os.system(t1(r''' + swaymsg '[pid="{{PID}}"] move window to workspace {{WORKSPACE}}' + ''')) == 0 + + if window_position[1] != '' and window_position[2] != '': + assert os.system(t1(r''' + swaymsg '[pid="{{PID}}"] floating enable' \ + swaymsg '[pid="{{PID}}"] resize set width {{W}}px height {{H}}px' && \ + swaymsg '[pid="{{PID}}"] move absolute position {{X}}px {{Y}}px' + ''')) == 0 + else: + assert os.system(t1(r''' + swaymsg '[pid="{{PID}}"] floating disable' + ''')) == 0 + if False: for tab in tabs[1:]: @@ -356,6 +372,8 @@ def eternal_firefox( ]) == 0 + reposition() + if debug: assert subprocess.check_call(['notify-send', '%s:Started' % group_name]) == 0