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