Friday, November 19, 2010

Clap control for Music PC

When I set up my FreeNAS server, I lost only one program I actually missed: iTunes. Now dont get me wrong, I absolutely hate iTunes as its a restrictive, bloated, and useless peice of crap. However, the Remote app on my iPhone is fucking fantastic and even after trying out alternatives (Namely songbird), the remote control apps just dont cut it.

So ive resurrected my old Compaq (for the 4th or 5th time now), and installed my nLite XP SP3 disc.

Ive installed iTunes 10 on it from a archive site as the lates iTunes refuses to work properly (the remote app wont connect period) but the 10.0 release worked fine. I imported a directory from my NAS into the setup and got it working well with the Remote app. After connecting this setup to the external speakers i set up for my TV, i was able to play some music just fine in the TV area.

However, iTunes doesnt really auto-add new tracks in the folder like i want it to so i bought iTunes folder watch from here. Its a really great app if your going to suck it up and use iTunes. The registered program sits in the background, scans your watch folder and auto-imports the tracks into the iTunes db. Its got quite a few more featuers as well.

However, one thing i was a bit 'meh' about was getting home after a stressful day at work and fiddling around on my iPhone to get it to play music. As it had a internal mic i thought i might be able to work something out.

I then settled on working on being able to play/pause via a clap (i have done voice recoginition programs a long time ago but found them to be fucking frustating when they pick up your voice during conversations). I found a nice and simple freeware program (here) that detected clapping and would run your selected program/action/whatnot.

After a short fiddle around with that awesome program autohotkey, i had 2 .exe files to control iTunes - one for play/pause, one for next song.

All it took was to set up the clap program to run the .exe's upon clap detection and presto! I did rip the microphone and super-glue it facing outward on the exterior of the laptop shell (this compaq is literally falling apart, so it wasnt really a issue)
Now i can walk into the lounge and clap once to start playing music immediately.

Tuesday, August 3, 2010

The Project again, roadblock gone!

Finally, more work on the project.

Problem:

VGA-CAT5 adaptor works (discussed here), but now the monitor cannot detect that its plugged in. So whats been happening is that every time it changes resolution (pretty much start and end of any game) it pops up that annoying 'ANALOGE MODE' box in the upper left of screen for 10 seconds. Also, when the computers plugged in to power it displays the 'NO CONNECTION DETECTED' box that slides around the screen.
Massively annoying, as its a issue thats only cropped up.

Its taken me over a month to figure out how to fix it easily. Simple answer is splice a VGA cable, but damn I bet that would only cause problems down the track.

Reasoning

I figured that since CAT-5 cable has 8 cables, and VGA has 15 pins, obviously some pins arnt being connected. I also assumed that, since monitors don't display all the crap the moment there plugged into a PC even if its not powered on, it must be something hardwired into the plugs on the computer end that allows the monitor to detect its plugged in even if there's no power on in the PC.
It makes sence that it will run a lower power signal through one pin, and look for a reply down another ground line. But with 15 pins, what combination is correct???

Solution
http://www.monitorworld.com/faq_pages/q17_page.html. This is what got me started on the right track. I noticed on this some 'sense' pins and ground pins - this narrowed it down for me from something like 210 different combination's to try to 9 or so.
I hit on the right one on the second go - shorting pings 10 and 5 made the monitor turn blank ready for input like it used to.
From there it was a simple case of cracking open the cheap CAT-5 -> VGA adaptor and soldering a wire directly across pins 5 & 10. Put back together and re-insert. It was so simple! (Not!)


Creating a short that tricks the monitor into permanently realizing its connected on the analogue mode. Once the shell is fitted back on, its as if i hadnt modded it!

Saturday, July 3, 2010

Freenas Transmission Tweaks

Blatantly liberated from http://code.google.com/p/freenas-rss-extension/wiki/MyTweaks.

** FOR THOSE SEARCHING FOR ERRORS RELATED TO "BLOCKLIST_UPDATE: Config directory not set"

The script below searches through FreeNAS' configurtion files to find the torrents 'Config' directory as per the below screenshot. This option is in the WebUI -> Services -> Torrents



You really really shouldnt need to, but if your still haveing huge problems you could try replacing the code:
config_dir=`/usr/local/bin/xml sel -t -m "//bittorrent" -v configdir /cf/conf/config.xml | /usr/local/bin/xml unesc`
With:
config_dir="/path/to/torrent/config/directory/"
Note: Make sure you put the torrent config directory in a location that allows write (i.e. dont put it willy nilly somewhere in the root filesystem - put it in your RAID or on the spare bit of your OS drive)

1) Fix for file permissions when using samba for windozer file sharing.
Why? Well, basically when you log in Anonymously in windows via SMB protocol, it forces your computer to work under FreeNAS's 'ftp' user. Which is fine, untill...
When Tranmission saves a file, it does so under the 'transmission' user. Also fine.
But when you browse to your NAS from windows (being forced to work as the 'ftp' user) and you try and move or whatnot a torrent file (which has been saved as the 'transmission' user) FreeNAS cracks a wobbly and tells you that you dont have permission to do that (as all it sees is one user trying to fiddle with anothers files)

So we can baindaid her up, with the below additions to the 'Auxiliary paramaters' section

This forces the windows client to pretend to be the 'transmission' user, not the 'ftp' user. So it all plays nice!

2) Blocklist updater.
By default, FreeNAS doesnt use a blocklist (in fact, it disables it quite semi-permantly). We can fixxer that up however.

The script below is also taken from the above wiki - I prefer this one because of the location it gets its blocklists from (Bluetack) and the felxibility of lists.

(Big note: If you copy this into notepad and save it onto the NAS, youll encounter one big problem: Windows uses CF+LF to dictate end of line (return). *NIX uses just LF. This confuses the bash interpreter and it will not run. Download and use Notepad2 and when you save the file select 'File->Line encoding-> Unix (LF)' to avoid those problems)

First off: youll have to stop FreeNAS from diabling blocklist. Do so by editing the rc.conf variables via System -> Advanced -> RC.CONF in the WebUI


Either way, before running the file, youll have to log into the NAS via SSH (Enable the SSH service, setup a user in the webUI with 'bash' as its shell, and point Putty to your NAS) and run some commands on the file.


Bonus geek points if you noticed the nethack.alt.org telnet settings!

First, use the SU command (and enter admin password to NAS) to gain 'superuser' privelages, browse to the direcrory using the CD command, and CHMOD +x the file. Then you can run it directly to ensure it works. Like ive done below.

(Note the LS -Gl [this lists the directory in colour mode] - the permissions list to the far left of blocklist.sh is -rwxrwxrwx. The x's mean its eXecutable, which is what we need to run the script (this is what CHMOD +x has done to the file - CHange MODe eXecute)



CODE: blocklist.sh
#! /bin/bash

###
# Select the blacklists you would like to download & use, all available lists
# (except exemptions) are listed below
#LISTS="ads-trackers-and-bad-pr0n bogon dshield edu fornonlancomputers hijacked iana-multicast iana-private iana-reserved level1 level2 Microsoft proxy spider spyware"
#
LISTS
="bogon dshield hijacked iana-multicast iana-private iana-reserved level1 level2 Microsoft"

###
# YOU SHOULD NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING
#
url
="http://www.bluetack.co.uk/config/"
config_dir
=`/usr/local/bin/xml sel -t -m "//bittorrent" -v configdir /cf/conf/config.xml | /usr/local/bin/xml unesc`
updated
=0

if [ "$config_dir" == "" ]; then
logger
-t blocklist_update -- Config directory not set
exit 1
fi

if [ ! -d "$config_dir/gzblocklists" ]; then
mkdir
"$config_dir/gzblocklists"
fi

for list in $LISTS; do
file
="$config_dir/gzblocklists/$list.gz"
lsize
=`stat -qf %z "$file" || echo 0`
rsize
=`fetch -apsw 5 $url$list.gz || exit 1`
if [ "$lsize" -ne "$rsize" ]; then
logger
-t blocklist_update -- Updated $list

# need to download to different folder than $config_dir/blocklists
# transmission seems to have trouble at times starting possibly by trying to parse
# gz'd files
fetch
-qapw 5 -o "$file" $url$list.gz
gunzip
-kqf "$file"
mv
"$config_dir/gzblocklists/$list" "$config_dir/blocklists/"
updated
=1
fi
done

if [ "$updated" -eq "1" ]; then
/etc/rc.d/transmission restart &> /dev/null
else
logger
-t blocklist_updater -- All lists up-to-date
fi

Then its a simple matter of setting up a cron job to run it on a schedule. Below is my settings for midnight every Wednesday.

Note: Your path to the script will differ.

Friday, July 2, 2010

Freenas extras

So after trials in a virtual machine, and three installs on ol' Frankenputer, FrankenNAS lives! Insert demoic laughter and all that.

I was going to do a big walkthrough to installing FreeNAS, but my apathy knows no bounds. Plus, google can tell you how to install it. I think you can install it falling over, actually.

  • Download FreeNAS from http://sourceforge.net/projects/freenas/
  • Burn CD - imgBurn or the like will be a-ok
  • Pop into CD drive, set BIOS to boot from CD and reboot
  • FreeNAS will boot, and run off the CD
  • Youll want to install it to a HDD or CF card (you can get IDE -> CF card adaptors)
  • I went for a Full install + swap. Swap is always fun. Keep in mind that booting the OS off your RAID (if you have a hardware RAID card) is a terrible idea. Grab either the IDE->CF card or a 40/80GB HDD and boot it off that.
  • Once its installed (all what, 15 seconds?) remove the CD and reboot. This time it will be off the HDD
  • Youll end up back at the same menu now. (It runs off the CD exactly the same, however you dont want it to run off the CD permantly - it wont perform all that well)
  • Now press 1. and setup the network (It's likely it guessed all that for you, but configuring it cant hurt) Youll have to select which network device to use (you may well only have 1 so go nuts) Im not sure how its wireless support goes here - I would advise against it anyway.
  • Once thats configured, press 2. Here you should select DHCP (unless you want to manually enter a IP address) and select no for IPv6. It will now give you a funky IP address.
  • FIN
You can now browse to that IP address in your webbrowser! As shown below, it will tell you the IP address you can log in with below.


The steam special is insanity. Oh, and also FreeNAS is shown.

Youll want to set up your hard drives first before hand, obviously.

This post will leave you to play with the webui. Google is your friend here.

Stay tuned for:
  • Transmission (Torrent client) blocklist
  • Transmission RSS auto-downloader
  • Transmission RSS auto-downloader email hack
  • Custom script ive used for email status reports
  • PS3 Media server setup (The pre-installed uPNP server is shite, sorry)
  • Performance Tweaks?