-
-
Notifications
You must be signed in to change notification settings - Fork 67
User defined keyboard hooks
You can configure your own shell-scripts to be run on key-presses
The run-hooks are configured through the keybindings file, the most rudimentary example which allows you to safely get the hang of it is to add a line like:
~/.config/astroid/keybindings:
thread_index.run(echo %1)=w
if you press w in the Thread Index the command echo %1 will be run with %1 replaced with the thread-id from the currently selected thread.
A more useful example is to set up keybindings to toggle custom tags, first create a script that can toggle its given tag. In this example the queue tag:
~/.config/astroid/hooks/toggle (you can place this anywhere):
#! /usr/bin/bash
#
# get a tag as first argument and thread id as second argument
#
# check if we have tag
if [[ $(notmuch search thread:$2 and tag:$1) ]]; then
echo "removing tag: $1 from thread:$2"
notmuch tag -$1 thread:$2
else
echo "adding tag: $1 from thread:$2"
notmuch tag +$1 thread:$2
fithen create a keybinding in: ~/.config/astroid/keybindings:
# toggle queue
thread_index.run(/home/gaute/.config/astroid/hooks/toggle queue %1)=w
# toggle todo
thread_index.run(/home/gaute/.config/astroid/hooks/toggle todo %1)=M-tyou can add several lines for different tags. A successful exit status (0) will trigger a refresh of the thread in astroid ensuring it is updated in all thread indexes. The command is passed to: Glib::spawn_command_line_sync. The argument (thread-id) is substituted into the string with ustring::compose().
Future run-hooks for other context may use more arguments, or substitute a list of
thread-ids into the placeholder.
thread_index.run (cmd %1)=keyspec Arguments: one
- thread-id - currently selected thread
Hook return value:
- true - an emit_thread_updated signal is emitted, causing the thread to be updated in all thread indexes.
- false - no action