Windows shell extension on Mac and Linux

I am making an application (first for Windows, but expanding to Mac and Linux as soon as possible) and I will need to expand the shell on both platforms in order to achieve the best usability. So, how can I make a shell extension for Mac OS X as well as Linux (based on GNOME) in C #?

Windows has a library called SharpShell that handles almost all of this for you, so great. But there is no such luck for Mac or Linux (as far as I can tell).

The main aspects of Shell that I want to integrate with are right-clicking on a file and displaying a context menu with various options for my application. (Like 7-Zip on Windows)

When I use the term shell, I get it from Windows. Therefore, when I say that I want to integrate with Shell, I mean creating context menus with right-clicking and similar functions. All user interfaces.

+5
source share
2 answers

You are trying to apply a concept defined in Windows environments (context menu) to a completely different * NIX environment. This is a difficult task, and very difficult, because * NIX does not provide a friendly API for changing the environment, since fragmentation is Desktop / Shells (Gnome, KDE, etc.). Windows Shell is explorer.exe and provides a shell and a desktop, explorer.exe shows you the desktop, the launch button bar and the explorer window (for navigating through files, devices and directories), so in Windows we only have a program for this, Linux or OSX follows a different design, on Linux we have a Desktop Manager (Gnome, KDE, LXDE), it shows you the desktop, but for interacting with files we have another program called File Manager (Nautilus, Dolphin, etc. .). But I must say that it is difficult, but not impossible.

To do this, you need to write an abstraction layer (AL). Your program should only call this layer, and you will need to redirect AL to every platform / desktop manager that you have.

Example:

Let's say we have the AddContextualItem (...) function in our AL to add a new item to the Shell context menu, your code should call this function, but for Windows environments this function will certainly call some WIN32 API to perform this task. but in OSX Environment or Linux, this AddContextualItem function must be replaced with another version compatible with the unix environment (for example, Gnome, KDE, etc.) or a specific file manager (Nautilus, Dolphin, etc.).

Ultimately, C # seems to be the best language to perform such a task, Xamarin does a great job with the Mono Framework, but that’s not enough. C or C ++ is a more powerful language for this.

How to add a right-click menu to Nautilus File Manager (Gnome)

Source code for nautilus actions

How to add a right-click menu to Dolphin File Manager (KDE)

Apple's official documentation for creating a service (such as a menu of right-click menu items) in OS X

+3
source

Linux does not have a shell.

It has many different applications that provide a “shell” -like functionality and many others that provide functionality similar to a file manager.

There are several specifications (listed below) that may be relevant to your goal here and which may help you do some of this in a general way, but ultimately I don’t know how close you are going to get an analog.


-3
source

All Articles