Tag Archive for 'Gnome'

Stata syntax highlighting in GEdit

Stata.lang file goes in ~/.local/share/gtksourceview-3.0/language-specs

Android Studio desktop icon

Android Studio for Linux needs a desktop icon.  This is a functioning one to place in ~/.local/share/applications.

[Desktop Entry]
Version=1.0
Name=Android Studio
Comment=Software Development
GenericName=AndroidStudio
Exec=sh /opt/android-studio/bin/studio.sh
Terminal=false
X-MultipleArgs=false
Type=Application
Icon=/opt/android-studio/bin/studio.png
Categories=Development;
MimeType=text/html;text/xml;application/xhtml+xml
Keywords=programming;java;android;ide;

Name[en_US]=AndroidStudio

Pycharm 2017.3 launcher icon

Pycharm 2017.3 doesn’t create a launcher icon like 2017.2.  This must be created manually.  Here is a functional one.

[Desktop Entry]
Version=1.0
Name=Pycharm 2017.3.3
Comment=Software Development
GenericName=Pycharm
Exec=sh /opt/pycharm-community-2017.3.3/bin/pycharm.sh
Terminal=false
X-MultipleArgs=false
Type=Application
Icon=/opt/pycharm-community-2017.3.3/bin/pycharm.png
Categories=Development;
MimeType=text/html;text/xml;application/xhtml+xml
Keywords=programming;python;ide;

Name[en_US]=Pycharm

The list of available categories so that it appears correctly in application menus is over at the page for the Gnome Desktop Menu Specification.  Development is used to make it appear in the “Programming” applications menu.

 

SHA1 Hash in Right Click Menu

Minecraft’s server.properties file has a field for sha1 hash for resource packs. To use this, install nautilus-python and then copy this python script using any file name (such as sha1_hash.py) into ~/.local/share/nautilus-python/extensions.  This provides a SHA-1 hash on the right click menu.

# Robert Knight, 

from gi.repository import Nautilus, GObject
import hashlib
import urllib

class Sha1Menu(GObject.GObject, Nautilus.MenuProvider):
    """ This places a SHA-1 sum in the context menu in Nautilus.
    To use it, nautilus-python is required.  This script then goes in
    ~/.local/share/nautilus-python/extensions and should work after a 
    restart of Nautilus
    """
    def __init__(self):
        pass

    def menu_activate_cb(self, menu, file):
        print "menu_activate_cb",file

    def get_file_items(self, window, files):
        if len(files) != 1:
            return

        file = files[0]
        filename = urllib.unquote(file.get_uri()[7:])
        sha1sum = hashlib.sha1()
        with open(filename,'rb') as f:
            for chunk in iter(lambda: f.read(8192), ''):
                sha1sum.update(chunk)
        f.close()
        string = sha1sum.hexdigest()
        item = Nautilus.MenuItem(name="Sha1Menu::Show_File_Name",
                                 label="SHA-1: %s" % string,
                                 tip="SHA-1: %s" % string)
        item.connect('activate', self.menu_activate_cb, file)
        
        return [item]

SHA-1 is not the most secure, but is the version used in the Minecraft server for resource pack hashing.