Created
November 27, 2015 19:20
-
-
Save MadcapJake/c081520b58d5a61a96d5 to your computer and use it in GitHub Desktop.
Open Atom via Gnome Files
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
import gi | |
gi.require_version('Nautilus', '3.0') | |
from gi.repository import Nautilus, GObject | |
from subprocess import call | |
class AtomExtension(GObject.GObject, Nautilus.MenuProvider): | |
def __init__(self): | |
pass | |
def menu_activate_cb(self, menu, file): | |
call(["atom", file.get_uri()[7:]]) | |
def get_file_items(self, window, files): | |
if len(files) != 1: | |
return | |
file = files[0] | |
if not file.is_directory(): | |
mime = file.get_mime_type() | |
if not (mime.startswith("text") or mime.startswith("application")): | |
return | |
item = Nautilus.MenuItem( | |
name="AtomExtension::Open_Atom_Editor", | |
label="Open in Atom Editor", | |
tip="Opens Atom Editor in this location" | |
) | |
item.connect('activate', self.menu_activate_cb, file) | |
return [item] |
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
sudo apt-get install python-nautilus | |
mkdir -p ~/.local/share/nautilus-python/extensions | |
atom !!2/AtomExtension.py |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks! This is helpful. 👍