Last active
March 27, 2026 15:38
-
-
Save dolzenko/03b4b0853dc01b4aac80deb401490e52 to your computer and use it in GitHub Desktop.
Nautilus python extension: Copy Path context menu action. Basically just because Firefox doesn't have that ready in Download manager so you have to go `Right click > Show in folder > Right click > Copy path`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from gi.repository import GObject, Nautilus | |
| import subprocess | |
| class CopyPathExtension(GObject.GObject, Nautilus.MenuProvider): | |
| def menu_activate_cb(self, menu, files): | |
| paths = [f.get_location().get_path() for f in files] | |
| text = "\n".join(paths) | |
| subprocess.run(["wl-copy"], input=text.encode(), check=True) | |
| def get_file_items(self, *args): | |
| files = args[-1] | |
| item = Nautilus.MenuItem( | |
| name="CopyPathExtension::CopyPath", | |
| label="Copy Path", | |
| tip="Copy full file path", | |
| ) | |
| item.connect("activate", self.menu_activate_cb, files) | |
| return [item] | |
| def get_background_items(self, *args): | |
| return [] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment