feat(i3): shortcut to throw windows to workspaces + balance windows

This commit is contained in:
Johann Dreo 2024-12-13 14:38:31 +01:00
commit c6238648a4
2 changed files with 73 additions and 0 deletions

View file

@ -168,6 +168,18 @@ bindsym $mod+Shift+8 move container to workspace number $ws8 , workspace number
bindsym $mod+Shift+9 move container to workspace number $ws9 , workspace number $ws9
bindsym $mod+Shift+0 move container to workspace number $ws10 , workspace number $ws10
# move focused container to workspace
bindsym $mod+Ctrl+Shift+1 move container to workspace number $ws1
bindsym $mod+Ctrl+Shift+2 move container to workspace number $ws2
bindsym $mod+Ctrl+Shift+3 move container to workspace number $ws3
bindsym $mod+Ctrl+Shift+4 move container to workspace number $ws4
bindsym $mod+Ctrl+Shift+5 move container to workspace number $ws5
bindsym $mod+Ctrl+Shift+6 move container to workspace number $ws6
bindsym $mod+Ctrl+Shift+7 move container to workspace number $ws7
bindsym $mod+Ctrl+Shift+8 move container to workspace number $ws8
bindsym $mod+Ctrl+Shift+9 move container to workspace number $ws9
bindsym $mod+Ctrl+Shift+0 move container to workspace number $ws10
# reload the configuration file
bindsym $mod+Shift+C reload
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
@ -259,6 +271,8 @@ assign [class="Terminator" window_role="boinc"] $ws1
# Video as background
# exec --no-startup-id "mpv --wid=0 --loop --no-terminal --speed=0.5 --video-align-x=0.5 --no-audio --video-sync=display-resample --interpolation --tscale=oversample ~/Vidéos/Blue_Turn_notitle.mp4"
# Wallpaper as background
exec --no-startup-id feh --bg-scale /home/nojhan/Images/Wood.png
# Sound controller
exec pavucontrol
@ -274,3 +288,5 @@ exec "terminator --profile 'small font' --role btop --command btop"
for_window [window_role="scratchpad"] move window to scratchpad
exec terminator --role scratchpad#
bindsym $mod+m exec "i3_balance_workspace"

57
.config/i3/tabs_in_split.py Executable file
View file

@ -0,0 +1,57 @@
#/usr/bin/env python3
import sys
# From https://github.com/i3/i3/issues/4207#issuecomment-792874108
# Manage windows as follows:
# - the workspace occupies the full screen, a single container in tabbed mode holding all the current windows
# - one can choose to split that area in half, horizontally or vertically, this creates two new tabbed containers, each occupying half of the screen; one gets the currently-focused window, IIRC, and the other gets the rest of the windows
# - any new window created in any of these new containers ends up as a new tab of one of these containers; new windows don't change the screen layout
# - this process can be repeated on each of these new halves if one so wishes
# In this way, in ion3/notion, the window manager assists you in creating the layout you need, while giving you the possibility of keeping it independent of how many windows you have in a workspace.
# i3ipc requires installation:
sudo apt install python3-i3ipc
# pip3 install i3ipc
from i3ipc import Connection
def tab_and_move_containers(con1, con2, other_cons):
con1.command('split horizontal') # force creation of a new parent container for this one
con1.command('layout tabbed')
con2.command('split horizontal') # force creation of a new parent container for this one
con2.command('layout tabbed')
con2.command('mark target')
[con.command('move window to mark target') for con in other_cons]
con2.command('unmark target')
def main():
direction = sys.argv[1]
i3 = Connection()
con1 = i3.get_tree().find_focused()
cons = con1.parent.descendants()
if len(cons) < 2:
return
other_cons = [con for con in cons if con.id != con1.id]
con2 = other_cons.pop()
# "bisect" the area of interest (split it horiz/vert)
if direction == 'h':
i3.command("layout splith")
else:
i3.command("layout splitv")
# relocate containers so there are only two of them visible;
# con1 will get a tabbed container all to itself,
# con2 and other_cons will go in the other tabbed container
# tab_and_move_containers(con1, con2, other_cons)
tab_and_move_containers(con2, con1, other_cons)
if __name__ == '__main__':
main()