What is #Wox
Win + S is a great launcher running on Windows: http://www.wox.one/
I use Alfred (+ Powerpack) on macOS, but I found it when I was looking for a similar usability launcher in the recently assigned Windows environment. I can create a plugin with C # and Python. , Alfred workflow (although not as flexible) You can do similar extensions.
As mentioned above, I'm an Alfred user, so I chose Python because I want to port my own Alfred workflow written in Python. To run the plugin written in Python, I need to install Python 3 separately and tell Wox where I am. Therefore, I feel that the hurdles are a little high in terms of widespread use. Unless there is a particular concern, it seems better to develop in C #.
Click here for official documentation: http://doc.wox.one/en/plugin/create_plugin.html
The point is that Wox passes user input to the plugin, so it's as simple as returning the corresponding result in JSON. The developer receives the string because the helper class makes it good for each language while saying JSON. Just return an array of dicts (for Python).
Wox displays the options based on the array returned by the plugin, and a callback is generated for the item selected by the user, so process it (as soon as you open the browser or folder). Select the item that does not contain callback information. Can not.
Used by Wox to run the Python plugin. After installation, specify the installation destination from the Wox setting screen.
--- git init
--Make sure that the previously installed Python 3 works (I used pyenv because I created a development environment on WSL)
Create a plugin.json
file by referring to Official
{
"ID": "1AEB702E890911EABAF20C54152B91EC", //Plugin ID,32 bit UUID
"ActionKeyword": "sample", //Plugin default action keyword
"Name": "sample plugin", //Plugin name
"Description": "sample plugin", //Plugin description
"Author": "kosugi", //Plugin Author
"Version": "1.0.0", //Plugin version,must be x.x.x format
"Language": "python", //Plugin language,we support csharp,python and executable now
"Website": "https://qiita.com/kosugi", //Plugin website or author website
"IcoPath": "Images\\icon.png ", //Plugin icon, relative path to the pluign folder
"ExecuteFileName": "main.py" //Execution entry. Dll name for c# plugin, and python file for python plugin
}
--ID is python -c'import uuid; print (uuid.uuid1 (). Hex.upper ())'
etc.
--Version is played when registering to the official repository unless it is in the format x.x.x
as per the document (there is no problem if it works at hand)
--IcoPath is often installed under the ʻImages` directory, but there is no problem even if it is directly under it.
Looking at the Official Sample Program, I read that wox.py
is needed, but I don't know the correct procurement method. Probably executed from Wox. When it is done, it may be included in the module search path, but what should I do during development?
Upon examination, it was included in Wox's GitHub repository (it doesn't seem necessary to clone the repository itself).
wget https://raw.githubusercontent.com/Wox-launcher/Wox/master/JsonRPC/wox.py
If wox.py exists when running from Wox, it will be prioritized and should not be included in the archive (described later) or the installation destination.
main.py
# -*- coding: utf-8 -*-
from wox import Wox
class Main(Wox):
def query(self, user_input):
# user_Returns the result corresponding to input
return [{
'Title': 'Displayed on the first line(test: ' + user_input + ')',
'SubTitle': 'Displayed on the second line',
'IcoPath': 'Icon displayed on the left.png',
'JsonRPCAction': {
'method': 'action', #Method name called at the time of selection
'parameters': ['Argument 1 passed to method', '2...'],
'dontHideAfterAction': False
}
}]
def action(self, data1, data2):
#The item has been selected and will be processed
pass
if __name__ == '__main__':
Main()
When the script is executed, the JSON given as a command line argument is interpreted by the Wox
class of the wox.py
at hand, and the query
method is called. Specifically, it is executed as follows.
$ python main.py '{"method": "query", "parameters": ["user intput"]}' | jq
{
"result": [
{
"Title": "Displayed on the first line(test: user intput)",
"SubTitle": "Displayed on the second line",
"IcoPath": "Icon displayed on the left.png ",
"JsonRPCAction": {
"method": "action",
"parameters": [
"Argument 1 passed to method",
"2..."
],
"dontHideAfterAction": false
}
}
]
}
If you use the method of executing main.py
, you cannot check the callback (here, the behavior when the ʻaction` method is called), so you need to actually install it on Wox and check it, but if you devise it, you can test it. It would be possible to write.
--Digging a directory with an appropriate name directly under the Plugins
directory of the Wox installation destination, and placing plugin.json
, main.py
and the icon file.
--Restart Wox or run Reload Plugin Data
from Wox.
--Can be called from Wox by entering the ActionKeyword specified in plugin.json
When called via Wox, the display looks like this:
If you register an account on http://www.wox.one/plugin, you can register the created plugin. You can search and install the registered plugin from Wox.
For registration, use a ZIP archive of the required files. The extension should be wox instead of zip.
You can search for unicode name and copy the corresponding character to the clipboard, or copy the character corresponding to the code point you entered to the clipboard. You can install it with wpm install Unicodebuilder (query)
and wpm install Unicodebuilder
, respectively. Alfred Then you can include multiple ActionKeywords in one workflow, but Wox doesn't, so we separated the plugins.
Recommended Posts