Newsboat: Add operation for opening a URL with given command

Created on 3 Sep 2020  Â·  4Comments  Â·  Source: newsboat/newsboat

As @der-lyse explains in https://github.com/newsboat/newsboat/issues/1165#issuecomment-685939764:

One thing which might break user expectations is the abort on the first failed command in a sequence. When using cleanups in the last step this would cause them to not be executed and leaving newsboat in a little bit messed up state. Suppose a common and documented use case in macros where people change their browser setting to a different executable, opening the article or link in the new "browser" and finally reverting back to their default browser. In case open-in-browser fails, the browser is not reset, which is probably not what one would expect:

macro i set browser "feh %u"; open-in-browser ; set browser "elinks %u"

However, if I followed the development correctly, macros were changed lately to behave the same, so this potential problem might not be that severe. The temporary browser change seems like a total hack to me, anyways – so we should probably add proper support for the use case of running a specific command on a given URL (but this is off-topic).

We can replace the whole thing with a new open-with-command, to be used like this: open-with-command "feh %u" (the name is subject to bikeshedding).

enhancement

Most helpful comment

This is really an interesting discussion.
And one of those, which goal might not be get an "immediate answer" but is very usefull in thinking about the real power and functionality of newsboat.

I'm gonna leave some more additional thoughts, comments and examples here, so that it can be referenced and easly found in the future. Sorry if it may sound to "abstract", and I can't write it clearly.

RANT:
Thinking deeper about the bookmarking functionality, the boomark script, and what that really entails.

Just like I argued before for the "open in browser" concept

..

.. because of the words "browser" and "open" there....but if one reads it as "operate" (what to do) on the url ( the input) to get some other stuff (the output) then the all the power of Unix scripting and piping possibilities becomes more evident.

I just realized that with the "bookmarking" concept, the same thing happens. That is one sees the word "bookmark", and might forget that this can be in fact a much more powerfull operation. That is,

take that "data set":

URL
DESC
COMMENT

and "operate" on that

So again, endless Unix pipelining possibilities and destinations.

I got this thought when I was revisiting this guy's Newsboat "bookmarking" setup:

uriel1998/newsbeuter-dangerzone: Enhanced, modular, bookmarking for newsboat, newsbeuter, or (for that matter) anything that can pass a title and an URL to a program - even from your clipboard.

https://github.com/uriel1998/newsbeuter-dangerzone

He has it since 2013 and has updated it recently.
I am not endorsing it in any way. It's just an example of a publicly available repo with advanced Newsboat hackery. One, among many. I actually find it a bit convuluted, overengineerd and with many bash scripting mistakes.

But that's not my point here.
My point here is again that as a Newsboat user, one might fail to grasp the power available, because of the words "bookmark" .

Just think for a minute of what one can do with just one simple key press C-b (bookmark) and a bit of fzf sugar. The multitude of different "services" and "endpoints" this "app" can reach:

  • Url Shorteners
  • Twitter
  • send to other online bookmarking services (ex. Shaarli )
  • send to Wallabag instance.(which is more than a bookmarking service"
  • pipe to todo.txt
  • Send to email
  • GUI opening with XDG-OPEN;
  • Capture to JPG/PNG/PDF (output)
  • Save to Surfraw / Elinks Bookmark
  • Submit to the Wayback Machine (output)
  • Mastodon via toot (output)
  • Video/Audio via YouTube-Dl (output)

Again, I'm not endorsing or recommending anything. I'm just trying to make a point about thinking "outside the box", when one bumps into the very common and established words/idioms, "open with" or "bookmark this or that".

And that this might be a contribute to, when writing Newsboat docs, "selling it", stressing it, or explaining it better for first time users.

All 4 comments

Just want to chime in, as a long time (power) newsboat end user, to upvote this idea/proposal, and give some feedback. Sorry I'm not a developer, can't comment or provide any coding ideas/directions.

The temporary browser change seems like a total hack to me

It's been, like, years, that I (and many others) have felt the same.
Many times I had thought about submiting a question/issue about this.But somehow always thought that this was something "intrinsic" to the way newsboat was designed from the first day. And that therefore it would be difficult or impossible to change it

There are always many things to improve. And of course one has to choose what to prioritize for development. From an end user point of view I would say that this config line,

macro X set browser "do stuffz ABC"; open-in-browser ; set browser "back to DEF"

is one of the most used, and hacked config lines to "bend" newsboat to do what you want.

I even think that many people new to newsboat, fail to grasp the power of that config line, because of the words "browser" and "open" there. It reads as just "see your article displayed on another web browser"

But if one reads it as "operate" (what to do) on the url ( the input) to get some other stuff (the output) then the all the power of Unix scripting and piping possibilities becomes more evident.

I myself, remember, that only after seeing many different people configs with cool, clever and creative uses of set browser "do stuffz ABC" did I realize that. Always thought, of course you dumb, why have I not thought of this before.

Therefore an improvement here has a huge positive end effect. Totally worth the efffort.

Anyway, this is just to thank you all, and especially Minoru for the leadership, for the amazing work that you've been doing lately and the carefull thought given to this kind of issues.

`

@m040601, thanks for the thorough explanation!

To add to your idea:

I even think that many people new to newsboat, fail to grasp the power of that config line, because of the words "browser" and "open" there. It reads as just "see your article displayed on another web browser". But if one reads it as "operate" (what to do) on the url ( the input) to get some other stuff (the output) then the all the power of Unix scripting and piping possibilities becomes more evident.

Use cases like the one I described in #1175, i.e. macro p set browser "mpv"; one ; set browser "firefox" certainly does not read as "open this podcast in your favorite player". It's fun creating it, but it's also a steep learning curve for users. The fact that mpv is a _media player_ (not a _browser_) is already confusing enough. Same goes for feh which is an _image viewer_.

Seems like a good reason to keep a generic name for the new operation.


I'd like the ability to choose which link to pass to the external command. Along with the existing %u with the browser command, something like open-with "mpv %1" would give the option to choose _any_ link within the article. Another way to type this command could be open-with mpv 1.

Being able to open those extra links from the _article list_ would also be a timesaver.


I myself, remember, that only after seeing many different people configs with cool, clever and creative uses of set browser "do stuffz ABC" did I realize that.

Documenting a few more examples of newsboat typical usage would solve that.
And it could help spread the word about newsboat flexibility.

  • How to open links in a _text-based web browser_
  • How to open links in a _graphical web browser_
  • How to open images in an _image viewer_
  • How to open audio and video files in a _media player_
  • How to open audio files _without_ a graphical environment
  • How to _download_ linked files and _save_ to disk
  • How to use the given URLs in a _shell script_
  • How to execute command in a separate _terminal_
  • How to _isolate_ command and keep on using newsboat while it's running

I can write a draft about those items if that's the intended direction of the project.

@m040601, thanks for another perspective on this! The name for the new operation certainly needs some more thought put into it, to make it generic yet useful enough.

@A1RO, good that you mentioned #1175, I forgot about that use-case already ._. I actually like your mpv %1 idea, but here's yet another: the new command could be something like with <setting name> <setting value> <operation>, to be used like this:

macro a with browser "feh %u" open
macro p with browser "mpv" one

That new operation would work just like with in Python, or bracket in Haskell: it remembers current value of the setting, changes it to the specified value, runs the op, and restores the original value of the setting (even if the operation failed). But I fear this might be a bit too generic and hard to understand for non-programmers.

I can propose a draft about those items if that's the intended direction of the project.

I'm not sure adding more examples really helps, but perhaps it's just my lack of imagination :) Please add a couple and submit a PR for me to see what you mean.

How to isolate command and keep on using newsboat while it's running

We have an FAQ item on this, by the way: https://newsboat.org/releases/2.20.1/docs/faq.html#_after_i_open_a_link_in_the_browser_newsboat_stays_unresponsive_until_the_browser_is_closed

@m040601: There are always many things to improve. And of course one has to choose what to prioritize for development.
@A1RO: But it might also be wise to wait and see for the new operation before suggesting more hacks...

Just to make sure you don't have unrealistic expectations here: all the people who work on Newsboat are volunteers, so I don't have power to make them do something. All I can do is guide the efforts and reject the ones I don't agree with. My own contributions are usually about upkeep, not introducing new features. As a consequence, we don't do priorities; there's no way to force anyone to heed them anyway. For the same reason, we don't have timelines, ETAs, mostly don't tie features to milestones, etc.

Instead, we just follow the interests of individual developers. If someone is interested in working on this, it will be done. Otherwise it won't be.

I understand this puts non-programmers at a hu-u-uge disadvantage (all they can do is wait), but that's just how things are.

This is really an interesting discussion.
And one of those, which goal might not be get an "immediate answer" but is very usefull in thinking about the real power and functionality of newsboat.

I'm gonna leave some more additional thoughts, comments and examples here, so that it can be referenced and easly found in the future. Sorry if it may sound to "abstract", and I can't write it clearly.

RANT:
Thinking deeper about the bookmarking functionality, the boomark script, and what that really entails.

Just like I argued before for the "open in browser" concept

..

.. because of the words "browser" and "open" there....but if one reads it as "operate" (what to do) on the url ( the input) to get some other stuff (the output) then the all the power of Unix scripting and piping possibilities becomes more evident.

I just realized that with the "bookmarking" concept, the same thing happens. That is one sees the word "bookmark", and might forget that this can be in fact a much more powerfull operation. That is,

take that "data set":

URL
DESC
COMMENT

and "operate" on that

So again, endless Unix pipelining possibilities and destinations.

I got this thought when I was revisiting this guy's Newsboat "bookmarking" setup:

uriel1998/newsbeuter-dangerzone: Enhanced, modular, bookmarking for newsboat, newsbeuter, or (for that matter) anything that can pass a title and an URL to a program - even from your clipboard.

https://github.com/uriel1998/newsbeuter-dangerzone

He has it since 2013 and has updated it recently.
I am not endorsing it in any way. It's just an example of a publicly available repo with advanced Newsboat hackery. One, among many. I actually find it a bit convuluted, overengineerd and with many bash scripting mistakes.

But that's not my point here.
My point here is again that as a Newsboat user, one might fail to grasp the power available, because of the words "bookmark" .

Just think for a minute of what one can do with just one simple key press C-b (bookmark) and a bit of fzf sugar. The multitude of different "services" and "endpoints" this "app" can reach:

  • Url Shorteners
  • Twitter
  • send to other online bookmarking services (ex. Shaarli )
  • send to Wallabag instance.(which is more than a bookmarking service"
  • pipe to todo.txt
  • Send to email
  • GUI opening with XDG-OPEN;
  • Capture to JPG/PNG/PDF (output)
  • Save to Surfraw / Elinks Bookmark
  • Submit to the Wayback Machine (output)
  • Mastodon via toot (output)
  • Video/Audio via YouTube-Dl (output)

Again, I'm not endorsing or recommending anything. I'm just trying to make a point about thinking "outside the box", when one bumps into the very common and established words/idioms, "open with" or "bookmark this or that".

And that this might be a contribute to, when writing Newsboat docs, "selling it", stressing it, or explaining it better for first time users.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rpolve picture rpolve  Â·  4Comments

qazip picture qazip  Â·  3Comments

garfieldnate picture garfieldnate  Â·  4Comments

decibyte picture decibyte  Â·  4Comments

j605 picture j605  Â·  3Comments