Demos the move of active container to workspace based on mouse cursor
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
**__pycache__/
|
||||||
38
README.rst
38
README.rst
@@ -90,15 +90,35 @@ Example config to be inserted into your i3 config.
|
|||||||
workspace $RightWs7 output $right
|
workspace $RightWs7 output $right
|
||||||
workspace $RightWs8 output $right
|
workspace $RightWs8 output $right
|
||||||
|
|
||||||
# Binded
|
# Shift workspace
|
||||||
bindsym $mod+Mod1+1 exec pi3-smart-workspace -i 1
|
bindsym $mod+1 exec pi3-smart-workspace -i 1
|
||||||
bindsym $mod+Mod1+2 exec pi3-smart-workspace -i 2
|
bindsym $mod+2 exec pi3-smart-workspace -i 2
|
||||||
bindsym $mod+Mod1+3 exec pi3-smart-workspace -i 3
|
bindsym $mod+3 exec pi3-smart-workspace -i 3
|
||||||
bindsym $mod+Mod1+4 exec pi3-smart-workspace -i 4
|
bindsym $mod+4 exec pi3-smart-workspace -i 4
|
||||||
bindsym $mod+Mod1+5 exec pi3-smart-workspace -i 5
|
bindsym $mod+5 exec pi3-smart-workspace -i 5
|
||||||
bindsym $mod+Mod1+6 exec pi3-smart-workspace -i 6
|
bindsym $mod+6 exec pi3-smart-workspace -i 6
|
||||||
bindsym $mod+Mod1+7 exec pi3-smart-workspace -i 7
|
bindsym $mod+7 exec pi3-smart-workspace -i 7
|
||||||
bindsym $mod+Mod1+8 exec pi3-smart-workspace -i 8
|
bindsym $mod+8 exec pi3-smart-workspace -i 8
|
||||||
|
|
||||||
|
# Move focused container to workspace
|
||||||
|
bindsym $mod+Ctrl+1 exec pi3-smart-workspace -i 1 -s
|
||||||
|
bindsym $mod+Ctrl+2 exec pi3-smart-workspace -i 2 -s
|
||||||
|
bindsym $mod+Ctrl+3 exec pi3-smart-workspace -i 3 -s
|
||||||
|
bindsym $mod+Ctrl+4 exec pi3-smart-workspace -i 4 -s
|
||||||
|
bindsym $mod+Ctrl+5 exec pi3-smart-workspace -i 5 -s
|
||||||
|
bindsym $mod+Ctrl+6 exec pi3-smart-workspace -i 6 -s
|
||||||
|
bindsym $mod+Ctrl+7 exec pi3-smart-workspace -i 7 -s
|
||||||
|
bindsym $mod+Ctrl+8 exec pi3-smart-workspace -i 8 -s
|
||||||
|
|
||||||
|
# Move to workspace with focused container
|
||||||
|
bindsym $mod+Shift+1 exec pi3-smart-workspace -i 1 -sk
|
||||||
|
bindsym $mod+Shift+2 exec pi3-smart-workspace -i 2 -sk
|
||||||
|
bindsym $mod+Shift+3 exec pi3-smart-workspace -i 3 -sk
|
||||||
|
bindsym $mod+Shift+4 exec pi3-smart-workspace -i 4 -sk
|
||||||
|
bindsym $mod+Shift+5 exec pi3-smart-workspace -i 5 -sk
|
||||||
|
bindsym $mod+Shift+6 exec pi3-smart-workspace -i 6 -sk
|
||||||
|
bindsym $mod+Shift+7 exec pi3-smart-workspace -i 7 -sk
|
||||||
|
bindsym $mod+Shift+8 exec pi3-smart-workspace -i 8 -sk
|
||||||
|
|
||||||
|
|
||||||
Credits
|
Credits
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -7,9 +7,9 @@ import argparse
|
|||||||
|
|
||||||
class WorkSpacer:
|
class WorkSpacer:
|
||||||
|
|
||||||
def __init__(self, index):
|
def __init__(self, args):
|
||||||
self.i3 = None
|
self.i3 = None
|
||||||
self.index = index
|
self.args = args
|
||||||
self.workspaces_on_outputs = {}
|
self.workspaces_on_outputs = {}
|
||||||
self.workspaces = None
|
self.workspaces = None
|
||||||
self.outputs = None
|
self.outputs = None
|
||||||
@@ -49,7 +49,12 @@ class WorkSpacer:
|
|||||||
self._connect()
|
self._connect()
|
||||||
self.mouse_position = self.mouse.position
|
self.mouse_position = self.mouse.position
|
||||||
self.current_output_name = self._get_workspace_from_courser_position()
|
self.current_output_name = self._get_workspace_from_courser_position()
|
||||||
self.i3.command(f'workspace {self.workspaces_on_outputs[self.current_output_name][self.index]}')
|
|
||||||
|
if self.args.shift:
|
||||||
|
self.i3.command(f'move container to workspace {self.workspaces_on_outputs[self.current_output_name][self.args.index - 1]}')
|
||||||
|
if not self.args.keep_with_it:
|
||||||
|
return
|
||||||
|
self.i3.command(f'workspace {self.workspaces_on_outputs[self.current_output_name][self.args.index - 1]}')
|
||||||
|
|
||||||
def _get_workspace_from_courser_position(self):
|
def _get_workspace_from_courser_position(self):
|
||||||
for output in self.outputs:
|
for output in self.outputs:
|
||||||
@@ -79,10 +84,18 @@ def main():
|
|||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description="Dynamic changes the workspace, based on what output your cursoer is on."
|
description="Dynamic changes the workspace, based on what output your cursoer is on."
|
||||||
)
|
)
|
||||||
parser.add_argument("-i", "--index", type=int,
|
|
||||||
|
required_group = parser.add_argument_group('Required', '')
|
||||||
|
required_group.add_argument("-i", "--index", type=int, required=True,
|
||||||
help="the number index of the workspace that should be openend. 1 = first workspace in config etc.")
|
help="the number index of the workspace that should be openend. 1 = first workspace in config etc.")
|
||||||
ws = WorkSpacer(parser.parse_args().index - 1)
|
|
||||||
ws.run()
|
shift_group = parser.add_argument_group('Shift', 'manipulate the active window')
|
||||||
|
shift_group.add_argument("-s", "--shift", action='store_true',
|
||||||
|
help="if present, moves the current active window to target workspace")
|
||||||
|
shift_group.add_argument('-k', '--keep-with-it', action='store_true',
|
||||||
|
help='if present, moves with the ')
|
||||||
|
|
||||||
|
WorkSpacer(parser.parse_args()).run()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
Reference in New Issue
Block a user