Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

My question is something like this - but I don't want to open a given application on a specific workspace, I want each instance to open on a new workspace each time.

The OP in the linked-to question wants to open Firefox on workspace 2, Chromium on workspace 1, etc...

I want to open new instances of a text-editor (Sublime Text) in a new workspace for every new instance. Is this possible?

solution:

I used the accepted answer in a modified form:

# .bashrc
...
function sublime {
  i3-msg workspace $(($(i3-msg -t get_workspaces | tr , '\n' | grep '"num":' | cut -d : -f 2 | sort -rn | head -1) + 1))
  /usr/bin/sublime_text_3/sublime_text $1
}

so that I can use it like this:

$ sublime /path/to/file

and also because I'm using my dotfiles across several computers, so it's nicer to include everything in one place!

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

You can use a small BASH script to do that:

This opens a new workspace (taken from here) and runs a command:

#!/bin/bash
i3-msg workspace $(($(i3-msg -t get_workspaces | tr , '\n' | grep '"num":' | cut -d : -f 2 | sort -rn | head -1) + 1))
sublime-text

Create this script under /usr/bin, name it eg. sublime-new, give it exec permissions and you can now launch it from a terminal emulator. Strange, but when executing the script from dmenu, it first opens the program and then changes the workspace.

share|improve this answer
    
works great, thanks. I modified it a bit, will add to my original post. cheers! –  dax Jun 21 at 11:26
1  
Or more generally exec "$@" to use it with other stuff! –  illuminÉ Jun 21 at 12:31
1  
@illuminÉ, it's a good idea to generalize the script, but if the OP needs it for only a specific application, then it might be more useful not requiring to type in another argument. –  psimon Jun 21 at 12:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.