Cardapio plugin to search Remmina configurations

Michael Roma on Oct 22, 2011

Cardapio plugin to search Remmina configurations written in python:



You may need to update the path for Remmina configurations, on line 51 below.

#  

Copyright © 2011 mroma (mroma82@gmail.com)

class CardapioPlugin (CardapioPluginInterface): author = ‘mroma’ name = _(‘Remmina’) description = _(‘Searches remmina connections’) url = “ help_text = ” version = ‘0.02’ plugin_api_version = 1.40 search_delay_type = None default_keyword = ‘run’ category_name = _(‘Remmina’) category_icon = ‘remmina’ icon = ‘remmina’ category_tooltip = _(‘Searches remmina connections’) fallback_icon = ‘system-run’ hide_from_sidebar = False # init def init(self, cardapio_proxy, category): “’ This method is called when the plugin is enabled. Nothing much to be done here except initialize variables and set loaded to True “’ self.c = cardapio_proxy try: import os except Exception, exception: self.c.write_to_log(self, ‘Could not import certain modules’, is_error = True) self.c.write_to_log(self, exception, is_error = True) self.loaded = False return self.os = os # get the directory for remmina configs self.dirname = os.getenv(“HOME”) + “/.remmina/” “”” build a list of tuples with (name, filename) “”” # init the list self.list = [] # go through file for f in os.listdir(self.dirname): # make sure a .remmina file if f.endswith(“.remmina”): # go through each line lines = open(os.path.join(self.dirname, f), ‘r’).readlines() for line in lines: # check if the name line, if so, add to the list if line.startswith(“name=”): self.list.append((line[5:255].rstrip(‘\n’), f)); # sort the list, by name self.list.sort() self.loaded = True # set to true if everything goes well # search def search(self, text, result_limit): # save the search test self.current_query = text # search through the list of remmina configurations my_items = [] if self.list and text: for (name, file) in self.list: # check if the configuration name contains the search text if name.lower().find(text.lower()) != -1: # add the item item = { ‘name’ : name, ‘tooltip’ : ‘remmina -c ’ + self.dirname + file, ‘icon name’ : ‘remmina’, ‘type’ : ‘raw-no-notification’, ‘command’ : ‘remmina -c ’ + self.dirname + file, ‘context menu’ : None } my_items.append(item) # show the results self.c.handle_search_result(self, my_items, self.current_query)

Download remmina.py