Skip to content
/ kuma Public

A cross platform, tab completion, emacs keybinding Alfred-like tool

License

Notifications You must be signed in to change notification settings

wufangjie/kuma

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Features

Usage

  1. Search the web
  2. Run applications (or activate/close application window)
  3. Open file with default application
  4. Eval one line python code (advanced calculator)
  5. Your imagination

NOTE: use space to seperate keyword and arguments

Tricks

  1. Space is not supposed to occur in keyword, indeed I use it to recognize keyword, but you can use it for completion (for commonly used command)
  2. You can use “keyword new” to force kuma open a new application (if the command do) rather activate one window
  3. When the popup have too many rows (> 2), try to press <Control-l>, see section “Emacs keybindings” below for detail
  4. Try `restart` keyword

Completion

  1. Keyword completion and path completion
  2. Path completion should start with ~/, / (also work for windows) or c:/(only for windows)
  3. Short keywords are too hard to remember, I think the whole word plus completion is better
  4. I think less used applications need not to be added to keyword’s completions

Custom keybinding and custom workflow

See below

Shortages

  1. First time adding commonly used apps is painful
  2. Only implement exact prefix matching

Requirements

basic

  • Python3
  • PyQt5

Linux sp

  1. python3-xlib is required, which may have been already installed by default
  2. xprop command line tool, which may have been already installed by default

NOTE: xprop is included in x11-utils on ubuntu 18.04

Windows sp

win32api

NOTE: pip install may raise ImportError, please download exe from the following url: https://sourceforge.net/projects/pywin32/files/pywin32/

or you can just install anaconda

MacOS sp

  • pyobjc-core
  • pyobjc-framework-Cocoa
  • pyobjc-framework-Quartz

Run kuma

NOTE: Do not run kuma multiple times (global hotkey will only call the first kuma)

Linux

by hand

python3 travel_async_but_risky.py

startup

I think it’s just a piece of cake for linux guys

For me, xfce4-session-settings -> Application Autostart -> then add command: python3 {absolute path}/travel_for_linux.py

Windows

by hand

Double click travel_for_windows.pyw

startup

http://www.intowindows.com/how-to-add-apps-to-startup-in-windows-10/

MacOS

fcitx support

  1. find PyQt5’s library path
from PyQt5.QtWidgets import QApplication
app = QApplication.instance() # must before FM
if app is None:
    app = QApplication(sys.argv)
print(app.libraryPaths())
  1. then you will see the paths, for example:
['/usr/local/lib/python3.8/dist-packages/PyQt5/Qt5/plugins', '/usr/bin']
  1. then
sudo cp /usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/libfcitxplatforminputcontextplugin.so /usr/local/lib/python3.8/dist-packages/PyQt5/Qt5/plugins/platforminputcontexts/
sudo chmod +x /usr/local/lib/python3.8/dist-packages/PyQt5/Qt5/plugins/platforminputcontexts/libfcitxplatforminputcontextplugin.so

Custom

keywords

see `system_config.json` and `user_config.json`

NOTE:

  1. “Keyword” in user_config should be unique in certain platform
  2. “Pattern”: you can write a regular expression to match window’s appname or title better, ” means use keyword instead
  3. “Platform”: must in {”, ‘Windows’, ‘Linux’, ‘Darwin’}, ” means available on all platforms
  4. user_config keyword has higher priority than system_config (Overwrite)
  5. Sp type keyword only work in system_config, which has highest priority (Built-in)

shortcuts

see `shortcuts.json`

Tab

  1. Complete
  2. Insert (if only one completion)
  3. Insert longest common prefix
  4. Complete with the selected row (popup’s)

Enter

  1. Run command
  2. Select completion
  3. Complete path or keywords when possible
  4. Run user-defined callback

move_to_golden_row

if a popup has 9 rows:
    if the highlighted row in the upper half:
        then jump to line 7 (change with the number of rows)
	# NOTE: this will let you go to any row within 3 keystrokes
    else:
        jump to line 3
so do other popup with different number of rows

theme

see `theme.json`

About workflow

  1. You only need to implement a main function which will be called when you press <Enter> after type in the workflow’s name.
  2. Use the main function’s returned value to interact with kuma.
  3. The default python file of a workflow is ‘workflow.py’.format(workflow_name), or specify “File” attribute in config to change it.
  4. See base.py and the workflows.py for more details

About kuma and travel

From one of the most popular cartoon “One Piece”.

Bartholomew Kuma, whose Devil Fruit ability can send people to any place easily, just like the thing I want my script do.

TODO:

  1. sogou input method on win10, not occur in the proper position (decay)
  2. complete without case sensetive
  3. disable kuma’s Alt+F4 for misoperation

About

A cross platform, tab completion, emacs keybinding Alfred-like tool

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages