Coder Social home page Coder Social logo

pbkhrv / ulauncher-notes-nv Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 1.0 210 KB

Ulauncher extension to search, store and retrieve plain text notes, inspired by NotationalVelocity

License: MIT License

Shell 0.15% Python 97.12% Makefile 2.73%
ulauncher ulauncher-extensions ulauncher-extension notational-velocity

ulauncher-notes-nv's Introduction

ulauncher-notes-nv

A NotationalVelocity-inspired Ulauncher extension for storing and retrieving notes as individual text files.

Features

  • Keyboard-centric search-first user experience: every action, including new note creation, begins with a search
  • Intuitive fuzzy search of note titles and contents in Ulauncher
  • Plain text: notes are stored as individual plain text files in a directory - use your favorite tools to keep them synchronized across devices
  • Bring Your Own Editor: use your favorite editor to view and edit notes
  • Clipboard: create notes from the contents of the clipboard, or copy the note contents into the clipboard directly from Ulauncher - useful for managing text snippets

Usage

Open Ulauncher and type in "nv " to start the extension. If everything is configured correctly, you'll see a partial list of your notes files, most recently modified on top:

All notes, no query

Start typing a search query to get instant search results. Select an note and press Enter to open it in the text editor that you configured in Preferences:

Query 1

The more concrete the search, the smaller the list of search results:

Query 2

Use the search query as a title of a new note. Decide whether you want an empty note or one with the contents of your clipboard and press Enter:

Create note

Power user feature: commands

ulauncher-notes-nv allows you to perform simple operations on your notes using a "pipe to" syntax inspired by Unix command line:

cp: Copy note to clipboard

Specifying |cp before or after the search pattern causes the selected note to be copied to the clipboard instead of being opened in a text editor:

Copy note

Copy note

Installation

Open Ulauncher preferences window -> Extensions -> "Add extension" and paste the following url:

https://github.com/pbkhrv/ulauncher-notes-nv

Configuration

  • Notes directory path: path to where your notes files are stored.
  • Command to open note: command to be executed to open the selected note file. Use the {fn} field to insert the full path to the note file. (If left empty, default application associated with that file type will be executed via xdg-open, e.g. default for .txt in Ubuntu is gedit)

Some examples of the "open note" terminal command:

gvim {fn}
gedit --new-document {fn}
gedit

Open note in Obsidian:

xdg-open "obsidian://open?path={fn}"

(If you don't specify {fn}, the note file path will be automatically passed to the editor as the last argument.)

Why?

NotationalVelocity is a Mac OS application with a cult following. In its own words:

NOTATIONAL VELOCITY is an application that stores and retrieves notes.

It is an attempt to loosen the mental blockages to recording information and to scrape away the tartar of convention that handicaps its retrieval. The solution is by nature nonconformist.

The "nonconformist" part is the one where NV ditched the traditional file-oriented actions of "create", "open" etc to reduce the number of steps required to store or access a piece of textual content:

Searching for notes is not a separate action; rather, it is the primary interface.

Searching encompasses all notes' content and occurs instantly with each key pressed.

Notational Velocity's window was designed for keyboard input above all else, and thus has no buttons.

Ulauncher happens to share the search-centric design goals. The only thing it doesn't provide is a text editor, and the hope is that using an external editor won't detract from the overall user experience too much.

Development

I use the following tools while working on this extension:

  • Black code formatter
  • pytest
  • pylint with the flake8 plugin
  • mypy static type checker

You can install them in one shot (except for Black - that's up to you) by running:

pip install -r scripts/requirements.txt

Check PEP8 compliance, perform static type analysis and run unit tests:

make test

Backup the "production" version of the extension and symlink the development version into Ulauncher's extension directory:

make symlink

Quit Ulauncher. Then run it in debug mode:

make run_ul

Run extension in the terminal, connect it to Ulauncher in debug mode:

make run

(if that doesn't work, check the connection string URL printed out by Ulauncher and modify the Makefile accordingly.)

Unlink the development version of the extension from Ulauncher and replace it with whatever was there before:

make unlink

Contributions

Issues and pull requests are welcome!

Inspiration and thanks

I loved NotationalVelocity and its modern fork NVAlt on Mac OS, and I've been (largely unsuccessfully) searching for something as good on Linux for a while. This extension is clearly not "as good" but it's "good enough".

ulauncher-notes-nv's People

Contributors

pbkhrv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

knoopx

ulauncher-notes-nv's Issues

add line number token that can be passed into "open" command

If a match is on a line inside the note, being able to open that file on that line might be helpful (NV does that IIRC).
For instance, gedit accepts line number as argument, so the command would look like this:

gedit %fn +%ln

where %fn is "note file path" and %ln is "matching note line number"

Possible issues:

  • if don't have line number, the command would look different - have 2 diff commands in configuration? that gets a little complicated.

Answer might come after I and others use the extension for a while.

paginate long search results

Need to think about this - ideal user would make the query more concrete by typing more. But (i guess) sometimes you just want to scroll thru results...

  • add "Next page" small item to the bottom of search results if items more than MAX
  • add "Previous page" small item to the top of search results if on page 2+
  • cache search results for this
  • reset pagination to page 1 if search query changes

configurable "open note" command

if not specified, do "xdg-open" via ulauncher's OpenAction()

{fn} token is replaced with the full path to the note being opened

quickly append/prepend line to note without using editor

Proposed syntax 1:

nv feeling ok. morning was good > mood

this would show list of notes matching "mood", and when user selects one of them, extension would prepend "feeling ok. morning was good" to the note.
Using >> should append text to note (similar to shell syntax)

Proposed syntax 2:

nv mood.txt < feeling ok. morning was good

This second syntax can also be triggered by choosing "prepend text" or "append text" command from the "alt+enter" menu

ulauncher should close after opening a note.

After opening a note, ulauncher should close. It does not. It does close if I open some application, say, firefox.

If, however, the note opens in the same workspace as ulauncher, then ulauncher does close in my case, however. Here is my setup:

  1. I use i3wm;
  2. I have my notes editor set up to open in workspace 1;
  3. Call ulauncher while on workspace 2 and open a note with it;
  4. Note opens in workspace 1, however, ulauncher is still opened in workspace 2. It should automatically close.

"command" mode using pipe character

I'd love to be able to copy the contents of a note into clipboard without opening it in an editor first - very useful for snippets, cheatsheets etc. If this works, we might be able to add more "commands".

Proposing the following syntax:

nv apt show files | cp
  • nv apt show files is the usual syntax
  • | means "command follows"
  • cp means "copy to clipboard"

The input above results in following flow:

  • Search notes that matches "apt show files"
  • Every item in search results says "To clipboard: ....txt"
  • User selects one of them and presses Enter, instead of opening that note, its contents are copied to clipboard

If user types just the pipe character without command following it and presses Enter, the list should show the list of commands that can be applied to the note.

support notes files in subdirectories

Great for separating notes into "code snippets", "general" etc

Necessary changes:

  • properly handle path separator / in search
  • note file search depth should be greater than 1
    ...more?

doesn't work on NixOS: "Could not execute 'ls' system command"

Since the location of the ls command is hard-coded at /bin/ls/, this extension won't work on NixOS, which has different locations for these commands. (which ls for me reports /run/current-system/sw/bin/ls).

I think a solution to this would be to replace the function which runs /bin/ls with one that just runs ls, which should be locatable by subprocess, I imagine.

FWIW, if another NixOS user sees this, a dirty workaround is to run sudo ln -s which ls /bin/ls.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.