Simple python krunner plugin, that will show the entered man page in the KDE Help center
Linking to: https://www.kubuntuforums.net/showth...l=1#post360818
Quick copy&paste from https://techbase.kde.org/Development...4/PythonRunner and editing few lines.
metadata.desktop:
	main.py:
	
Seems to work...
							
						
					Linking to: https://www.kubuntuforums.net/showth...l=1#post360818
Quick copy&paste from https://techbase.kde.org/Development...4/PythonRunner and editing few lines.
metadata.desktop:
Code:
	
	[Desktop Entry] Name=Man page runner Comment=Simple python krunner plugin, that will show the entered man page in the KDE Help center Type=Service Icon=help-browser ServiceTypes=Plasma/Runner X-Plasma-API=python X-Plasma-MainScript=code/main.py X-KDE-PluginInfo-Author=<your name> X-KDE-PluginInfo-Email=<your email> X-KDE-PluginInfo-Name=manpage_runner X-KDE-PluginInfo-Version=0.1 X-KDE-PluginInfo-Website=http://plasma.kde.org/ X-KDE-PluginInfo-License=LGPLv3 X-KDE-PluginInfo-EnabledByDefault=true
Code:
	
	from PyKDE4 import plasmascript
from PyKDE4.plasma import Plasma
from PyKDE4.kdeui import KIcon
from subprocess import call
 
class ManPageRunner(plasmascript.Runner):
 
    def init(self):
        # called upon creation to let us run any intialization
        # tell the user how to use this runner
        self.addSyntax(Plasma.RunnerSyntax("? :q:", "Display :q: manpage with the KHelpcenter"))
 
    def match(self, context):
        # called by krunner to let us add actions for the user
        if not context.isValid():
            return
 
        q = context.query()
 
        # look for our keyword '?'
        if not q.startsWith("? "):
             return
 
        # ignore less than 3 characters (in addition to the keyword)
        if q.length() < 3:
            return
 
        # strip the keyword and leading space
        q = q[2:]
        q = q.trimmed()
 
        # now create an action for the user, and send it to krunner
        m = Plasma.QueryMatch(self.runner)
        m.setText("man page for: '%s'" % q)
        m.setType(Plasma.QueryMatch.ExactMatch)
        m.setIcon(KIcon("help-browser"))
        m.setData(q)
        context.addMatch(q, m)
 
    def run(self, context, match):
        # called by KRunner when the user selects our action,        
        # so lets keep our promise
        call(["khelpcenter", "man:" + match.data().toString()])
 
 
def CreateRunner(parent):
    # called by krunner, must simply return an instance of the runner object
    return ManPageRunner(parent)

Seems to work...
							
						


							
						

							
						








Comment