I am attempting to port one of my hobby project to linux. Preferrably to Mono since it is written in C#. But I am looking into Python as well.
One of the feature of the application is that it needs to associate with a custom protocol so the application is invoked when the user clicks links like this on the app's website:
myapp://module/action
A custom protocol like this, this and this.
How can that be done in linux/unix systems? Can I associate a system-wide handler like in Windows? or does it need to be browser-dependent?
Can't find anything on Google. And I am utterly clueless at linux programming.
I need some pointers. Thanks!
In the ideal situation, this sort of thing is handled by the desktop environment (KDE, GNOME, XFCE), and Firefox respects those settings---it should do so on Ubuntu, Fedora, and OpenSUSE, at least. YMMV:
Integrating a new URIs Scheme Handler to GNOME and Firefox
Adding a protocol handler for firefox (KDE)
The manual way to doing it for firefox:
open firefox
type in about:config to location bar
add new string
name: network.protocol-handler.app.myapp
value: /path/to/program
There's not going to be a single answer, because that will be happening at the X window manager level at best. In general, you're going to need to have some chunk of code you can put into your path, and associate the name with the protocol. Have a look at the about:config page, which is where the handlers are set up.
That's really all that Windows does too, it's just that stuff is in the registry.
This looks like a decent drescription for Firefox.
Can I associate a system-wide handler like in Windows? or does it need to be browser-dependent?
It has to be browser-dependent. There's no cross-browser way of associating URL handlers in Linux.
Related
It looks like Chrome uses xdg-open, so it's sufficient to create a .desktop file for you application and register it via mimeapps.list.
Firefox doesn't appear to honour this. I also tried registering via gconftool as suggested at http://kb.mozillazine.org/Register_protocol#All_Firefox_versions, but Firefox still doesn't seem to recognise the protocol, and entering "myprotocol://foo" just triggers a search rather than launching my application.
Is there a foolproof way to do this on all Linux versions which supports all browsers? Or at least a list of common bases to cover which will work for the majority of distro/browser combinations?
Note: this must be do-able programmatically - I want the application to register itself
I have a webapp with "print invoice" and "print receipt" functions.
How could I accomplish to print in the thermal printer for printing receipts but using the laser printer for invoices 100% silently?
I understand this isn't possible without any client side software previously loaded installed, this functionality is needed just for certain computers. It doesn't matter if the solution is browser specific or OS specific. Also I understand "kiosk mode" allows me to print silently to the default printer.
I have no idea what could be a good solution but was thinking about a Chrome extension or Firefox addon with a custom printing function where I could trigger from javascript like
my_custom_print('printer_b')
or
my_custom_print('printer_a')
Still I have no idea if that is even possible with extensions/addons or need something like NPAPI, PPAPI, java applets, etc...
Any ideas about this?
I'm about 90% sure that you can't silently print to a printer using any technology built into the browser; since NPAPI doesn't work in Chrome anymore (as of version 45) and PPAPI was never something you could use to call native APIs unless you want to pass in special command line flags to enable your plugin, Native Messaging is most likely what you'd need to use for this.
I'm diving into the world of Chrome Extension development, primarily because there is a very small feature that is missing in Chrome that I miss dearly. The context-menu option to "Set as background/wallpaper" like that found in Firefox. Sounds trivial, but it's convenient.
I have most of the "basic" stuff worked out with the manifest file, am able to install it, even managed to get it to show up as a context menu item.
The problem obviously is that I am wanting to mess with a user's OS-level settings which is extremely difficult because of security issues (fully understand this).
I found an extension that allowed this in older versions of Chrome, and it looked like the developer used some type of .dll and C++ to accomplish this.
I'm not really sure how to make this work.
Since that Chrome doesn't allow these kind of manipulations (such as your PC's settings), you will need to create a native application that will run beside your extension. When the user chooses the image from your extension and selects "use as wallpaper", you will use the native messaging API to send a message to your desktop application, that will set the wallpaper (and do whatever else you can't do within a chrome extension) for you.
You can use the chrome.wallpaper app api to set the wallpaper after using the messaging api to send the image from your extension.
Here's the deal. I've animated + coded a variety of 'screensavers' in Actionscript3/Flash. They make extensive use of the timeline, AS3 code, the TweenLite library, and embedded fonts. That's the limit of my programming knowledge. I've tried, to no avail, to convert my .SWFs into screensaver files using a variety of software, such as InstantStorm. Somehow it never works, the code never executes properly, it's a disaster.
So, I'm wondering if it's possible to make a screensaver that simply contains an embedded browser, and have it point to my .SWF file, hosted on my web-server. Basically, imagine a full-screen website acting as a screensaver.
If this is possible, what is the EASIEST and FASTEST way for me to whip up a solution for both PCs and Macs? Language, etc. I'm hoping something that has a library I can simply draw from to embed the browser view :)
My startup is developing a product to do exactly this, it's called Screensaver Ninja and you can find it at https://Screensaver.Ninja.
You can set many different web pages with different timers. The configuration tool allows you log in and navigate to the page you want to display:
It uses WebKit, on Mac OS X it uses Safari's and on Windows it uses Chrome's and in both cases it has a separate session from any other browser installed on the computer.
Here's a small Windows-only solution:
https://github.com/cwc/web-page-screensaver/releases
You could modify this open-source one for the Mac so that it's hard-coded to your URL:
http://www.liquidx.net/blog/2010/11/13/webviewscreensaver-for-mac/
Modify hasConfigureSheet() to return NO and change the URL in kScreenSaverDefaultURL. And change the name!
FvwmButtons (a module of fvwm window manager) has the Swallow function, that embeds
the window of an application into a panel.
I have to do something like this with Motif and Xlib. I want to embed an Xclock into my application. I guess I have to change the Window ID of the embedded app.
How can I do that?
the only supported and reliable mechanism is XEmbed, but it requires the embedded app to cooperate. Without a cooperating app, you're in a world of scary hacks.
The basic thing you need to do is XReparentWindow() but the problem is that you're fighting the window manager which will also want to reparent the window. You're also potentially confusing the app, which will be expecting ICCCM and EWMH behavior, and expecting the parent window to be a WM frame.
Really old GNOME 1.x versions of gnome panel had a swallow feature you could try to steal hacks from maybe.
Without pretty extensive X knowledge this will be painful, and even
with it's not necessarily possible to make 100% reliable.
It looks like you are looking for the XEmbed protocol, documented here.