Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: I3wm Alt+Tab Workspace Switcher
61 points by iondodon 7 months ago | hide | past | favorite | 51 comments
https://github.com/iondodon/i3-switcher-x11

The i3wm Alt+Tab Workspace Switcher is a tool designed to bring the familiar Alt+Tab window switching functionality to the i3 window manager environment. It aims to enhance productivity by enabling users to switch between workspaces efficiently and intuitively, mimicking the window switching feature found in traditional desktop environments like Windows.

In my experience, using the $mod+workspace number to switch workspaces feels slower. I suspect this might be because I process visual cues more quickly than I recall specific keystrokes for each workspace. Alternatively, it could simply be due to my familiarity with the Alt+Tab behavior from Windows and macOS, which has influenced my preferences and habits.




One big reason I use i3 is because I find the Windows and macOS style alt/cmd tab incredibly unintuitive. It is not easy to consistently predict how many times to press it to get the desired result.

With i3 I bind keys to specific things (including workspaces) so I can switch instantly.


I've built something similar for my own needs.

What I found lacking in the default i3 possibilities, was going to the previously used window on the same workspace.

My daily driver is a 32" 4k monitor, so many times I end up with one IDE or terminal on the left, and some documentation on the right, both halves visible at the same time.

However, I hate using tabs in the browser, so thanks to a hacky extension, firefox opens a new window per tab, which means that i3 manages firefox' tabs as regular windows.

So, if you have a bunch of windows open, want to see the one in the middle of the bunch, but need to switch between that and the "work" window, there's no easy way to do that from the keyboard.

From the IDE, going right works as expected. But from the browser, going left "changes tabs". You only reach the IDE after you've been through all the other tabs.


> However, I hate using tabs in the browser, so thanks to a hacky extension, firefox opens a new window per tab, which means that i3 manages firefox' tabs as regular windows.

Can you provide a bit more information about your setup?

I'm using sway and I removed the tabs from Firefox to handle them as individual windows.


I don't have my machine on hand to give you the specific extension, but basically it's something called "notabs" or similar. Whenever a new tab is opened, it gets moved to a separate window. It works mostly OK, but it can sometimes get confused.

I combine this with some custom chrome to completely hide the tab bar area at all times.

Afterwards, I manage my firefox windows with i3 as I would any other window. They usually end up in tiled mode.


Thanks, I guess it would be the following extension:

https://addons.mozilla.org/de/firefox/addon/adsum-notabs/

For the custom chrome, I'm using in userChrome.css:

  #TabsToolbar { visibility: collapse !important; }


That's the one, yes.


You can use the "focus parent" bind then move off of it with your regular left/right binds.


Yeah, that works technically, but it's a PITA. Because you have to:

1. do an extra action

2. remember whether you actually have a parent or not, since it's context dependent. Doing this while the single-window IDE is selected, it'll do nothing (the parent is "everybody", so there's nothing to the right).


i've got you covered. I made a script to achieve exactly this.


https://end.re/9793ad90063fb74423e4b2ff4d5b198ab576110c9bfef...

and then trigger it with eg.:

``` bindsym $mod+x exec --no-startup-id "xargs -n1 kill -USR2 < /tmp/focus_last.pid" ```


Well, I've covered myself with a few lines of Rust that do exactly that.

By the way, there are a few subtleties which your script doesn't handle which bit me ;) Off the top of my head, some full-screen windows (mpv IIRC) behave a bit differently and would be missed.


The Windows alt+tab behaviour up to Windows 7 was reliable/predictable with two caveats, 1. Things that minimised to the notification area would not go to the back of the stack when you minimised them. 2. Microsoft Excel misbehaved - something to do with each workbook having its own window entry in the group, but also the application having this entry.

At some point since Windows 7 I played with it and found it to be no longer consistent. I could somewhat correct for this by using alt+esc to move a window to the back of the stack and then reverse to it with ctrl+shift+tab.


Alt+Tab (or at least Cmd+Tab) works very predictably though, doesn't it? Most-recently-used order.

My work habits generally involve switching back and forth between two applications. Sometimes three.

Cmd+Tab switching works well for that. More convenient than, e.g., Cmd+3 then Cmd+7 etc.

I also appreciate Firefox's Ctrl+Tab for tab switching, which works the same way.


I like using Contexts on the Mac as replacement: https://contexts.co Looks like i3 does something similar?


One nice quality of life improvement for i3 is update the window names dynamically and use emojis for applications

https://github.com/cboddy/i3-workspace-names-daemon


You can configure the window icons directly in the config file.

for_window [class="(?i)firefox"] title_format "<tt></tt><span foreground='#FF6611'>  </span><tt> </tt>%title


I've mostly moved away from i3, for XMonad where I have my workspace keys mapped to alt+qwer...zxcv in a waterfall pattern. That way workspace switching is always on one hand and I don't need to reach for the 10th workspace.

On i3 though, I find myself scrolling through workspaces a lot, especially when I have a trackpoint available. It requires almost no precision to just throw the mouse to the bottom of the display and scroll until you see the thing you want, then continue on your way.

Never once thought about wanting alt+tab, my hatred for inconsistent alt+tab is why I went to tiling wms in the first place.


I'm very new to i3 but could you not set up a similar set of keybinds with it? What does XMonad add for you?

EDIT: I've just stolen this btw. I was never using the higher workspaces because $mod+number gets less convenient on higher numbers. This pattern works great though, thanks!


I think I was getting frustrated over how i3 handled it, its certainly possible, but I really liked how XMonad handled multiple mod keys in the config, as well as the dynamic tiling.

It was years ago at this point and i3 was giving me issues binding alt to one of the mods, while retaining super for other shortcuts. I've always been quick to get to get frustrated with config files so it was a nice off-ramp to learn something new.


I think this is a really nice idea. I suspect I will continue using mod + {num} but I love the implementation.

I've always liked OS X's distinction between Alt + Tab which switches between App, and then Alt + ~ to switch between the windows of the apps. While using Windows the number of open windows quickly becomes too large for Alt + Tab to be useful for anything more than switching between a handful of recent windows.

But the problem with the OS X implementation is that after you switch to an app switching between windows is like throwing darts in teh dark. There is no overall context available at all.

Using Alt + Tab to switch between workspaces, and with a tiling window a workspace preview also shows you all teh windows in it, and once you switch to a workspace switching to the window you want is trivial, seems like a novel and significantly improved way to handle Alt + Tab navigation.


> But the problem with the OS X implementation is that after you switch to an app switching between windows is like throwing darts in teh dark. There is no overall context available at all.

There's also the fact that, IIRC, it brings all the non-minimized windows of the app to the front.


Good point. That really destroys the stability of the spatial layout.


I came from exwm, I really like the idea of only having one "workspace" per monitor, with some number of windows.

I use https://github.com/OliverUv/quickswitch-for-i3/ to fuzzy select a buffer,

bindsym $mod+b exec --no-startup-id ~/projects/quickswitch-for-i3/quickswitch.py --swap

I have a "hidden" workspace where windows I don't want to look at goes to

bindsym $mod+Shift+x move container to workspace garbage

This lets me not worry about remembering which workspace something lives on, but just "pull" it to whatever window I'm on


This is very nice, stock i3 works very well for me though so it's a hard sell to get me to switch.


I have always found that workspaces were a way to "save a game" and I don't have to switch a lot so I never bothered using anything else than my desktop's native shortcuts. On the other hand, window switching happens often and needs to be fast and as a vimmer I always found that mod + j/k was a natural candidate.

Anyone else using anything out of the ordinary that they think is clever ?


Here's mine:

bindsym $mod+Shift+P exec /home/calvin/bin/rename_workspace

bindsym $mod+Shift+F exec /home/calvin/bin/throw_window

alt-F -> "throw_window" launches dmenu with a list of all my windows so i can then select it and it will automatically switch me to the workspace that window is on and focus it

alt-P -> rename my workspace on the fly

https://git.ceux.org/throw_window.git/

https://git.ceux.org/i3-rename-workspace.git/


I have

    bindsym $mod+Tab exec --no-startup-id rofi -show window
for this


TBH I find that a visual of what the window looks like helps a ton. I just ran that to see what it did, and all it gives is the text of the window title.


I've bound alt+tab to `workspace back_and_forth`, so I can toggle between the last two used workspaces. I mostly have only 1 window per workspace, so it works fine for me.


I've always found it odd how Alt/CMD-Tab behavior differs from Windows & macOS.

Windows: Alt-Tab will cycle through all open 'windows' (so if you have 2 different Word documents open, it will show both independently)

macOS: CMD-Tab will cycle through all open 'apps' (if you have 2 different Word documents open, macOS will not distinguish between them and only show you the last used Word doc)


I don't understand the continued obsession with "grouping" application instances together like this (Windows and macOS both do this, in different places and different ways).

Dear OS: If I have multiple instances of an application open it's because I'm doing different things. If one is a text editor, you should not act differently depending on if the other one is a PDF viewer or another text editor.

Many applications already have their own "grouping", usually called tabs. Web browsers being a really obvious one, and where this application grouping is the worst. Half my "apps" are really just web pages.

Grouping the window where I'm testing the web application I'm currently coding with the IDE where I'm working on the code would make way more sense than grouping it with my web-based email client... yet here we are.


Macos is really big on the document model, where a window is tied to a document (file, a set of data, a list of objects), so Option-Tab to switch between applications, and Option-Backquote for said documents/windows.


That only cycles through open windows for the current in-focus application.

E.g. If I have 2 Excelsheets open and 2 Word documents open, if Word is the current in-focus app ... CMD+` only cycles between the 2 Words documents (and does not cycle the Excel sheets)


I wonder, has anyone moved away from using i3 (for a few years) to dwm or another dynamic wm? If so please share your experiences.


I used i3 for several years and liked it a lot. I've recently switched to XMonad and I think I like it more. I find the configuration to be far more flexible, and the defaults aligned more with my natural preferences. My i3 config was pretty sizeable, but my XMonad config is (for now) quite small. Additionally, I found cycling tiling layouts in XMonad was a very useful feature that I never got from i3. Also I like Haskell, so that was a +1 for XMonad.


On a related note, I used to organize my multi-monitor setup according to each project, and used to switch workplaces on all the monitors in sync. https://github.com/sainathadapa/i3-wm-multi-disp-scripts


`$mod+{1..0}` seems to be more ergnomic as someone who switched from macOS to Linux with i3, but that's just me.


I miss Mod + {1..n} when using macOS!! I know they do allow workspace switching via keyboard shortcuts. But the minute you full screen an app, that breaks. Full screened apps are taken out of the desktop workflow. So even though a three-finger swipe can move between a full-screen app and a desktop, keyboard shortcuts cannot.


Coming from i3 this was one of my biggest pain on osx, running skhd + yabai to solve that. Still not i3's perfect experience: I did not manage to have only one action key, but starting to get closer. And you can have that full screen without the osx full screen!


Isn't it much more efficient to simply use $mod+num_of_workspace like Alt+1, Alt+2?


You still have that available. This is for when you might not remember which workspace the stuff you're looking for or are just more visual in recognizing the workspace you need.


Alt-W does that too though


I use rofi and bind $mod+q to search for windows.


Showing the workspaces is really nice. I’m surprised there isn’t a built in button for it, now that you’ve sort of pointed it out


If anyone is looking for a similar feature in sway, there's a tool swayr, which does exactly this and more.


i'm curious about OPs point of processing visual queues faster than specific keystrokes. The default config for workspaces is 1 through 9. How is it possible that it's harder to recall a specific workspace than process a visual queue?

None of that makes sense to me


So I'm working on something on workspace N, but I want to peek at a job or browser running on workspace 3, then go back to what I was doing. How do I get back to workspace N without going through "Was I on workspace 5? No, 2? No, 7? Ok, that's where I was."

I used to do this all the time when I was on a laptop as my primary machine, with many things either full screen windows or ~3 windows on the screen, and different tasks on different workspaces. "Back to last workspace" was something I used all the time.


You can switch workspaces by scrolling on the i3 bar. That's probably the easiest way.


With window preview, very nice.


I need just this kind to thing for bspwm


I'm going to try that, thank you!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: