Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep window open when closing the last (only) tab #233

Open
spcmd opened this issue Mar 3, 2016 · 15 comments
Open

Keep window open when closing the last (only) tab #233

spcmd opened this issue Mar 3, 2016 · 15 comments
Labels

Comments

@spcmd
Copy link

spcmd commented Mar 3, 2016

Is there a way to prevent closing the window when closing the last tab?

If there is only one tab and I close it, I'd like uzbl to open a blank page or home page in its place instead of closing the whole browser. Now I'm using the CLEAN_TABS event for this (as a temporary solution), but this way I have to use another key for closing the last tab.

Maybe some command could check whether it's the last tab and use the exit or CLEAN_TABS event depending on the command's output?

@mathstuf mathstuf added the tabbed label Mar 3, 2016
@mathstuf
Copy link
Member

mathstuf commented Mar 3, 2016

This could be a variable that uzbl-tabbed pays attention to.

@GSI
Copy link
Contributor

GSI commented Mar 3, 2016

Is there a way to prevent closing the window when closing the last tab?

I was very accustomed to that too, but that was due to "firefox bias" :)

Now I don't actually see any reason for a feature like that - what do you need an empty browser for? You'll most likely want to navigate to another site anyway, so why bother about what's currently open?

@spcmd
Copy link
Author

spcmd commented Mar 3, 2016

I don't like to keep open any page if I don't need it. Reasons mainly: resource usage, privacy. I also have my own customized home page and I'd like to see that if my browser is "empty". I also don't like to relaunch the browser every time, so this is why I need a solution for this.

@keis
Copy link
Member

keis commented Mar 3, 2016

The best place to implement this would be inside tabbed. UzblTabbed.tab_closed has some very simple logic that calls quit() when there is no more open pages. Configurable by some setting this should instead by calling new_tab()

@spcmd
Copy link
Author

spcmd commented Mar 4, 2016

Today I wrote a little "workaround". Can be used as a temporary solution until uzbl gets a proper option/setting for this:

exit_keep_last_tab.sh

#!/bin/sh

count_tabs=$(pgrep uzbl | wc -l)

if [ "$count_tabs" -gt 1 ]; then
    echo "exit" > "$UZBL_FIFO"
else
    echo "set uri = file://@config_home/uzbl/newtab.html" > "$UZBL_FIFO"
fi

Then I set the key binding for this in the config:

# close tabs (keep the last tab open)
@cbind d = spawn @scripts_dir/exit_keep_last_tab.sh

@mathstuf
Copy link
Member

mathstuf commented Mar 4, 2016

Just an FYI, that will fail for any number of reasons because the pgrep uzbl (and the wc -l is better replaced with the -c flag to pgrep) will false-positive for instances outside of the uzbl-tabbed, other users running uzbl, and probably others.

@spcmd
Copy link
Author

spcmd commented Mar 4, 2016

Yeah, you are right, pgrep -c is better. For the instance part: I use the uzbl-tabbed once, I don't use other tabbed or single window instances, so it's okay for me at the moment.

But a proper config setting or something would be better of course. :)

@mathstuf
Copy link
Member

mathstuf commented Mar 4, 2016

I figured, but before others go and run with this script, the caveats might be useful to know :) .

@spcmd
Copy link
Author

spcmd commented Mar 5, 2016

Unfortunately my script is not working well with the git version of uzbl. It was okay with the quite old Arch Linux package, but today I installed the git version (tabbed-next) from the AUR and the tab closing is "hanging" for seconds with the script I wrote. I added a notification for the script to check the execution time, it was okay (instant), but for some reason the tab didn't get closed until a few seconds.

The interesting thing is if I hit any key after the close, then it closes instantly. I can hit the d key twice and it closes instantly. It isn't a key binding conflict, I tried with different keys.

I tried with the FIFO and the socket too, I tried the git master branch too, the results are all the same.

@mathstuf
Copy link
Member

mathstuf commented Mar 5, 2016

There's some buffering happening in the I/O system :/ . Thought that was finally fixed.

@GSI
Copy link
Contributor

GSI commented Mar 8, 2016

@spcmd

Reasons mainly: resource usage, privacy.

Given you mention "resource usage", I realized that your process of opening an entirely new window may be (unneccesarily?) complicated.

Otherwise you could just close the window altogether.

I use Mod4+[SOMEKEY] to fire up the browser, so I don't worry about accidently closing my instance and then having to navigate to some icon to click.

Also, I always made heavy use of tabs. After switching to dwm I realized that I was just solving a problem I wouldn't need to have in the first place.

Tabs leave you guessing about their contents until you switch (back) to them. A proper WM let's you preview contents of all windows and switch quickly.

Also, tabs cause additional headache:
When you rotate through them and any of the websites sets the focus to a form field, uzbl, by default, goes into insert mode. So you have to press Esc to continue rotating.

Now I exclusively use uzbl-browser. In my opinion, uzbl-tabbed could be dropped altogether. Actually it should be dropped in order to free up the limited developer time available for more important parts of uzbl.

The browser surf, for example, implements the Xembed specification so it can be "tabbed" using an according tool like http://tools.suckless.org/tabbed

=> Unix philosophy

@GSI
Copy link
Contributor

GSI commented Mar 8, 2016

Ah, and why not just start your browser with this command:

while 1 ; do uzbl-tabbed ; done

=> Whenever you close the last tab, you get a fresh uzbl.

@spcmd
Copy link
Author

spcmd commented Mar 8, 2016

@GSI

With some tiling WMs you can live without tabbed, but if someone uses for example Openbox, it won't be a nice user experience. Also, every modern browser have tabs, even w3m (which is a CLI/TUI browser) has this feature. And it's a preference. I prefer tabs.

When you rotate through them and any of the websites sets the focus to a form field, uzbl, by default, goes into insert mode. So you have to press Esc to continue rotating.

With the older version of uzbl this worked for me (mostly):

@on_event   LOAD_FINISH    event ESCAPE
@on_event   FOCUS_GAINED   event ESCAPE

Seems like it doesn't work anymore. But maybe it can be fixed somehow.

For the while loop part: it works, but it's slower than redirecting the last page to a custom home page (local file) or a blank page, because it always restarts the whole browser. Maybe it's not a problem if you have a SSD, but with a HDD (especially when it's under load) it could be relatively slow.

I know this tab thing isn't the biggest problem, we can use a "workaround" like the script I wrote above. That I/O buffering issue which was mentioned before is more of a problem now (but it's another topic/issue I think).

@keis
Copy link
Member

keis commented Mar 8, 2016

Just to clear a few things up.

uzbl-core also implements xembed and should in theory work with suckless tabbed or some similiar tool. In fact uzbl-tabbed works exactly the same way by launching a full uzbl for each tab and it turns out to not be a big deal performance wise.

autofocus is implemented in the config, you could simply drop that line if you don't want it

@GSI
Copy link
Contributor

GSI commented Mar 11, 2016 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants