originally posted by @APotOfSoup in #51 :
Termite doesn't have a command line option to change the class or instance name. It does have the ability to change the window title but decided against using that as I wasn't sure it would work in the long run.
I was having trouble getting xdotool to work at first but now see that I need to supply the window id and not the container id.
I originally added the --force
option to i3run because I was having all that trouble and thought it would be easy to throw in a ||
statement and get i3run to launch the command even if a window with that name already exists.
That may seem silly but do see value in it in situations like I am using it.
For example I have my terminal commands set up very similar to what I seen in your old config files I found. The first line is the one that has the force command. It will always lay down a terminal in the currently focused container. Nothing special.
$super+Control+Return $exe i3run -f -i tiledterm -x termite -e termite
$super+$alt+Return $exe i3run -s -i floatterm -x termite -e termite
$super+Shift+Return $exe i3run -i topterm -x termite -e termite
$super+Return $exe i3run -i cornterm -x termite -e termite
With urxvt the name could be set on that line quite easy, and I'm sure I could do it with xdotool quite easy now as well, all without i3run; But now with the change I've made that --force
flag and the already included '--rename' is all that is needed to launch any number of programs with specific class or instance names, even if the user is like me and couldn't figure out how to rename a terminal themselves haha
At first the --force flag was just a quick way to get the main function to always run. After adding it to the getopts stuff the only real change I made at first was one line in the main function.
if (( $nowin==1 )) || [[ -n ${__o[force]} ]]; then
launchcommand
else
focuswindow
fi
Now i3run -f -i mynamedinstance -x 'some_instance' -e 'some_command'
will just keep running the -e command and renaming every single instance that was created like I wanted.
That was great! I thought I added a good feature that might help others.
Until using it for a couple hours I figured out that I created a new issue because it would consistently focus a different instance then the newly created one.
This is why I asked about making i3get look for the newest instance so I could make sure the i3run command would focus the newest instance.
I figure out now that I could solve this a much simpler way.
I made the i3get that is run during the rename section of launchcommand store the results into a array. I made it return both the container id and the window id so I could use those pointers in i3-msg or xdotool respectively. This one will always be the newest instance because it returns the results before renaming it.
Now I just added a check to the line to set i3list[TWC]
to either the container id that we already found or run the i3get that finds the container id with the acri array.
That was all the important changes to get this working as I wanted.
I made a couple more change that actually fixes the send to mouse command when it's ran during the launchcommand section.
i3list[TWF]
is never set before attempting to use it in a check
Because of this I moved the eval i3list outside that check and changed the options like this eval "$(i3list -n "${i3list[TWC]}")"
.