Project

General

Profile

Bug #421

How to get a bash script to return true on function key press (for use as a Sylpheed filter)

Added by Bradley Nichols about 1 year ago. Updated 11 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
05/24/2021
Due date:
% Done:

0%

Estimated time:

Description

I'm currently trying to make a filter rule on Sylpheed that deletes a message from server on command, and I was thinking of writing a bash script that returns true when you press something like say, F8, then use that as an argument.
ACES ETM
Unfortunately, that appears to be harder than expected. I've tried this code so far:

#!/bin/sh
f8='^[[19~'
f9='^[[20~'
echo please enter the F8 function key
read -n5 key # Read 5 characters.
echo -n "$key" | grep "$f8" #Check if character code detected.
if [ "$?" -eq $SUCCESS ]
then
echo "F8 key pressed."
return 0
fi
echo -n "$key" | grep "$f9" #Check if character code detected.
if [ "$?" -eq $SUCCESS ]
then
echo "F9 key pressed."
return 0
fi
that I found on the net and modified a bit, but unfortunately it doesn't seem to work (using Fedora LXDE). I got the keypress data for the F8 and F9 keys via using control-v in the terminal, then pressing F8 and same for F9.

I've tried variations of it, by deleting the ^ and changing the read -n5 to read -n4, but grep still keeps saying "grep: Unmatched" etc. Can anyone help out?

Also open to anyone who can show me how to create a filter on Slypheed to delete an email from a server as an alternative solution (apparently it is possible, but I have not been able to get it to work; currently testing it on a gmail account, and any message deleted in the client is not deleted on gmail, and I can't seem to get the filter to run on flagged messages, or coloured messages, or any variation of the above that lets the user select the messages that they want to delete from the server). I cannot switch to IMAP because of client specifications.

#1

Updated by Kentaro Hayashi 11 months ago

  • Status changed from New to Closed

duplicated: #366

Also available in: Atom PDF