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

Open a file from Finder/Explorer #1830

Closed
iansinnott opened this issue Sep 5, 2022 · 7 comments
Closed

Open a file from Finder/Explorer #1830

iansinnott opened this issue Sep 5, 2022 · 7 comments
Labels
TODO The issue is ready to be developed

Comments

@iansinnott
Copy link

Is your feature request related to a problem? Please describe.

No response

Describe the solution you'd like

From the native OS Finder/Explorer the user can open a file in the a wails app. On mac this might mean using the right-click menu and selecting "Open with..." and then a wails app.

If the wails app is registered as the default handler for a specific file type, simply double-clicking on a file from Finder/Explorer should open it in the wails app.

Electron has some prior art here, although an ideal solution for wails/go might look different: https://www.electronjs.org/docs/latest/api/app#event-open-file-macos

Describe alternatives you've considered

No alternatives known other than using something besides Wails.

Additional context

There's also a related discussion: #1829

Wails is currently great for putting a UI on top of a web app or some Go functionality, however, its capabilities would be significantly expanded (IMO) if Wails apps could handle files the same way native apps do. Certain use-cases likely will not be possible otherwise.

@leaanthony leaanthony added this to the v2.1.0 milestone Sep 5, 2022
@leaanthony leaanthony added the TODO The issue is ready to be developed label Sep 5, 2022
@leaanthony
Copy link
Member

Thanks for opening this! I was certain there was a ticket for it already but this is great! I've got code for this on Mac but will need to look into what's available on Windows and Linux. If you have any information on that, please feel free to add it to the ticket. I've scheduled it in for v2.1 👍

@leaanthony leaanthony changed the title Open a file from Finder/Exploer Open a file from Finder/Explorer Sep 6, 2022
@iansinnott
Copy link
Author

Thanks! Sorry, I don't have any info regarding win/lin. I primarily use mac for GUI-related stuff.

@lyimmi
Copy link
Contributor

lyimmi commented Sep 9, 2022

On linux I think there is two ways to do this, one of which needs root permission. (I'm no expert, this is how I use it.)

By "hand"

This registers the app for the current user only!

  1. You need a *.desktop file for the application.
  2. Copy the *.desktop file to ~/.local/share/applications
  3. Add a new line to ~/.local/share/applications/defaults.list like {your mime type}=myapp.desktop

By xdg-mime

  1. You need a *.desktop file for the application.
  2. Create a file type xml for you'r filetype if needed:
<?xml version="1.0"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
  <mime-type type="text/wails">
    <comment>MyApp</comment>
    <glob pattern="*.wails"/>
  </mime-type>
</mime-info>
  1. Register the new mime type: sudo xdg-mime install --mode system MyApp-wails.xml
  2. Make your app default: sudo xdg-mime default myapp.desktop text/wails
  3. Add your icon for it with: xdg-icon-resource (never really figured it out)

Edit:
But probably this should be a post install script for a *.deb file or something, not really an integral part of wails.

@leaanthony leaanthony moved this to 🆕 TODO in Wails Backlog Sep 22, 2022
@leaanthony leaanthony modified the milestones: v2.1.0, v2.2.0 Oct 1, 2022
@leaanthony leaanthony moved this to 🆕 TODO in Wails Backlog Oct 16, 2022
@leaanthony leaanthony modified the milestones: v2.2, v2.3.0 Nov 22, 2022
@leaanthony leaanthony modified the milestones: v2.4.0, v2.5.0 Dec 29, 2022
@sriramr98
Copy link

@lyimmi This thread looks a bit inactive. Is someone working on this? If not, I would like to pick this up.

@lyimmi
Copy link
Contributor

lyimmi commented May 9, 2023

@sriramr98 hi, feel free to pick this up.

@porty
Copy link

porty commented May 10, 2023

macOS specific: I was able to edit the Info.plist file just fine to associate a Wails app with .deb files:

 	<key>NSHumanReadableCopyright</key><string>{{.Info.Copyright}}</string>
+	<key>CFBundleDocumentTypes</key>
+	<array>
+		<dict>
+			<key>CFBundleTypeExtensions</key>
+			<array>
+				<string>deb</string>
+			</array>
+		</dict>
+	</array>
 </dict></plist>

And this works - I can double-click on a .deb file, or right-click, Open With, and it shows up. BUT macOS doesn't simply send through the filename as a command-line argument and I get an error/warning message: The document “whatever.deb” could not be opened. deb-view cannot open files of this type.

See https://apple.stackexchange.com/questions/370427/what-does-macos-actually-do-when-open-a-file

To allow a macOS Wails app to handle opening a file from Finder it would need to handle these messages.

@dami-i
Copy link

dami-i commented Jun 29, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TODO The issue is ready to be developed
Projects
Status: 🆕 TODO
Development

No branches or pull requests

6 participants