Sponsored Content
Operating Systems OS X (Apple) A simple plaything for a 19 month old and higher. Post 303021018 by wisecracker on Thursday 2nd of August 2018 06:01:51 PM
Old 08-02-2018
A simple plaything for a 19 month old and higher.

This thread today reminded me of it:
Larger window
This is OSX 10.13.6 and greater centric only.
This expands the terminal window on the fly in bash.
You initially need to put the standard terminal window to the top left hand side as far as it goes.
I wrote this for my 19 month old grandson, (17-06-2018), as he loves punching the computer keyboard.
It is a simple keyboard plaything that prints a coloured squared in a random position inside an expanded terminal window. The window size is for a MBP 13 inch device so that is the reason for the odd terminal size.
If the first argument is set to [Yy] then a single alpha-numeric character is spoken so little one can learn said characters as well as printing the random coloured square. If the second argument is set to [Yy] then you can write a sentance of not more than 40 characters to aid in speech learning also with the random coloured square.
If there are no arguments then just the random coloured square is generated per keystroke.
Code:
#!/bin/bash
# Usage: Baby_Play [sppech<Yy>] [word<Yy>]<CR>
# Examples:
# Baby_Play<CR>
# Baby_Play Y y<CR>
#
# For OSX Sierra and above.
# Place default terminal in upper left hand corner.
# Auto expand to maximum size with dock and top bar showing.
printf "%b" "\x1B[8;48;179t"
# Write into terminal header...
printf "%b" "\x1B]0;Baby_Play, press the Delete or Esc, (and Enter), keys to QUIT.\x07"
clear
echo ""
echo "Usage: Baby_Play [speech<Yy>] [word<Yy>]<CR>"
echo ""
echo 'Press the Delete or Esc, (and Enter), keys at any time to QUIT Baby_Play...'
printf "\nPress ENTER/RETURN to continue:- "
read -r -n 1 char
clear
char="Baby_Play_Original_(C)2017,_B.Walker_Licence_CC0."
speech="$1"
word="$2"
colour=$(( ( $RANDOM % 8 ) + 40 ))
x=$(( $RANDOM % 174 ))
y=$(( $RANDOM % 43 ))
escape=$'\x1B'
backspace=$'\x7F'
# Thanks to Corona688 for the stty section below.
inkey() { char="" ; stty -icanon min 0 time 1 ; char=$( dd count=1 2> /dev/null ) ; }
printf "%b" "\x1B["$(( $y + 2 ))";"$(( $x + 3 ))"f\x1B[0;"$colour"m  \x1B[0m"
while true
do
	printf "%b" "\x1B[1;1f\x1B[0m "
	if [ "$word" = "Y" ] || [ "$word" = "y" ]
	then
		printf "Enter word(s), 40 characters maximum:- "
		read -r -n 40 char
	else
		inkey
	fi
	case $char in
		[''${escape}${backspace}])
			break
		;;
		" "|*[0-9a-zA-Z]*)
			colour=$(( ( $RANDOM % 8 ) + 40 ))
			x=$(( $RANDOM % 174 ))
			y=$(( $RANDOM % 43 ))
			if [ "$speech" = "Y" ] || [ "$speech" = "y" ]
			then
				say -v Daniel "$char"
			fi
			printf "%b" "\x1B["$(( $y + 2 ))";"$(( $x + 3 ))"f\x1B[0;"$colour"m  \x1B[0m"
			printf "%b" "\x1B[1;1f\x1B[0m                                                                                "
		;;
	esac
done
# EXIT comes here.
printf "%b" "\x1B[8;24;80t\x1Bc\x1B[2J\x1B[H\x1B[0m"
printf "%b" "\x1B]0;\x07"
clear
echo "Terminal reset back to original state."
exit 0

Have fun little ones.
 

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Backgrounding process with higher priority

I have been troubleshooting a mysterious performance problem with the nightly batch programs on our primary system for quite some time and just found something very interesting. All batch processes are running with a nice value of 24. I don't know what the default is on other systems but I do know... (3 Replies)
Discussion started by: keelba
3 Replies

2. UNIX for Dummies Questions & Answers

grep 2000 and higher

i have content that looks like this: 0003326050 A E LITHO 0023823422 AMERICAN RED CROSS 0005713642 ARUP LABORATORIES 0003206450 CAEL 0002519930 CARDINAL HEALTH 0002619063 FISHER HEALTHCAR 0065203177 OWENS & MINOR INC 0016552938 STAPLES INC 0000002001 MSC... (8 Replies)
Discussion started by: tjmannonline
8 Replies

3. UNIX for Dummies Questions & Answers

print previous month (current month minus 1) with Solaris date and ksh

Hi folks month=`date +%m`gives current month Howto print previous month (current month minus 1) with Solaris date and ksh (7 Replies)
Discussion started by: slashdotweenie
7 Replies

4. Shell Programming and Scripting

if test for higher value between 2 decimal numbers

Hi I would like to test for a max number value. It may be a decimal so I know I have to pipe into bc. I just cannot get the syntax for this to work. I cannot get passed an error with the bracket - see below. Any help appreciated. Regards Ewan This works: /export/home/ewan> cat... (5 Replies)
Discussion started by: emjs
5 Replies

5. Shell Programming and Scripting

Script to counting a specific word in a logfile on each day of this month, last month etc

Hello All, I am trying to come up with a shell script to count a specific word in a logfile on each day of this month, last month and the month before. I need to produce this report and email it to customer. Any ideas would be appreciated! (5 Replies)
Discussion started by: pnara2
5 Replies

6. Shell Programming and Scripting

Convert From Month Number to Month Name

Hi, I have a script that accepts an input date from the user in yyyy-mm-dd format. I need to get the mm-dd part and convert it to month name. example: 2011-11-15 I want that to become "Nov 15" I don't have the GNU date, I am using an AIX os. Thanks. (1 Reply)
Discussion started by: erin00
1 Replies

7. Shell Programming and Scripting

How to add decimal month to some month in sql, php, perl, bash, sh?

Hello, i`m looking for some way to add to some date an partial number of months, for example to 2015y 02m 27d + 2,54m i need to write this script in php or bash or sh or mysql or perl in normal time o unix time i`m asking or there are any simple way to add partial number of month to some... (14 Replies)
Discussion started by: bacarrdy
14 Replies

8. Shell Programming and Scripting

Need last month files after 10th of every month

Hi, I need all file names in a folder which has date >= 10th of last month, Example : files in folder AUTO_F1_20140610.TXT BUTO_F1_20140616.TXT CUTO_F1_20140603.TXT FA_AUTO_06012014.TXT LA_AUTO_06112014.TXT MA_AUTO_06212014.TXT ZA_AUTO_06232014.TXT Output: AUTO_F1_20140610.TXT... (9 Replies)
Discussion started by: nani1984
9 Replies

9. UNIX for Dummies Questions & Answers

Remove when date is higher

Dear Masters, I need to eliminate lines from file input 2 when the date in column 1 more than date in column 1 in file input 1 input 1 20141101|USA|CANSEL|496420000 20141101|USA|CANUT|1069740000 20141101|USA|CANTENG|625920000 20141102|USA|CANUT|413180000 20141103|USA|CANSEL|1364245000... (5 Replies)
Discussion started by: radius
5 Replies
RANDOM(4)						     Linux Programmer's Manual							 RANDOM(4)

NAME
random, urandom - kernel random number source devices DESCRIPTION
The character special files /dev/random and /dev/urandom (present since Linux 1.3.30) provide an interface to the kernel's random number generator. File /dev/random has major device number 1 and minor device number 8. File /dev/urandom has major device number 1 and minor device number 9. The random number generator gathers environmental noise from device drivers and other sources into an entropy pool. The generator also keeps an estimate of the number of bit of the noise in the entropy pool. From this entropy pool random numbers are created. When read, the /dev/random device will only return random bytes within the estimated number of bits of noise in the entropy pool. /dev/random should be suitable for uses that need very high quality randomness such as one-time pad or key generation. When the entropy pool is empty, reads to /dev/random will block until additional environmental noise is gathered. When read, /dev/urandom device will return as many bytes as are requested. As a result, if there is not sufficient entropy in the entropy pool, the returned values are theoretically vulnerable to a cryptographic attack on the algorithms used by the driver. Knowledge of how to do this is not available in the current non-classified literature, but it is theoretically possible that such an attack may exist. If this is a concern in your application, use /dev/random instead. CONFIGURING
If your system does not have /dev/random and /dev/urandom created already, they can be created with the following commands: mknod -m 644 /dev/random c 1 8 mknod -m 644 /dev/urandom c 1 9 chown root:root /dev/random /dev/urandom When a Linux system starts up without much operator interaction, the entropy pool may be in a fairly predictable state. This reduces the actual amount of noise in the entropy pool below the estimate. In order to counteract this effect, it helps to carry entropy pool informa- tion across shut-downs and start-ups. To do this, add the following lines to an appropriate script which is run during the Linux system start-up sequence: echo "Initializing kernel random number generator..." # Initialize kernel random number generator with random seed # from last shut-down (or start-up) to this start-up. Load and # then save 512 bytes, which is the size of the entropy pool. if [ -f /var/random-seed ]; then cat /var/random-seed >/dev/urandom fi dd if=/dev/urandom of=/var/random-seed count=1 Also, add the following lines in an appropriate script which is run during the Linux system shutdown: # Carry a random seed from shut-down to start-up for the random # number generator. Save 512 bytes, which is the size of the # random number generator's entropy pool. echo "Saving random seed..." dd if=/dev/urandom of=/var/random-seed count=1 FILES
/dev/random /dev/urandom AUTHOR
The kernel's random number generator was written by Theodore Ts'o (tytso@athena.mit.edu). SEE ALSO
mknod (1) RFC 1750, "Randomness Recommendations for Security" Linux 1997-08-01 RANDOM(4)
All times are GMT -4. The time now is 01:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy