code: def make_desktop_entry(d):
      
      assert d['path'].endswith('.desktop')
  
      # default values
      d.setdefault('comment', '')
      d.setdefault('icon', '')
  
      # Format the command to a single string.
      if isinstance(d['cmd'], list):
          d['cmd'] = ' '.join(d['cmd'])
  
      assert isinstance(d['terminal'], bool)
      d['terminal'] = {False: 'false', True: 'true'}[d['terminal']]
  
      fo = open(d['path'], "w")
      fo.write("""\
  [Desktop Entry]
  Type=Application
  Encoding=UTF-8
  Name=%(name)s
  Comment=%(comment)s
  Exec=%(cmd)s
  Terminal=%(terminal)s
  Icon=%(icon)s
  Categories=%(categories)s
  """ % d)
  
      if d['tp'] == 'kde':
          fo.write('OnlyShowIn=KDE\n')
      else:
          fo.write('NotShowIn=KDE\n')
  
      fo.close()
docs: Create a desktop entry that conforms to the format of the Desktop Entry
      Specification by freedesktop.org.  See:
              http://freedesktop.org/Standards/desktop-entry-spec
      These should work for both KDE and Gnome2
  
      An entry is a .desktop file that includes the application's type,
      executable, name, etc.   It will be placed in the location specified within
      the passed dict.