Vieb icon indicating copy to clipboard operation
Vieb copied to clipboard

Setting to open every tab in a new window instead

Open markstos opened this issue 3 years ago • 2 comments

Checklist

Addition or change

I would like to manage tabs using my window browser (Sway) which supports tab-grouping of Windows. Qutebrowser supports this with an option named "tabs_are_windows:true"

https://qutebrowser.org/doc/help/settings.html#tabs.tabs_are_windows

When enabled, the tab bar is hidden and any command or binding that would open a new tab opens a new window instead.

Alternatives considered

  • Using tabs managed by the browser requires remembering one set of key bindings for moving and managing tabs in the browser and a second set of keybindings for managing tabs in the window manager. By making every "tab" a first class window, the experience is improved for tiling window managers. For example, there's often a way to search for a window by name to switch to. When every tab is a window, you can switch from another app directly to a specific "tab" in the browser in one step.

markstos avatar Sep 24 '21 19:09 markstos

I don't mind making this an option, but it requires #141 to be implemented.

Jelmerro avatar Sep 24 '21 20:09 Jelmerro

For the record, this is the main reason why I use Qutebrowser instead of Vieb as my primary browser. Actually the only reason that I can remember.

mentalisttraceur avatar Oct 04 '21 06:10 mentalisttraceur

Since #141 is now an option, this can be achieved by doing: :set containernewtab=s:external externalcommand="vieb --unsafe-multiwin=true --datafolder=<datafolder>" This does require the installed Vieb to have this setting as well, so it only works when installed not when run from source, I have yet to release this version. It's also recommend to have this setting in your viebrc, since it will not be synced between windows and thus only work in the first one if not read from the viebrc. Overall this approach has a lot of disadvantages to using multiple datafolders, which will remain the recommended way to create multiple windows, as per FAQ.

Jelmerro avatar Nov 22 '22 11:11 Jelmerro

Related to my comment in #470 - I've never tried --unsafe-multiwin=true (assuming it's even available in a release build yet? haven't checked) because as I understood it, --unsave-multiwin=true creates risk of losing/corrupting stuff (which I presume includes history, what pages were open when the browser was last closed, etc).

And so long as history or open-tabs-when-browser-last-closed/session-last-saved is liable to be lost (at least until I have the time to look into some sort of alternative way to duplicate that information externally), that's just not something I'm going to gamble with. (If there was documentation about what kind of actions could cause what kind of corruptions, even if it's just super technical stuff like "whenever function foo is called, which is called from at least x, y, and z at this time - but check the latest code to be sure", I'd be more comfortable trying it.)

As is, if I can't get used to Vieb's single-window workflow, what I might be inclined to do is create multiple data dirs for when I want new windows, and if that stops scaling well, some simple program/script to create a new datadir copy (probably with a file-descriptor-based flock(2) lock on some constantly-existing file in the data directory, so that it vieb can just inherit that file descriptor (I sure hope it doesn't automatically close every FD it doesn't use at startup) and then it will get automagically unlocked by the OS if the vieb process exits with no need for coordination from within vieb).

(The ideal would then be if I could at least merge stuff like history and cookies from those working datadirs into some latest template datadir which no vieb ever uses but which gets updated each time one vieb closes... but that's a whole big undertaking I probably will never get around to doing.)

mentalisttraceur avatar May 06 '23 04:05 mentalisttraceur

The command above does exactly what you mention and will create a new window in a custom datafolder (a different one, but the same external one) when you open a page externally with x or other external commands. Regarding what will corrupt, most likely not much in the beginning, especially if you don't use the windows at the same time, but especially Chromium's storage such as sessionstorage, localstorage and cookies are very much not made to be used in multiple windows at the same time, and since that isn't supported, Vieb settings don't account for it either, though those are anyway stored in a single file per datafolder and don't update based on runtime changes, just don't expect the windows to stay in sync.

Jelmerro avatar May 06 '23 09:05 Jelmerro

That's not exactly what I am saying - I'm talking about accepting that we need multiple datadirs for robust/intended/as-designed function, and making that work reasonably transparently from outside Vieb by creating new datadirs on-demand.

I'm basically imagining a script like this:

#!/bin/sh -
need_directory=true
for directory in ~/my/vieb/datadirs/*
do
    exec 3<directory/my-dummy-lock-file || exit 1
    if flock -n 3
    then
        need_directory=false
        break
    fi
done
if $need_directory
then
    directory=`mktemp -d ~/my/vieb/datadirs/XXXXXX` || exit 1
    cp -r ~/my/vieb/master-datadir/* "$directory/" || exit 1
fi
vieb --datadir="$directory" "$@" || exit 1
# if I can figure out how: merge datadir changes from
# $directory into ~/my/vieb/master-datadir - at least
# history and tabs saved before exiting would be cool.

mentalisttraceur avatar May 06 '23 16:05 mentalisttraceur

To be clear, I'm not saying Vieb should do anything here. I'm just saying that the way things are right now, this is probably what I would do the next time that I want fluently multi-window Vieb badly enough.

mentalisttraceur avatar May 06 '23 16:05 mentalisttraceur