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

request: allow for using a custom handler/opener, or xdg-open as an alternative to the current way(which opens the wrong browser for me) #98

Open
erikLundstedt opened this issue Feb 7, 2023 · 8 comments

Comments

@erikLundstedt
Copy link
Contributor

I use a custom setup on my system that uses a program called jaro instead of xdg-open to open links(and other things too, its an xdg-open alternative)

however, when I try to open a link in tym, it opens the wrong program(firedragon (firefox-fork installed for testing) rather than vivaldi or firefox (depending on url as i have it open some things in firefox and the rest in vivaldi)

so my question now is: would it be possible to have something like a wrapper around os.execute() or io.popen() that wont freeze tym

(probably) relevant parts of the code:

context.c:

void context_launch_uri(Context* context, const char* uri)

called by builtin.c:
context_launch_uri(context, uri);

github-search-result:
https://github.com/endaaman/tym/search?q=context_launch_uri

@endaaman
Copy link
Owner

endaaman commented Feb 8, 2023

Talking about the behavior when clicking an URI? If so, one solution is to set clicked hook to invoke a custom opener.

tym.set_hook('clicked', function(button, uri)
  if button == 1 then -- left click
    if uri then
      -- invoke a custom opener here
      return true
    end
  end
end)

@erikLundstedt
Copy link
Contributor Author

my question is mostly how to make it not freeze tym itself(Im assuming here that os.execute("jaro" .. uri ) isnt safe to use , although I have not actually tried it)

@TorchedSammy
Copy link

io.popen? popen doesn't block

@js-everts
Copy link
Contributor

@erikLundstedt

The simplest thing would be add an ampersand to make it non blocking:

os.execute("jaro " .. uri .. "&")

@erikLundstedt
Copy link
Contributor Author

erikLundstedt commented Feb 12, 2023

@erikLundstedt

The simplest thing would be add an ampersand to make it non blocking:

os.execute("jaro " .. uri .. "&")

Thanks

I'm usually extra careful when Lua is called from a different program.

Because I know that the implementations used by booth awesome (windowmanager, C/C++) and xplr (TUI file-explorer, rust) have special ways of doing shell command execution

@endaaman
Copy link
Owner

endaaman commented Feb 21, 2023

I think tym should provide only minimal APIs. I can provide some API to launch shell command, but if it isn't related to tym, it should not be implemented in tym. We can also use LuaRocks in Lua context and there maybe a good library.

The problem is what is considered safe. To achieve safety, if we need tym application dependent information, the API should be implemented in tym.

@erikLundstedt
Copy link
Contributor Author

I think tym should provide only minimal APIs. I can provide some API to launch shell command, but if it isn't related to tym, it should not be implemented in tym. We can also use LuaRocks in Lua context and there maybe a good library.

The problem is what is considered safe. To achieve safety, if we need tym application dependent information, the API should be implemented in tym.

I'm thinking there could be a way to utilize the daemon in some way
(like running a tym-instance ,without the UI), I don't know though

@endaaman
Copy link
Owner

To daemonize processes, we should use the propert apps to daemonize.

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

No branches or pull requests

4 participants