[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: IMG_1376.png (301 KB, 1280x1224)
301 KB
301 KB PNG
Started tinkering with i3 today. In tabbed layout, how do I remap to switch to a specific tab index? All that i’ve found to work is next and prev but they aren’t specific to a tab.
>>
>>108540704
You have to use a script that puts the tabs into an array and indexes them by querying the window tree. There is no such tab index in the window tree. You have to make it in bash.
>>
let claude do you some i3ipc script
>>
>>108540704
>>108540729
When you try to do this, you're going to run into a problem where this only works on the tabs in the immediate parent window. You'll have to select the parent window, and then do it, which may have to matched differently in the window tree.
>>
>>108540754
>>108540729
>>108540754
Thanks anons.
>>
>>108540754
just need some recursive magic. hint: the function shall call itself.
>>
File: hth.png (291 KB, 674x1894)
291 KB
291 KB PNG
>>108540704
Is this your post from yesterday >>108537507
Lrn2Google, anon, ffs.
>>
here is my weird tab navigation script, that does different shit, but that might inspire you or be funny to someone. it does... stuff, it's commented. i made it socket server to kill the python latency.

https://paste.debian.net/hidden/bbb4fb46
>>
>>108540787
I already tried something like that and it doesn’t work.
>>
#!/usr/bin/env python3
import sys
import json
import subprocess

def find_focused_parent(node):
if 'nodes' in node:
for child in node['nodes']:
if child.get('focused'):
return node
parent = find_focused_parent(child)
if parent:
return parent
return None

if len(sys.argv) == 2:
target_index = int(sys.argv[1]) - 1 # Convert 1-based input to 0-based index

# Grab the current window tree from i3
tree_data = subprocess.check_output(['i3-msg', '-t', 'get_tree'])
tree = json.loads(tree_data)

parent = find_focused_parent(tree)

# If a parent is found and the requested tab index exists, focus it
if parent and 0 <= target_index < len(parent['nodes']):
target_id = parent['nodes'][target_index]['id']
subprocess.run(['i3-msg', f'[con_id={target_id}] focus'], stdout=subprocess.DEVNULL)

make a key binding for this script like this
bindsym $mod+Ctrl+1 exec --no-startup-id ~/.config/i3/i3-file-name.py 1
bindsym $mod+Ctrl+1 exec --no-startup-id ~/.config/i3/i3-file-name.py 2
2 second prompt
anon please fuck off its not a tech support board, although it has its generals for that, you'd already have an answer if you posted that question on reddit
>>
>>108540772
You're fully misunderstanding what I'm saying, that if you use the script to move to a tab index. It's only going to work on whatever nest level you are at in the window tree that has tabs in it. Using it from a window with tabs inside of a window with tabs won't work on the outer most window unless you select the appropriate parent with "focus parent". Which may have to be filtered differently from the window tree than normal windows. So it might be necessary to check the focused window and have alternate logic for handling a parent window containing tabs. That's an if statement, not a recursive function.
>>
I was trying to get i3 to swap-rotate through all windows in a particular class, yesterday. So, I could have a terminal open, press a keybind, and it will be swapped out with the next window of that class. It was not working out.
>>
>>108541274
Can you translate that into a language that doesn't suck?
>>
Here's some actual advice. Use stacks instead of tabs so you can still move focus left and right without interfering with the tabs in the container. You're trying to use tabs for what workspaces are for.
>>108541274
You should probably just throw this guy's script away since he want to help you and cry like a bitch at the same time.



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.