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

[RFC] Support for custom rules and user script #16

Closed
wants to merge 1 commit into from
Closed

Conversation

sonnyp
Copy link
Owner

@sonnyp sonnyp commented Oct 24, 2021

Feedback and comments welcome.

This is a WIP to implement custom rules and user script.

The userscript runs in strict mode and in the same process as the rest of the application

  1. User shouldn't copy paste stuff from the Internet without understanding
  2. The script has access to gi bindings and as such can do a bunch of cool stuff like triggering notifications and whatnot
  3. Async is not allowed for now
  4. It's not a ESModule, no import / export for now

Here is an example

  • host ~/.config/Junction/userscript.js
  • flatpak ~/.var/app/re.sonny.Junction/config/Junction/userscript.js
// resource is an object containing
// `URI` https://docs.gtk.org/glib/struct.Uri.html
// `content_type` String
// `file` https://docs.gtk.org/gio/iface.File.html

// Always open `*github.com*` URLs with Firefox Developer Edition
if (resource.URI.get_host() === "github.com") {
  return {
    app: "firefox-developer-edition.desktop",
  };
}

// Open Jitsi and 8x8 URLs in the desktop app
if (
  resource.URI.get_host() === "meet.jit.si" ||
  resource.URI.get_host() === "8x8.vc"
) {
  return {
    app: "org.jitsi.jitsi-meet.desktop",
    // https://github.com/jitsi/jitsi-meet-electron/issues/509
    uri: `jitsi-meet://${resource.file.get_uri()}`,
  };
}

// Open Youtube URLs in FreeTube
if (resource.URI.get_host() === "www.youtube.com") {
  return {
    app: "io.freetubeapp.FreeTube.desktop",
  };
}

@sonnyp
Copy link
Owner Author

sonnyp commented May 15, 2022

I'm gonna close this for now due to a lack of interest from users (and myself);

There 2 main cases are already covered by

  1. Remember for domain / file type #5
  2. Domain Specific Applications Possible? #75

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

Successfully merging this pull request may close these issues.

None yet

1 participant