Skip to main content

Use your local environment variables in Plover

Project description

Plover Local Env Var

Build Status linting: pylint

This Plover extension plugin contains a meta that can read in and output values stored in local environment variables on your computer.

Use Case

Ever have information that is not quite secret enough to warrant putting in a password manager, but not public enough that you want to have steno dictionary outlines containing it available to the public? Information like your phone number, home address, and date of birth is very handy to have in outline values when filling in online forms etc, but I wouldn't want to share that info in my steno dictionaries.

So, in order to be able to share the outlines I use, but not the values contained in them, I put that kind of semi-secret information in environment variables, manage them with direnv, and use this plugin to access them in order to write them out.

[!NOTE] If you prefer to manually write out all your semi-secret information and/or you do not share your steno dictionaries publicly, you may not need to use this plugin at all.

[!WARNING] Please do not put secret information like passwords in your steno dictionary outlines! Plover stands between when you write your keystrokes and when they output on screen, fitting the very definition of a "man-in-the-middle" (see your strokes.log file for what Plover records by default). Use a password manager.

Why a Plugin?

I used to access environment variables from a steno outline like in this example:

"PHAEUL/PHAEUL": "{:COMMAND:SHELL:bash -ci 'osascript $STENO_DICTIONARIES/src/command/actions/output-env-var.scpt EMAIL'}"

This solution does the following:

  • uses the Plover Run Shell plugin to run a shell command from Python
  • calls bash in interactive mode (-i) so that the command can see environment variables ($STENO_DICTIONARIES in this case) defined outside of the Plover environment
  • gets bash to use the osascript command-line tool to load in and run the target compiled AppleScript (.scpt) file
  • The AppleScript in question would then call out to the shell to fetch the $EMAIL env var, and keystroke it out to the screen

This stack of Python->Shell->AppleScript->Shell is convoluted and just not the right tool for the job at hand. Plover Local Env Var just uses Python and Shell, and reduces the outline above to be just:

"PHAEUL/PHAEUL": "{:ENV_VAR:$EMAIL}"

All the fetched values also get cached, so subsequent calls to the same env var get returned quicker.

Install

Until this plugin is added to the Plover registry, download from GitHub or clone using git:

git clone git@github.com:paulfioravanti/plover-local-env-var.git
cd plover-local-env-var
plover -s plover_plugins install .

Where plover in the command is a reference to your locally installed version of Plover. See the Invoke Plover from the command line page for details on how to create that reference.

  • Restart Plover, open the Configuration screen (either click the Configuration icon, or from the main Plover application menu, select Preferences...)
  • Open the Plugins tab
  • Check the box next to plover_local_env_var to activate the plugin

[Future] Once this plugin is added to the Plover registry:

  1. In the Plover application, open the Plugins Manager (either click the Plugins Manager icon, or from the Tools menu, select Plugins Manager).
  2. From the list of plugins, find plover-local-env-var
  3. Click "Install/Update"
  4. When it finishes installing, restart Plover
  5. After re-opening Plover, open the Configuration screen (either click the Configuration icon, or from the main Plover application menu, select Preferences...)
  6. Open the Plugins tab
  7. Check the box next to plover_local_env_var to activate the plugin

How To Use

After defining and exporting environment variables in your shell configuration file, you can use them in your outlines with the ENV_VAR meta. For an environment variable named $PHONE_NUMBER, the outline would look like:

"{:ENV_VAR:$PHONE_NUMBER}"

Pressing the "Disconnect and reconnect the machine" button on the Plover UI resets the environment variable cache. If you make any changes to the values contained in your environment variables, make sure to press it so they get re-read in again.

Development

Clone from GitHub with git:

git clone git@github.com:paulfioravanti/plover-local-env-var.git
cd plover-local-env-var

Python Version

Plover's Python environment currently uses version 3.9 (see Plover's workflow_context.yml to confirm the current version).

So, in order to avoid unexpected issues, use your runtime version manager to make sure your local development environment also uses Python 3.9.x.

Testing

Tests in this plugin were created with Pytest. Run them with the following command:

pytest

Currently, the only parts able to be tested are ones that do not rely directly on Plover.

Linting

Attempts have been made to have at least some kind of code quality baseline with Pylint. Run the linter over the codebase with the following command:

pylint plover_local_env_var

Testing Changes

After making any code changes, install the plugin into Plover with the following command:

plover -s plover_plugins install .

Where plover in the command is a reference to your locally installed version of Plover. See the Invoke Plover from the command line page for details on how to create that reference.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

plover_local_env_var-0.1.0.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

plover_local_env_var-0.1.0-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

Details for the file plover_local_env_var-0.1.0.tar.gz.

File metadata

  • Download URL: plover_local_env_var-0.1.0.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for plover_local_env_var-0.1.0.tar.gz
Algorithm Hash digest
SHA256 83da3ed79ca4b588ce88550c268e2eb7b7e4d06792d6f1237bba2798b62b32bd
MD5 442a236bec042e4b2b7b159ed2bf4248
BLAKE2b-256 337e1042a03a718a54305cdd939854f077b5854c491b5ea9d7025c80bfa2ed2f

See more details on using hashes here.

File details

Details for the file plover_local_env_var-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for plover_local_env_var-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aae6dada9c34b29639bad00b3d7810c6a5b7556ef021953cd50b524521ece2d1
MD5 dc409afd2465cebf3e890a70a9260679
BLAKE2b-256 fe1b2c6c743c4c24f4b4cabfa76d931ddd5be6c94196fcd49ce402f2e9dec964

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page