Mint Serena 64 bit using the Mate desktop environment. Most of the following scripts will run on this machine, although some have only been tested with the Gnome desktop. Extra software requirements can be met by the Ubuntu and safe PPA repositories. Scripts may be re-written or added to from time to time, the date serves as the version number. Syntax highlighting on these pages is provided by GVim's "Convert to HTML" option.

Weather Scraper


#!/bin/bash
# Filename: weather.sh
# Version.: 21092018
# Author..: robz
#
# Met Office scraper widget.
# Get the url from the web page for your location, chop the date off the end.
# Run from a launcher with this command.
# mate-terminal -t "Current Weather" -e /home/robz/scripts/weather.sh
#
sed1 () { sed 's/<[^>]\+>//g'; }
sed2 () { sed -e 's/^[ \t\n]*//;s/[ \t\n]*//'; }

wsite="https://www.metoffice.gov.uk/public/weather/forecast/qwerty123#?date="
wfile="/home/robz/scripts/weather.txt"
hours=$(date +%H | sed 's/^0//')
today="$(date +%Y-%m-%d)"
check=$(grep 'Timecheck' "$0" | tail -1 | cut -d' ' -f3)

if [[ "$check" != "$hours" ]]; then             # Check stamp at end of script.
    wget -q --retry-connrefused --waitretry=1 \
    "$wsite$today" -O "$wfile"                  # If it's old re-scrape page.
    sed -i '$d' "$0"                            # Delete old time stamp.
    echo "# Timecheck $hours" >> $0             # Insert new.
fi

echo -e "\nTodays weather - $(date +%a' '%d' '%b' - '%H':00') onwards:-\n"

time=$(grep -m1 -A9 'Now' "$wfile" | sed1 | sed2)
aspt=$(grep -m1 -A30 'weatherWX' "$wfile" | sed2 | grep 'title' | \
cut -d\" -f2 | sed -e 's/day\|night//')
prec=$(grep -m1 -A10 'Chance' "$wfile" | sed1 | sed2 | cut -d\; -f2 | tail)
temp=$(grep -m1 -A80 'weatherTemp' "$wfile" | grep 'data-value=' | \
cut -d\" -f2 | sed 's/$/°C/')
wind=$(grep -m10 -A10 '"direction"' "$wfile" | grep 'data-value=' | \
cut -d\" -f2 | sed -e 's/$/mph/')
win2=$(grep -m10 -A10 '"direction"' "$wfile" | grep 'data-value2=' | \
cut -d\" -f2)
gust=$(grep -m11 -A11 '"gust"' "$wfile" | grep 'data-value="' | sed 'n;d;' | \
cut -d\" -f2 | sed -e 's/$/mph/')

hours=$(( 24-hours ))                           # Number of hours to head file.
paste <(echo "$time") <(echo "$aspt") <(echo "$prec") <(echo "$temp") \
<(echo "$wind") <(echo "$win2") <(echo "$gust") | head -n$hours | \
column -s $'\t' -t

echo
echo $(grep -m2 -E 'Sunrise|Sunset' "$wfile" | sed1 | sed2) | column -s -t
read

# Timecheck has to be the last line no blanks.
# Timecheck 13

Clean Scrape


#!/bin/bash
# Filename: clean-scrape.sh
# Version.: 05082018
# Author..: robz
# Clean list of magnet links from "showRSS.info" page source scrape.
# Add to your file browser scripts directory for right click usage.
# Usage: In the web browser, right click - "View Page Source" - "Select All" 
# left click - drag to desktop - right click - run script

cd '/home/robz/Desktop'
[ -e 'dropped text.txt' ] || exit
sed '/1080p\|720p/d;/href="magnet/!d;s/.*href="//;s/" .*//' 'dropped text.txt' \
| sort -t= -k3 -o 'dropped text.txt'
mv 'dropped text.txt' 'add-magnet.txt'
exit

Fix Subtitle Offset


#!/bin/bash
# Filename: srt-fix-offset.sh
# Version.: 20052018
# Author..: not robz
# A script to modify subtitle offset beyond the Kodi maximum of 60 seconds.
# Put original titles in a file called "srt.txt" in your home directory and
# run the script.
# In all honesty this is pretty much a copy paste job from Linux Questions.
# For more detailed information goto:
# www.linuxquestions.org/questions/linux-newbie-8/editing-srt-files-4175436550/
#
# Modify and comment the offset variable as appropriate.
# Advance subtitles.
offset="75 seconds"
# Retard subtiles.
#offset="5 seconds ago"

while read start s end; do
    if [[ $start =~ ^..:..:..,... ]]; then
        start=$(date -d "$start $offset" +%H:%M:%S,%N)
        end=$(date -d "$end $offset" +%H:%M:%S,%N)
        echo ${start:0:12} $s ${end:0:12}
    else
        echo $start $s $end
    fi
done < srt.txt >> new-subtitles.srt

DAB Radio


#!/bin/bash
# Filename: dab-radio.sh
# Version.: 07022018
# Author..: robz
# Basic DAB radio via a cheap DVB-T dongle using a "zenity" gui and the command
# line version of "vlc player", see man vlc. The utility "wmctrl" places the gui
# top left of the screen. The initial scanning for radio stations I used the
# "w_scan" utility to create a playlist text file.

text="Make a selection"
optn=":dvb-frequency=522000000 :dvb-bandwidth=8 :dvb-ts-id=4168 \
:dvb-code-rate-hp=2/3 :dvb-modulation=64QAM :dvb-transmission=8 \
:dvb-guard=1/32 :program="

get_mplex () {
prog=$(zenity --list --radiolist --height=400 --width=200 --hide-header \
--title='robz DAB Radio' --text="$text" --column '' --column '' --column '' \
--hide-column=3 --print-column=ALL --ok-label='Play' \
FALSE 'BBC Radio 1' '6720' \
FALSE 'BBC Radio 1 Extra' '5888' \
FALSE 'BBC Radio 2' '6784' \
FALSE 'BBC Radio 3' '6848' \
FALSE 'BBC Radio 4' '6912' \
FALSE 'BBC Radio 4 Extra' '5824' \
FALSE 'BBC World Service' '6016' \
FALSE 'BBC Radio 5 Live' '5632' \
FALSE 'BBC Radio 5 Sport' '5696' \
FALSE 'BBC Radio 6 Music' '5760' \
FALSE 'BBC Manchester' '6152' \
FALSE 'BBC Lancashire' '6216'
)
}

while true; do
    (sleep .5 && wmctrl -r "robz DAB Radio" -e 1,0,0,200,400) &
    get_mplex
    text="<b>Playing: $(cut -d'|' -f1 <<< $prog)</b>"
    prog="$(cut -d'|' -f2 <<< $prog)"
    pkill -9 vlc
    if [ "$prog" = '' ]; then exit; fi
    (cvlc dvb-t:// $optn$prog > /dev/null 2>&1) &
done


Morse 2


#!/bin/bash
# Filename: morse2.sh
# Version.: 03102017
# Author..: robz
# Enter words hear morse.

trap 'kill -9 $pid 2>/dev/null; echo; exit' TERM EXIT

declare -A morse
morse[A]=".-"     morse[B]="-..."   morse[C]="-.-."   morse[D]="-.."
morse[E]="."      morse[F]="..-."   morse[G]="--."    morse[H]="...."
morse[I]=".."     morse[J]=".---"   morse[K]="-.-"    morse[L]=".-.."
morse[M]="--"     morse[N]="-."     morse[O]="---"    morse[P]=".--."
morse[Q]="--.-"   morse[R]=".-."    morse[S]="..."    morse[T]="-"
morse[U]="..-"    morse[V]="...-"   morse[W]=".--"    morse[X]="-..-"
morse[Y]="-.--"   morse[Z]="--.."   morse[1]=".----"  morse[2]="..---"
morse[3]="...--"  morse[4]="....-"  morse[5]="....."  morse[6]="-...."
morse[7]="--..."  morse[8]="---.."  morse[9]="----."  morse[0]="-----"
morse[.]=".-.-.-" morse[,]="--..--" morse[?]="..--.."

while true; do
    read -p "Input a word or sentence: " input
    echo
    while read -n1 character; do
        character="${character^^}"
        if [ "$character" ]; then
            echo -ne " $character\t"
            while read -n1 dotdash; do
                tput bold
                [ "$dotdash" = "." ] && duration="0.2" || duration="0.4"
                echo -n "$dotdash"
                (speaker-test -t sine -f 400 >/dev/null) & pid="$!";\
                sleep "$duration"; kill -9 "$pid"
                tput sgr0
            done < <(echo -n "${morse[$character]}")
            sleep 0.2; echo
        else sleep 0.4; echo
        fi 2> /dev/null
    done < <(echo -n "$input")
    echo
done