Skip to content

Instantly share code, notes, and snippets.

View smeech's full-sized avatar

Stephen Meech smeech

View GitHub Profile
@smeech
smeech / multiple_choice.yml
Created June 18, 2025 15:40
[Implement multiple possible returns for a choice form variable] A minimal script workaround to Espanso's inability to return a variable number of choices. #espanso #python
# Via https://chatgpt.com/share/6852dd0d-dcd4-8012-849f-623787d8408a
# In response to https://github.com/espanso/espanso/issues/2360
- trigger: ":checklist"
replace: "{{output}}"
vars:
- name: output
type: script
params:
args:
@smeech
smeech / currency.yml
Last active May 31, 2025 11:15
[Currency conversion] Responds to e.g. ":10gbp/usd" to convert GBP to USD, can handle decimals, and any currency codes listed in the website below. #espanso #bash #python
- regex: :(?P<amount>\d+(?:\.\d+)?)(?P<src>\w{3})/(?P<dst>\w{3})
replace: "{{output}}"
vars:
- name: output
type: shell
params:
cmd: |
dst_uc=$(echo "{{dst}}" | tr '[:lower:]' '[:upper:]')
rate=$(curl -s "https://open.er-api.com/v6/latest/{{src}}" | jq -r ".rates.$dst_uc")
if [ "$rate" = "null" ] || [ -z "$rate" ]; then
@smeech
smeech / date_format.yml
Created May 21, 2025 12:29
[Date formats] Choice or list box to select today's date in different formats #espanso
- trigger: :date
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'}}
- {name: Another, type: date, params: {format: '%A, %B %d, %Y'}}
- name: Output
type: form
@smeech
smeech / tmux-pi
Last active May 12, 2025 10:10
[tmux-pi] Four-pane tmux to show chrono and filtered processing for two Piholes. Requires tmux and access to two Pi via ssh keys. Works well in a TTY session. #pihole #tmux #bash
#!/bin/bash
# Requires tmux and access to two Pi via ssh keys
# chmod +x tmux-pi to make executable
SESSION=$USER
tmux new-session -d -s $SESSION
# Setup a window for monitoring pi & dietpi
@smeech
smeech / heredoc.yml
Last active March 13, 2025 17:55
[HereDoc] Capture clipboard content, preserving quote characters contained, by using the Here-Document method #espanso #bash #sed
# Capture and process clipboard content, preserving quote characters contained,
# by using the Here-Document method.
- trigger: ":dwq"
replace: "{{MyShell}}"
vars:
- name: Clipb
type: clipboard
- name: MyShell
type: shell
@smeech
smeech / espanso_search
Last active February 4, 2025 14:16
[Espanso Search] Scripts to find and list Espanso trigger/regex values. #espanso #bash #python #pwsh
@smeech
smeech / trigger_espanso.py
Last active February 4, 2025 19:04
[Trigger] A Python script to invoke `espanso match exec -t (trigger)`, which gets around Espanso trying to delete the trigger characters (which don't exist when called in this manner) by injecting the characters first. An alternative to using: `xdotool sleep 0.2 type (trigger)`. Either can be attached to a system hotkey. #espanso #python
# A Python script to invoke `espanso match exec -t <trigger>`, which gets around
# Espanso trying to delete the trigger characters (which don't exist when called
# in this manner) by injecting the characters first.
# An alternative to using: `xdotool sleep 0.2 type <trigger>`
# Either can be attached to a system hotkey.
#!/usr/bin/env python3
import subprocess, sys, time
from pynput.keyboard import Controller, Key
@smeech
smeech / speed.yml
Created January 31, 2025 17:23
[Speed test] between shell: and script: #espanso #powershell
# Espanso speed test between shell: and script
# No discernible difference here on Linux, but recommend using script: to avoid calling
# an unnecessary process
# Conversation at https://discord.com/channels/884163483409731584/1013916990760554608/1253033704599846973
global_vars:
- name: code
type: echo
params:
echo: |
@smeech
smeech / popup.yml
Last active February 4, 2025 22:13
[Popup date selector] #espanso #python
# Espanso popup date selector
- trigger: :ddate
replace: '{{output}}'
vars:
- name: output
type: script
params:
args:
- python
@smeech
smeech / genpass.yml
Last active January 31, 2025 17:32
[Password generator] A simple password generator written while reflecting on an Espanso Hub submission. Called by `:genpass()` for a twelve-character password, or `:genpass(n)` for an n-length password. #espanso #python #regex
# A simple password generator written while reflecting on an Espanso Hub submission
# Called by `:genpass()` for a twelve-character password, or
# `:genpass(n)` for an n-length password.
# The script will add the result to the clipboard for pasting elsewhere,
# if `pyperclip` is installed
matches:
- regex: :genpass\((?P<myvar>\d*)\)
replace: "{{output}}"
vars: