Fixes a problem with args parse and updates the readme
This commit is contained in:
112
README.rst
112
README.rst
@@ -10,55 +10,103 @@ Usage
|
|||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
usage: pi3-smar-switch [-h] [-f] [-p | -m | -s] WORKSPACE_NAME
|
usage: pi3-smart-switch [-h] -i num
|
||||||
|
Openens the [i] number of workspace assigned in the config, on the output the cursor is currently on.
|
||||||
|
|
||||||
Moves selected i3 workspace to the current output (by default determined by
|
|
||||||
cursor location) and focuses it.
|
|
||||||
|
|
||||||
positional arguments:
|
|
||||||
workspace name of the i3 workspace
|
|
||||||
|
|
||||||
optional arguments:
|
|
||||||
-h, --help show this help message and exit
|
|
||||||
-f, --focus use focused window instead of cursor position to determine the
|
|
||||||
current output
|
|
||||||
-p, --push moves replaced workspace to the second output (works only if
|
|
||||||
there are two outputs, ignored otherwise)
|
|
||||||
-m, --master same as 'push' but will only move from primary output to the
|
|
||||||
secondary
|
|
||||||
-s, --swap (NOT IMPLEMENTED YET) behaves like xmonad, swaps workspaces if
|
|
||||||
they are on a different output
|
|
||||||
|
|
||||||
|
requred arguments:
|
||||||
|
-i, --index the number index of the workspace that should be openend. 1 = first workspace in config etc.
|
||||||
Installation
|
Installation
|
||||||
------------
|
------------
|
||||||
|
|
||||||
Install using `pipsi`_ (recommended) or pip:
|
Install using pip (recommended):
|
||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
pipsi install pi3-switch
|
pip install pi3-switch
|
||||||
|
|
||||||
Add keybindings to ~/.config/i3/config and reload i3 (remember to modify flags to your liking):
|
Example config to be inserted into your i3 config.
|
||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
bindsym $mod+1 exec pi3-switch -p 1
|
# Displays
|
||||||
bindsym $mod+2 exec pi3-switch -p 2
|
set $primary DP-2
|
||||||
bindsym $mod+3 exec pi3-switch -p 3
|
set $left HDMI-0
|
||||||
bindsym $mod+4 exec pi3-switch -p 4
|
set $right HDMI-1
|
||||||
bindsym $mod+5 exec pi3-switch -p 5
|
|
||||||
bindsym $mod+6 exec pi3-switch -p 6
|
# WOrkspaces
|
||||||
bindsym $mod+7 exec pi3-switch -p 7
|
set $ws1 1:1:Code
|
||||||
bindsym $mod+8 exec pi3-switch -p 8
|
set $ws2 2:2:Code
|
||||||
bindsym $mod+9 exec pi3-switch -p 9
|
set $ws3 3:3:Code
|
||||||
bindsym $mod+0 exec pi3-switch -p 10
|
set $ws4 4:4:Code
|
||||||
|
set $ws5 5:5:Code
|
||||||
|
set $ws6 6:6:Code
|
||||||
|
set $ws7 7:7:Code
|
||||||
|
set $ws8 8:8:Code
|
||||||
|
|
||||||
|
set $LeftWs1 1:1:Browser
|
||||||
|
set $LeftWs2 2:2:Left
|
||||||
|
set $LeftWs3 3:3:Left
|
||||||
|
set $LeftWs4 4:4:Left
|
||||||
|
set $LeftWs5 5:5:Left
|
||||||
|
set $LeftWs6 6:6:Left
|
||||||
|
set $LeftWs7 7:7:Left
|
||||||
|
set $LeftWs8 8:8:Left
|
||||||
|
|
||||||
|
set $RightWs1 1:1:Right
|
||||||
|
set $RightWs2 2:2:Right
|
||||||
|
set $RightWs3 3:3:Right
|
||||||
|
set $RightWs4 4:4:Right
|
||||||
|
set $RightWs5 5:5:Right
|
||||||
|
set $RightWs6 6:6:Right
|
||||||
|
set $RightWs7 7:7:Right
|
||||||
|
set $RightWs8 8:8:Right
|
||||||
|
|
||||||
|
# Workspace assignments
|
||||||
|
workspace $ws1 output $primary
|
||||||
|
workspace $ws2 output $primary
|
||||||
|
workspace $ws3 output $primary
|
||||||
|
workspace $ws4 output $primary
|
||||||
|
workspace $ws5 output $primary
|
||||||
|
workspace $ws6 output $primary
|
||||||
|
workspace $ws7 output $primary
|
||||||
|
workspace $ws8 output $primary
|
||||||
|
|
||||||
|
workspace $LeftWs1 output $left
|
||||||
|
workspace $LeftWs2 output $left
|
||||||
|
workspace $LeftWs3 output $left
|
||||||
|
workspace $LeftWs4 output $left
|
||||||
|
workspace $LeftWs5 output $left
|
||||||
|
workspace $LeftWs6 output $left
|
||||||
|
workspace $LeftWs7 output $left
|
||||||
|
workspace $LeftWs8 output $left
|
||||||
|
|
||||||
|
workspace $RightWs1 output $right
|
||||||
|
workspace $RightWs2 output $right
|
||||||
|
workspace $RightWs3 output $right
|
||||||
|
workspace $RightWs4 output $right
|
||||||
|
workspace $RightWs5 output $right
|
||||||
|
workspace $RightWs6 output $right
|
||||||
|
workspace $RightWs7 output $right
|
||||||
|
workspace $RightWs8 output $right
|
||||||
|
|
||||||
|
# Binded
|
||||||
|
bindsym $mod+Mod1+1 exec pi3-smart-workspace -i 1
|
||||||
|
bindsym $mod+Mod1+2 exec pi3-smart-workspace -i 2
|
||||||
|
bindsym $mod+Mod1+3 exec pi3-smart-workspace -i 3
|
||||||
|
bindsym $mod+Mod1+4 exec pi3-smart-workspace -i 4
|
||||||
|
bindsym $mod+Mod1+5 exec pi3-smart-workspace -i 5
|
||||||
|
bindsym $mod+Mod1+6 exec pi3-smart-workspace -i 6
|
||||||
|
bindsym $mod+Mod1+7 exec pi3-smart-workspace -i 7
|
||||||
|
bindsym $mod+Mod1+8 exec pi3-smart-workspace -i 8
|
||||||
|
|
||||||
|
|
||||||
Credits
|
Credits
|
||||||
-------
|
-------
|
||||||
|
|
||||||
Thanks to Travis Finkenauer for an inspiration (`i3-wk-switch`_) and
|
Thanks to Michał Wieluński for an inspiration (`pi3-switch`_) and
|
||||||
Tony Crisci for an easy-to-use i3 python library (`i3ipc-python`_).
|
Tony Crisci for an easy-to-use i3 python library (`i3ipc-python`_).
|
||||||
|
|
||||||
.. _pipsi: https://github.com/mitsuhiko/pipsi
|
.. _pipsi: https://github.com/mitsuhiko/pipsi
|
||||||
.. _i3-wk-switch: https://github.com/tmfink/i3-wk-switch
|
.. _pi3-switch: https://github.com/landmaj/pi3-switch
|
||||||
.. _i3ipc-python: https://github.com/acrisci/i3ipc-python
|
.. _i3ipc-python: https://github.com/acrisci/i3ipc-python
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ import argparse
|
|||||||
|
|
||||||
class WorkSpacer:
|
class WorkSpacer:
|
||||||
|
|
||||||
def __init__(self, args):
|
def __init__(self, index):
|
||||||
self.i3 = None
|
self.i3 = None
|
||||||
self.args = args
|
self.index = index
|
||||||
self.workspaces_on_outputs = {}
|
self.workspaces_on_outputs = {}
|
||||||
self.workspaces = None
|
self.workspaces = None
|
||||||
self.outputs = None
|
self.outputs = None
|
||||||
@@ -52,7 +52,7 @@ 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.args]}')
|
self.i3.command(f'workspace {self.workspaces_on_outputs[self.current_output_name][self.index]}')
|
||||||
|
|
||||||
def _get_workspace_from_courser_position(self):
|
def _get_workspace_from_courser_position(self):
|
||||||
for output in self.outputs:
|
for output in self.outputs:
|
||||||
@@ -83,8 +83,8 @@ def main():
|
|||||||
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,
|
parser.add_argument("-i", "--index", type=int,
|
||||||
help="the number index of the workspace that should be openend. 1 = workspace 1 etc.")
|
help="the number index of the workspace that should be openend. 1 = first workspace in config etc.")
|
||||||
ws = WorkSpacer(parser.parse_args())
|
ws = WorkSpacer(parser.parse_args().index - 1)
|
||||||
ws.run()
|
ws.run()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user