justbuchanan / i3scripts

My scripts for enhancing i3wm
Other
163 stars 46 forks source link

Need a way to limit number of workspaces created by new_workspace #16

Closed sjclayton closed 5 years ago

sjclayton commented 5 years ago

I am loving your scripts... I have been playing around with a few different configurations for my setup, and overall things are awesome.

However, I was wondering there was any easy way to limit the number of workspaces created, maybe a variable that could be setup to be able to tell it to stop spawning any more once it's reached a predefined number.

justbuchanan commented 5 years ago

Thanks, glad you've found them useful!

I'm not sure I fully understand the use case here. Is this just to help you keep your workspaces under control by not opening too many? Would you want the script to just ignore attempts to create more windows or have it display a message?

sjclayton commented 5 years ago

I only have so many keys assigned to switch directly to x numbered workspaces.... so creating more than I can actually directly command i3 to switch in to is kind of useless for me.

You could have it display an message, but it's not really necessary.. as I was thinking that this max 'limit' could be passed in via a command argument to the script itself... so in that case if the user sets a limit they will know when it gets reached.

Hope that helps you understand better.

justbuchanan commented 5 years ago

Makes sense, @sjclayton, thanks for the explanation (and sorry for the slow reply). Probably the best way to do this would be to add a --maxnum flag to the script with parser.add_argument(), then pass the value to the new_workspace() function. From there, a quick check against new_ws_num should determine whether to go through with creating a new workspace or exit.

I probably won't merge this behavior into my repo for now since I don't think it's something I'd personally use, but please do try it out for yourself and see how it helps your workflow!