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

Add ability to autocopy JSON #115

Merged
merged 3 commits into from
Dec 7, 2023

Conversation

udoprog
Copy link
Contributor

@udoprog udoprog commented Nov 14, 2023

I have an application I'm working on which can toggle the ability to process the clipboard content as JSON so that translations can be displayed alongside the text being analyzed.

I've also tried to modify the mime type where it is supported (e.g. wl-copy --type application/json) but this seems to largely be ignored in GNOME. It wouldn't hurt to set it though for future reference.

Tried to keep most things as-is and follow the style. But I don't work in Lua a lot so apologies if something is off.

@tatsumoto-ren
Copy link
Member

I've added an option called autoclip_method to make it easier to switch between various ways we can send text to external apps.

@udoprog
Copy link
Contributor Author

udoprog commented Nov 16, 2023

Oh. Yeah. You're getting somewhere! That made me realise I could use a custom command too. But I would appreciate two more knobs:

  • The ability to specify the format independently of the pasting method. Currently if I specify a custom command I think it will just receive text and can't receive JSON.
  • (Preferably) the ability to template the custom command so that it includes a mime type. Something like jpv send-clipboard-data --type %m %d. Maybe this is already supported, but I'm on my phone right now so can't easily check.

@tatsumoto-ren
Copy link
Member

Currently, if a custom command is set, the subtitle line will be passed to it as the last argument. This could be changed to allow for more customization.

What do %m and %d stand for?

I think instead of passing the primary subtitle line unconditionally we could define letters for the primary and secondary subtitle line. E.g., you could call programname --primary %s1 --secondary %s2. In this case, the json option probably doesn't need to be implemented as the receiving program will handle the rest. Plus, I rarely see programs that pass json around using the system clipboard.

You can transfer your application (jpv) to Ajatt-Tools after you join our organization. I'll invite you if you're interested.

@udoprog
Copy link
Contributor Author

udoprog commented Nov 16, 2023

What do %m and %d stand for?

The %m argument would be the mime type in my example, and %d the data. %s1 and %s2 is fine too, with the caveat that %s2 might not be defined.

@tatsumoto-ren
Copy link
Member

Added %MPV_PRIMARY% and %MPV_SECONDARY% args that will be substituted when calling an external process.

@tatsumoto-ren tatsumoto-ren merged commit da39f6d into Ajatt-Tools:master Dec 7, 2023
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

2 participants