Sponsored Content
Full Discussion: How to subdue the keyboard?
Top Forums Shell Programming and Scripting How to subdue the keyboard? Post 302946360 by sea on Monday 8th of June 2015 04:24:17 PM
Old 06-08-2015
Quote:
I have already written the morse practice oscillator but one has to tap keys "o" and "p" for the dits and dahs...
Sounds awesome!

Anyway, since you are expecting 'chars', you could just run a case or if block catching the expected ones, and ignore (and/or trap if required/convenient) the other chars.

How about this?
Code:
while read -n1 CHAR
do case "$CHAR" in
    p) (sleep 0.5;echo dah)& ;;
    o) (sleep 0.5;echo dit)& ;;
    q) break ;;
    esac
done

It would 'act' on keypress, but delay the output.

hth

---------- Post updated at 22:19 ---------- Previous update was at 22:15 ----------

Doh, now i get it....
You'd need to catch an actual keypress, or... pipe that output to a function which then returns something when the stream ends.
EDIT: Like a counter value of the time when it started/ended, and then decide according to that value, wether to dit or dah.

hth

---------- Post updated at 22:24 ---------- Previous update was at 22:19 ----------

Like, writing a tempfile:0, first start if 0 add 2 and reset the $TIME_PRESSED, after which you keep adding 1 to tempfile:$tempfile.
And when the stream stops, you set it back to 0, at which time you decide for dit/dah.
This User Gave Thanks to sea For This Post:
 

7 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

How can I map Unix keyboard for PC keyboard

A Solaris AXI 440 machine with Solaris 8 version. I have PC users who use an emulation to login to the Solaris server. How can I change the keyboard mapping of the Sun keyboard to fit to the PC keyboard ? Any comment will be appreciated. Thanks (1 Reply)
Discussion started by: simhab
1 Replies

2. SCO

Kill from keyboard

I have a cron job that creates my backup tape. However my commands in this job are timing out, therefore "Retrying job retry" is the loop it is hung into. I cannot telnet to the box nor get a login prompt. What is the kill command keystone stroke sequence that will break a cron job? Thanks, (3 Replies)
Discussion started by: jwideman
3 Replies

3. Linux

mdk 10.2 and keyboard

Hi all, I'm running a mdk 10.2 cooker on my computer. After and update, i've lost the "alt gr" key. How am i supposed to get it back? I've already googled around a bit, testing solutions provided, but nothing can help.. any other suggestions? Thanx all Jason (3 Replies)
Discussion started by: penguin-friend
3 Replies

4. UNIX for Dummies Questions & Answers

Keyboard keeps locking up

First off, let me start by saying that I am a total rookie when it comes to Unix so I will do my best to explain the situation. BACKGROUND:We are running AIX and using a third party Inventory Management software called Acclaim. My main interface terminal is just a "dummy" terminal hooked up to... (1 Reply)
Discussion started by: sstaszak11
1 Replies

5. Solaris

Keyboard problem

Hi to everyone I am new at Solaris world so I need little help. I can not put my keyboard to Croatian layout. I tried to edit /etc/default/init and in that file I changed LC_ALL=hr_HR. Also I tried to change my language settings over GUI (input methods and SCIIM) but with no results. Also tried... (11 Replies)
Discussion started by: microbot
11 Replies

6. What is on Your Mind?

Keyboard vs mouse

Which Input device do you use the most ? for me... keyboard ofcourse !! (56 Replies)
Discussion started by: vpraveen84
56 Replies

7. UNIX for Dummies Questions & Answers

Problem getting vertical bar with British keyboard layout on US (physical) keyboard

Hi, I've got a bit of a ridiculous problem and wasn't sure where to post it. I need to use the vertical bar for piping in Bash but, as per the title, am using a UK layout on a US (physical) keyboard which doesn't have a key for it in the place I'd expect. I've tried using xbindkeys and Unicode... (7 Replies)
Discussion started by: crunchgargoyle
7 Replies
TEMPFILE(1)						      General Commands Manual						       TEMPFILE(1)

NAME
tempfile - create a temporary file in a safe manner SYNOPSIS
tempfile [-d DIR] [-p STRING] [-s STRING] [-m MODE] [-n FILE] [--directory=DIR] [--prefix=STRING] [--suffix=STRING] [--mode=MODE] [--name=FILE] [--help] [--version] DESCRIPTION
tempfile creates a temporary file in a safe manner. It uses tempnam(3) to choose the name and opens it with O_RDWR | O_CREAT | O_EXCL. The filename is printed on standard output. See tempnam(3) for the actual steps involved in directory selection. The directory in which to create the file might be searched for in this order (but refer to tempnam(3) for authoritative answers): a) In case the environment variable TMPDIR exists and contains the name of an appropriate directory, that is used. b) Otherwise, if the --directory argument is specified and appropriate, it is used. c) Otherwise, P_tmpdir (as defined in <stdio.h>) is used when appropriate. d) Finally an implementation-defined directory (/tmp) may be used. OPTIONS
-d, --directory DIR Place the file in DIR. -m, --mode MODE Open the file with MODE instead of 0600. -n, --name FILE Use FILE for the name instead of tempnam(3). The options -d, -p, and -s are ignored if this option is given. -p, --prefix STRING Use up to five letters of STRING to generate the name. -s, --suffix STRING Generate the file with STRING as the suffix. --help Print a usage message on standard output and exit successfully. --version Print version information on standard output and exit successfully. RETURN VALUES
An exit status of 0 means the temporary file was created successfully. Any other exit status indicates an error. BUGS
Exclusive creation is not guaranteed when creating files on NFS partitions. tempfile is deprecated; you should use mktemp(1) instead. EXAMPLE
#!/bin/sh #[...] t=$(tempfile) || exit trap "rm -f -- '$t'" EXIT #[...] rm -f -- "$t" trap - EXIT exit SEE ALSO
tempnam(3), mktemp(1) Debian 30 May 2011 TEMPFILE(1)
All times are GMT -4. The time now is 06:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy