Aug 182013
 

I recently had to create a whole bunch of directories for my XBMC HTPC so that it could parse the directory contents correctly, so I made a little script to help me do it

This script takes a file extension as an argument, and then creates directories for all the files that have that extension. The directory name is the same as the original file name, minus the extension.

Example Usage: ./convert.sh avi
The example will get all avi files in the current directory and create directories for the files, and then move the files into those directories.

#/bin/bash
OldIFS=$IFS
IFS=$'\n'
shopt -s nullglob
for x in *.$1; do
mkdir ${x:0:(-4)}
mv $x ${x:0:(-4)}
done
IFS=$OldIFS

Share
Aug 172012
 

After seeing this blog post, it got me wondering how many people are in the same predicament where they can’t see what they are typing on the console session on the Raspberry Pi from another computer.

For me, I’ve almost always used SSH, unless I misconfigure the network adapter before taking everything down (or kill the WiFi dongle…oops). But for some people, they actually have space, and a TV/Monitor that they can use with the Raspberry Pi, and they can sit at the Pi to type away. But what if you want to see what you’ve done on your Pi on another computer ?

If you SSH in after you’ve done everything, you won’t be able to see the history, or what’s running on the console session.
To get around that, you can add the following line to ~/.bashrc, and it will start a screen session if there isn’t one running already, or attach to one that is running.

screen -R

Putting that into ~/.bashrc will ensure that there will always be a screen session running when you logon ( unless you kill it, in which case it will start another screen session when you login again ). Only downside to that, is that if you kill the screen session that the console login is attached to, you’ll need to either start another screen session from the console, or re-attach to a new screen session on the console.

To get out of screen without killing the session, you need to use the key combo CTRL-A and then D
That will detach the screen session without killing it.

Share
Aug 152012
 

I have found that occasionally I need multiple windows on my Raspberry Pi so I can keep tabs on top while running a process.
I don’t have a window manager on my Pi however, as I had stripped all of that out.
The solution ?
screen

It has the ability to split the current terminal into 2 terminals so that you can run 2 things side by side and switch between them.
You can use the keyboard key combo CTRL-A and then | to split it side by side, or CTRL-A and then S (this is a capital S) to do a horizontal split.
CTRL-A then TAB will switch between the 2 splits.
When you have just created a new window, you need to switch to the window via CTRL-A , TAB and then hit CTRL-A and then C to start a new session within that new window.
When you’re done, you can hit CTRL-A and then Q to close the other windows.

Share
Apr 202012
 

Update – a newer version has been created here.

With the recent release of the Raspberry Pi, a computer designed to make coding and programming easy, fun, and accessible to children of all ages, there has been some discussion on how to change the memory split between the GPU and CPU.
I have come up with a script to make changing the split easy for all the future programmers who aren’t quite comfortable doing it themselves. I’m not a great coder so if you spot any flaws in this please shout out.

You can download the bash script here.
Feedbask is most welcome as I’m looking to improve the script.

Below is the code for the script itself if you want to copy / paste it instead.
If anyone has any suggestions for the script itself or would like some more options, feel free to express yourself in either the comments section on this port or in this thread


#!/bin/bash
##
## Raspberry Pi Memory Split Selector Script
## Author: SirLagz
## Website: http://sirlagz.net
##
## The purpose of this script is to make selecting the memory split
## on the RPi easy.
## Simply make this script executable if it's not already, move
## it to the directory with the elf files, and run it with ./select.sh
## The menu should be pretty self explanatory.
##
clear
list=./*
b128det=0
b192det=0
b224det=0
bdefdet=0

for i in $list
do
case $i in
"./arm128_start.elf") b128det=1;;
"./arm192_start.elf") b192det=1;;
"./arm224_start.elf") b224det=1;;
"./start.elf") bdefdet=1;;
esac
done

if [[ "$b192det" == "$bdefdet" ]] ; then
diffresult=`diff arm192_start.elf start.elf`
if [[ -z $diffresult ]] ; then
mv arm192_start.elf arm192_start.old.elf
b192det=0
fi
fi

if [[ "$b128det" == "$bdefdet" ]] ; then
diffresult=`diff arm128_start.elf start.elf`
if [[ -z $diffresult ]] ; then
mv arm128_start.elf arm128_start.old.elf
b128det=0
fi
fi

if [[ "$b224det" == "$bdefdet" ]] ; then
diffresult=`diff arm224_start.elf start.elf`
if [[ -z $diffresult ]] ; then
mv arm224_start.elf arm224_start.old.elf
b224det=0
fi
fi

if [[ "$b128det" == 0 ]] ; then
current=128
elif [[ "$b192det" == 0 ]] ; then
current=192
elif [[ "$b224det" == 0 ]] ; then
current=224
fi

declare -i vram
vram=256-$current

echo "##################################"
echo "## Raspberry Pi Memory ##"
echo "## Selector Script ##"
echo "##################################"
echo " Current Memory Split"
echo " CPU $current/$vram VRAM"
echo "##################################"
case $current in
128)
echo "1) Set CPU/VRAM split to 192/64"
echo "2) Set CPU/VRAM split to 224/32"
echo "3) Quit"
;;
192)
echo "1) Set CPU/VRAM split to 128/128"
echo "2) Set CPU/VRAM split to 224/32"
echo "3) Quit"
;;
224)
echo "1) Set CPU/VRAM split to 128/128"
echo "2) Set CPU/VRAM split to 192/64"
echo "3) Quit"
;;
*)
echo "Invalid memory detected"
;;
esac
echo "Enter Choice:";
read x

case $x in
1)
case $current in
128)
mv start.elf arm128_start.elf && mv arm192_start.elf start.elf
;;
192)
mv start.elf arm192_start.elf && mv arm128_start.elf start.elf
;;
224)
mv start.elf arm224_start.elf && mv arm128_start.elf start.elf
;;
*)
echo "Invalid memory detected"
;;
esac
;;
2)
case $current in
128)
mv start.elf arm128_start.elf && mv arm224_start.elf start.elf
;;
192)
mv start.elf arm192_start.elf && mv arm224_start.elf start.elf
;;
224)
mv start.elf arm224_start.elf && mv arm192_start.elf start.elf
;;
*)
echo "Invalid memory detected"
;;
esac
;;
3) exit 0;;
esac
if [[ $? -ne 0 ]]; then
echo "Memory Split setting failed"
fi

Share