Commit cc7da82e authored by Maxime Bombar's avatar Maxime Bombar
Browse files

[i3] Custom script to safely rename a workspace and keep the number (Or force change the number).

parent b613b6b5
# Create a new workspace
if [ ! -d ~/.config/i3/venv ]; then
python3 -m virtualenv ~/.config/i3/venv;
pip3 install -m ~/.config/i3/requirements.txt;
source ~/.config/i3/venv/bin/activate && python3 ~/.config/i3/bin/ $@
# Rename current workspace and keep the number
import i3ipc
from argparse import ArgumentParser
import logging
import colorlog
logger = logging.getLogger()
def main(newname=""):
i3 = i3ipc.Connection()
focused = i3.get_tree().find_focused()
num, name = None, newname
if ":" in newname:
num, name = newname.split(":")
num = int(num)
except ValueError:
num, name = None, newname
if num is None:
num = focused.workspace().num"i3-msg 'rename workspace to \"{num}\":\"{name}\"'")
i3.command(f'rename workspace to "{num}:{name}"')
if __name__ == '__main__':
format_string = "%(asctime)s - %(levelname)s - %(message)s"
stdout_handler = logging.StreamHandler()
stdout_formatter = colorlog.ColoredFormatter(
parser = ArgumentParser()
parser.add_argument("newname", type=str, nargs="+",
help="The new name of the workspace.")
parser.add_argument("-v", "--verbose",
help="More logging.",
args = parser.parse_args()
if args.verbose:
newname = " ".join(args.newname)
......@@ -161,7 +161,7 @@ bindsym $alt+Shift+Left exec --no-startup-id ~/.config/i3/bin/slide_workspace le
bindsym $mod+Delete focus parent, kill
# Rename current focused workspace
bindsym $mod+r exec i3-input -F 'rename workspace to "%s"' -P 'New name: '
bindsym $mod+r exec i3-input -F 'exec ~/.config/i3/bin/rename_workspace %s' -P 'New name: '
# Goto workspace
bindsym $mod+j exec i3-input -F 'workspace "%s"' -P 'Name: '
Markdown is supported
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