Skip to content

Instantly share code, notes, and snippets.

View smeech's full-sized avatar

Stephen Meech smeech

View GitHub Profile
@smeech
smeech / monitor_log.sh
Created January 31, 2025 17:05
[Monitor Espanso log] Continuously without repeated typing of `espanso log`. #espanso #bash #powershell
# Routines to follow the Espanso log for problems, without having to
# type `espanso log` every time something goes wrong.
# Filters out routine messages.
# Linux
tail -F ~/.cache/espanso/espanso.log | grep -v "INFO"
# Windows
Get-Content "$env:LOCALAPPDATA\espanso\espanso.log" -Wait | Where-Object { $_ -notmatch "INFO" }
@smeech
smeech / variables.yml
Last active January 31, 2025 17:02
[Minimised variables] A compact way of listing multiple variables for e.g. a list form. #espanso
# Espanso minimised variables used in a list Form
# https://onlineyamltools.com/minify-yaml is helpful
- trigger: :td1
replace: "{{Output.Date}}"
vars:
- {name: Day, type: date, params: {format: '%d'}}
- {name: Month, type: date, params: {format: '%m'}}
- {name: Year2, type: date, params: {format: '%y'}}
- {name: Year4, type: date, params: {format: '%Y'}}
@smeech
smeech / URL_extract.yml
Created January 31, 2025 16:54
[Text URL extract] Extract text and URL from copied web-page link. #espanso #python
- trigger: :test
replace: '{{Clipb}} {{Output}}'
vars:
- name: Clipb
type: clipboard
- name: Output
type: script
params:
args:
- python
@smeech
smeech / espanso_move.sh
Last active January 31, 2025 16:51
[Espanso move] Espanso doesn't facilitate repositioning of its Search or Choice etc. windows. This background script waits and moves its windows. #espanso #bash
#!/bin/bash
# A slightly more efficient version of espanso_move.sh which utilises xwininfo.
# Espanso doesn't facilitate repositioning of its Search or Choice etc. windows.
# If the following script is running in the background, it will await the opening
# of the window, and move it to the top left of the screen.
# Adjust the middle two coordinates (,0,0,) for a different position, and reduce
# the lower sleep value (included to reduce CPU load) if it's too slow
@smeech
smeech / delays.yml
Created January 31, 2025 16:44
[Delays] Espanso doesn't support replacements which include delays. A couple of alternatives. #espanso #bash #python
# Espanso doesn't support replacements which include delays
# A solution is to ignore Espanso's own replace and use another tool to inject characters
# Similar methods are available for Windows PowerShell using e.g.:
# (New-Object -ComObject wscript.shell).SendKeys
# Snippet to inject text using xdotool
- trigger: ":xd"
replace: "{{output}}" # Redundant placeholder
vars:
- name: output
@smeech
smeech / delays-characters.yml
Last active January 31, 2025 16:43
[Delays in replacements] Espanso doesn't support replacements which include delays. A solution is to ignore Espanso's own replace and use another tool to inject characters. Similar methods are available for Windows PowerShell using e.g.: (New-Object -ComObject wscript.shell).SendKeys #espanso #python
# Espanso trigger to be used in conjunction with the script test_pynput.py
# Uses the Python pynput library to inject text, instead of Espanso. Enables the
# addition of pauses (sleep) and <Tab> etc. keys and can include Espanso {{variables}}
# See https://pynput.readthedocs.io/en/latest/keyboard.html#controlling-the-keyboard
# Supports type, tap, press, release, and sleep
# Whilst you can add to the replace:, anything there will be injected AFTER the script's
# output
- trigger: :delay
replace: '{{output}}'
@smeech
smeech / default.yml
Created January 31, 2025 16:34
[default.yml] Default Espanso configuration file #espanso
# espanso configuration file
# yaml-language-server: $schema=https://raw.githubusercontent.com/espanso/espanso/dev/schemas/config.schema.json
# For a complete introduction, visit the official docs at: https://espanso.org/docs/
# You can use this file to define the global configuration options for espanso.
# These are the parameters that will be used by default on every application,
# but you can also override them on a per-application basis.
@smeech
smeech / ConvertMarkdown.ps1
Created January 31, 2025 16:31
[Convert markdown] Script to convert Markdown to Plain text, using an Espanso trigger. #espanso #powershell #python
## Script to convert Markdown to Plain text, using an Espanso trigger:
#!/usr/bin/env pwsh
param (
[string]$markdownText
)
# Function to convert Markdown to plain text
function Convert-MarkdownToText {
@smeech
smeech / caseinsens.yml
Created January 31, 2025 16:26
[Case insensitive + word: true] A case-insensitive trigger expansion with word: true functionality. Triggered by "example ????", "EXAMPLE ?????", "exaMPLe ????" etc. #espanso #regex
# A case-insensitive trigger expansion with word: true functionality.
# Triggered by "example ????", "EXAMPLE ?????", "exaMPLe ????" etc.:
- regex: (?i)\bexample(?P<w>\W)
replace: Something{{w}}
@smeech
smeech / assessment.yml
Created January 31, 2025 16:17
[Psychological assessment] Espanso draft form and output for Bswizzles #espanso
# Espanso draft form and output for Bswizzles
- trigger: /mse
replace: >
Client presented as age {{form1.age}} and was {{form1.alert}}.
Client was {{form1.calm}} and {{form1.attended}} to the interview.
Client was dressed in {{form1.clothing}} clothing appropriate for the
setting with {{form1.hygiene}} as though {{form1.not1}} regularly
attending to ADLs.
Eye contact was {{form1.wnl}}. Speech was {{form1.rtv}}.
Client reported mood as {{form1.mood}}.