Commit 3885d4d1 authored by Maxime Bombar's avatar Maxime Bombar
Browse files

Move new workspace script to python

parent 324ed679
#!/bin/bash
# Create a new workspace
if [ ! -d ~/.config/i3/venv ]; then
python3 -m virtualenv ~/.config/i3/venv;
pip3 install -m ~/.config/i3/requirements.txt;
fi
source ~/.config/i3/venv/bin/activate && python3 ~/.config/i3/bin/new_workspace.py $@
#!/usr/bin/python3
# Create a new workspace with the lowest available number
import i3ipc
def main():
i3 = i3ipc.Connection()
workspaces = i3.get_workspaces()
all_numbers = sorted(list(map(lambda w: w.num, workspaces)))
new = all_numbers[0]
i = 0
while new == all_numbers[i]:
new += 1
i += 1
i3.command(f"workspace {new}")
if __name__ == '__main__':
main()
#!/bin/sh
# Create a new workspace
i3-msg workspace $(($(i3-msg -t get_workspaces | tr , '\n' | grep '"num":' | cut -d : -f 2 | sort -rn | head -1) + 1))
......@@ -147,8 +147,8 @@ bindsym $mod+space focus mode_toggle
#####################
# Create a new workspace on current output
bindsym $mod+Shift+n exec --no-startup-id ~/.config/i3/bin/new_workspace.sh
bindsym Control+$alt+n exec --no-startup-id ~/.config/i3/bin/new_workspace.sh
bindsym $mod+Shift+n exec --no-startup-id ~/.config/i3/bin/new_workspace
bindsym Control+$alt+n exec --no-startup-id ~/.config/i3/bin/new_workspace
# Move current workspace to the right
bindsym $alt+Shift+Right exec --no-startup-id ~/.config/i3/bin/slide_workspace_right.sh
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment