Posts

Showing posts from August, 2015

morse script 2

I'll copy in the actual code below later, but I can't right now because I'm using ssh to a headless machine at work. I gave up on reading the letters from a separate text file - seemed like too much overhead for what I wanted to do. Instead I've found out how to create an associative array within my bash script. This'll let me pass the user input variable as a key that will return the binary value. SO, I have the following: #!/bin/bash # declare array and assign values to each letter # make sure no spaced between array var, = and ( declare -A morseCode_arr=( [a]=01 [b]=1000 [c]=1010 [d]=100 [e]=0 [f]=0010 [g]=110 [h]=0000 [i]=00 [j]=0111 [k]=101 [l]=0100 [m]=11 [n]=10 [o]=111 [p]=0110 [q]=1101 [r]=010 [s]=000 [t]=1 [u]=001 [v]=0001 [w]=011 [x]=1001 [y]=1011 [z]=1100 ) echo 'Input string' read user_input #loop over the characters if the user input for (( s=0; s<${#user_input}; s++ )); do # retrieve the value from the array and assign to a new va

morse script 1

Last night I got it to the point where it'd take single characters of user input and play them as a long beep if 1, a short beep if 0 and error if other. It would only take one digit at a time though; a string of digits was rejected. At that stage it looked like this: #!/bin/bash echo "Enter a sequence of 1s and 0s representing dashes and dots:" read user_input for x in $user_input; do         if [[ $x = 1 ]]         then beep -l 300 -D 50         elif [[ $x = 0 ]]         then beep -l 150 -D 50         else echo "$x is not an acceptable character"         fi done I recognise that this is poorly formed. Anyway, I need it to iterate over each character in the user input. I see references to sed and awk and whatnot, and I don't understand that stuff, so I'm going to use the most basic form I can. I found the answer here : You can use a traditional for loop: foo = string for (( i = 0 ; i < $ {# foo }; i

morse script 0

I've been trying to think of good little projects or challenges to undertake, probably in bash, that'd help me develop my knowhow, so when I was in the bath reading Tales of Pirx the Pilot by Stanislaw Lem it gave me the idea of a little morse code testing script. The idea is that it beeps out letters at you and you have to enter the letter you think it is. I guess that then builds to using a file of dictionary words and then maybe sentences from your e-books or whatever, but one step at a time! I have a vague, aspirational notion that this could be worth submitting to Linux Voice, who are soliciting for writers at the moment. might be pie in the sky, but maybe worth a shot. So, what's my approach? Well, my first thought was to use bash, rather than python or antything. I'm looking for a real basic angle. Are there any built-in commands that use the system beep? It seems not in my Arch install, but I quickly find that my instinct to type "beep" is no

mate lock screen background

God, I've spent ages googling this after I moved some wallpapers around and the lock screen background changed to a horrible gradiant. I should've looked more closely at the Arch wiki, of course, where I eventually discovered this entry . looking at  /usr/share/glib-2.0/schemas/mate-background.gschema.override of course, I discover that I've already set this for an absolute path that's no longer valid. Sorted via the following amendement: org.mate.background] picture-filename='/usr/share/backgrounds/default.jpg' where default.jpg is a copy of my currently selected wallpaper. THEN you have to glib-compile-schemas /usr/share/glib-2.0/schemas/ and restart x