Car-PC Project

December 14th, 2011

See this link for progress so far:

http://www.fullfatrr.com/forum/topic8786.html

HTML Auto Slideshow using Javascript and php with dynamically generated array of Images

October 14th, 2011

Another holy grail for me, to be able to just add images to a directory and have the slideshow automatically pick them up and display them withoput having to edit html /javascript code. Most scripts I had found for an html slideshow required the array created inside the script, this way you use php to generate the array and then the javascript runs with it. Only downside is you will need php up and running, but most web servers online have this by default now.

My blog is a bit broken at the moment so will have to link the files to Ubuntuforums

http://ubuntuforums.org/showpost.php?p=11339174&postcount=2

  1. Images will be shown at their actual size, so you may need to add some html code to the tag in the to restrict the images size.
  2. On your server, go to the place where you want the html file to be and upload the index.html file there, then create a sub-directory called pics and upload the getimages.php file to the pics directory.
  3. Next upload all your images to the pics directory.
  4. Done.

Acknowledgements to all the clever people who wrote the original scripts and files

Auto Web Page Changer using iframe

May 23rd, 2011

Oh I like this. In seeking to setup a rolling web browser display display at work, I came upon this small but very clever bit of javascript, which on a timer will change the web page being viewed inside an iframe. Just edit the defaults to you preferred pages and timings and away you go:

 <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Changing Pages… Please Wait</title>
<script type=”text/javascript”>
var frames = Array(’http://www.google.com/’, 15,
‘http://www.yahoo.com/’, 15,
‘http://www.ask.com/’, 15,
‘http://www.dogpile.com/’, 15);
var i = 0, len = frames.length;
function ChangeSrc()
{
if (i >= len) { i = 0; } // start over
document.getElementById(’frame’).src = frames[i++];
setTimeout(’ChangeSrc()’, (frames[i++]*1000));
}
window.onload = ChangeSrc;
</script>
</head>
<body>
<iframe src=”" name=”frame” id=”frame” width=”100%” height=”100%”></iframe>
</body>
</html>

I had to put a fixed height in there as 100% wasn’t giving 100% just 10% at the top of the page. This script repeats adinfinitum. If you only want it to run once, use this one:

 <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Changing Pages… Please Wait</title>
<script type=”text/javascript”>
var frames = Array(’http://www.google.com/’, 15,
‘http://yahoo.com/’, 15,
‘http://www.ask.com/’, 15,
‘http://dogpile.com/’);
var i = 0, len = frames.length;
function ChangeSrc()
{
document.getElementById(’frame’).src = frames[i++];
if (i >= len) return; // no more changing
setTimeout(’ChangeSrc()’, (frames[i++]*1000));
}
window.onload = ChangeSrc;
</script>
</head>
<body>
<iframe src=”" name=”frame” id=”frame” width=”100%” height=”100%”></iframe>
</body>
</html>

and it gets better! Now the next set of code does the rolling web pages, with no border on the iframe, no scrollbar on the iframe, and with a fix for full height and width in Firefox:

 <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Changing Pages… Please Wait</title>
<style type=”text/css”>
html, body, div, iframe { margin:0; padding:0; height:100%; }
iframe { display:block; width:100%; border:none; }
</style>
<script type=”text/javascript”>
var frames = Array(’http://www.google.com/’, 15,
‘http://www.yahoo.com/’, 37,
‘http://www.ask.com/’, 12,
‘http://www.dogpile.com/’, 14);
var i = 0, len = frames.length;
function ChangeSrc()
{
if (i >= len) { i = 0; } // start over
document.getElementById(’frame’).src = frames[i++];
setTimeout(’ChangeSrc()’, (frames[i++]*1000));
}
window.onload = ChangeSrc;
</script>
</head>
<body>
<div>
<iframe src=”" name=”frame” id=”frame” width=”100%” height=”100%” border=”0″ scrolling=”no”></iframe>
</div>
</body>
</html>

XP - Missing User Profile

May 23rd, 2011

A rare fix for a problem on XP suffered by my father following a twofold issue of full C:/ drive and a powercut! When he restarted the PC it appeared that he had lost everything, and just booted up to a new plain and empty profile.

So first off I cleared out some cruft using C-cleaner and got 1GB of space back, then moved a load of installation files to some redundant space on the PC and got back another 500mb.

Then to restore his profile I headed into: My Computer (right click) > Properties > Advanced tab > User Settings. This brings up a dialog listing the user profiles available on the PC. I identified his original profile which had been labelled back up and the new profile that had been created when he restarted. Tried to delete this new profile but couldn’t. So into Control Panel > Users and created a new user with Admin rights. Logged out, logged into the new user and went to user profiles and deleted the new profile for his main system. Logged out and logged back into the main user and thankfully his profile returned. Then deleted the newly created user account.

All done :)

Run programs without sudo ?

May 7th, 2011

Wouldn’t normally do this, or recommend it, but for occasional and considered use this is a useful tip.You need to run a program normally requiring sudo, but as a normal user. The usual way of fixing this is to put a line in /etc/sudoers, but you still need to type sudo.The problem I had was with a custom iso I have been putting together. because my WM was openbox I was using a bash script with zenity to provide reboot and shutdown. This was all set up fine, but on installing the distro from the live cd, the installation needed to add a line to the bottom of /etc/sudoers, thereby negating my previously entered line.A long trawl through google provided an answer on ubuntuforums, which was to change the set uid bit for the shutdown command, so that all users could run shutdown with needing sudo. As you can see, doing this to a more important command would create security holes, but in this instance there is not much a hacker can do with shutdown, other than shutdown…AFAIK !!So here is the command I used:

sudo chmod a+s /sbin/shutdown

which gives the following permission:

 645 -rwsr-sr-x  1 root root    46864 2011-01-22 01:58 shutdown

I edited out the sudo shutdown in my script and replaced it with /sbin/shutdown and all is well

Run Once Only Bash Scripts

April 21st, 2011

I am constantly amazed by what can be achieved with a simple bash script or two. I had a situation where I needed a script to run only once, and to not get any errors spat out at me from the cli. I needed a second script to call the run once script to go into rc.local, a file I didn’t want to mess with, so the call in rc.local would just be a quick file check after the first run. for me, the clever bit is that the scriptI have to do the work can “move” (rename) itself once it has done its business, thereby ensuring it is not called upon again, but is still there if needed.

Here’s the script that does the work (called once.sh):

#!/bin/bash
Do the work

echo “I am now going to back myself up :)!”
sleep 2
mv once.sh once.sh.bak
echo file backed up
sleep 2
exit 0

The key line is the mv command, running on itself! I’ll remove the comments for the production setting

Here’s is the script that calls the one above (called runitonce.sh):

 #!/bin/bash
if [ -f ~/once.sh ]
then
echo the file exists
sleep 2
~/once.sh
else
echo the file does not exist
sleep 2
fi

Basically, if once.sh is there, this script, runitonce.sh, runs once.sh, which when finished, renames itself. If once.sh is not there, the script just finishes. Subsequent runs of the script runitonce.sh called in rc.local just run through as there is no file to run. Simples :)

Play your entire music collection - Mplayer One Liner

April 16th, 2011

Sometimes just plain lazy, and want just to play music. Run this command in the background (ALT+F2) or in a terminal for playback of all your mp3/ogg/m4a/wma, shuffled, looped, normalised. What’s nice about this is that the shuffle algorithym does a good job and with a large collection of music you don’t get repeats. I found that trying the same thing with vlc meant the shuffle was  always the same, and so you always started with the same music. :( Anyway the one-liner:

find ~/Music \( -iname “*\.mp3″ -o -iname “*.m4a” -o -iname “*.ogg” -o -iname “*.wma” \) -exec mplayer -nocache -af volnorm -shuffle -loop 0 ‘{}’ + &

Change “~/Music” to suit.

Even better put this in a script, and link to a keyboard shortcut, or add to your startup?

Now running the one liner from a terminal takes a bit of stopping, you’ll need to CTRL+C a couple of times in quick succession to close find then mplayer. Or you can run another one-liner:

killall -15 find mplayer

If you run the command from a script, you’ll have to shut down the script first, and then kill off the running instances of find and mplayer. Best to also do this from a script as well. Say the script you use to run is called singles.sh, let’s create another called endsingles.sh which contains:

#!/bin/bash

killall -15 singles.sh
killall -15 find
killall -15 mplayer

I am sure someone clever could bind this all together in one script, based upon a keyboard shortcut toggle or something…

Prevent Screen Blanking on Xubuntu CLI / Slim / Openbox Install on Asus EB1012 nettop

April 6th, 2011

Normally I am able to take care of screen blanking through the gui powersaving options in Xubuntu, however my command line install followed by installing openbox and using slim as a login manager presented me with real problems. teh screen would blank and half kill the x server, leaving a reboot as the only option. I found some xset options which I put into a script and added this to autostart.sh, which seemed to take care of X issues, but the terminal blanking was still going on. Using setterm I was able to stop terminal blanking but had to find a place to put it on startup. This turned out to be in /etc/profile (for all users). So now writing this post from my non blanking setup :)

sudo nano ~/.config/openbox/noblankx.sh

#!/bin/bash

xset s blank

xset s 0 0

xset -dpms

I was able to test this by outputting xset -q > test.txt at the end of the script, which produced

Keyboard Control:
auto repeat:  on    key click percent:  0    LED mask:  00000000
XKB indicators:
00: Caps Lock:   off    01: Num Lock:    off    02: Scroll Lock: off
03: Compose:     off    04: Kana:        off    05: Sleep:       off
06: Suspend:     off    07: Mute:        off    08: Misc:        off
09: Mail:        off    10: Charging:    off    11: Shift Lock:  off
12: Group 2:     off    13: Mouse Keys:  off
auto repeat delay:  660    repeat rate:  25
auto repeating keys:  00ffffffdffffbbf
fadfffefffedffff
9fffffffffffffff
fff7ffffffffffff
bell percent:  50    bell pitch:  400    bell duration:  100
Pointer Control:
acceleration:  2/1    threshold:  4
Screen Saver:
prefer blanking:  yes    allow exposures:  yes
timeout:  0    cycle:  0
Colors:
default colormap:  0×20    BlackPixel:  0    WhitePixel:  16777215
Font Path:
/usr/share/fonts/X11/misc,/usr/share/fonts/X11/100dpi/:unscaled,/usr/share/fonts/X11/75dpi/:unscaled,/usr/share/fonts/X11/100dpi,/usr/share/fonts/X11/75dpi,/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType,built-ins
DPMS (Energy Star):
Standby: 600    Suspend: 600    Off: 600
DPMS is Disabled

The important bits for this are in bold.

Now add the script to autostart.sh

nano ~/.config/openbox/autostart.sh

and add the line:

~/.config/openbox/noblankx.sh &

Now for terminal blanking

sudo nano /etc/profile

scroll to the bottom and add

setterm -blank 0 -powersave off -powerdown 0

[EDIT] You can also put this command in /etc/rc.local, it works just the same :)

A reboot is necessary to test it out.

More information is available from man xset and man setterm but google is better to get real examples of usage.

Looking for a way to view the current settings for setterm, to see what is in place……

Call of Duty / Black Ops / Modern Warfare Disconnecting from Xbox Live on Start Up

April 4th, 2011

Off beat post this.

My sons Xbox started misbehaving the other day, and refused to run the Call of Duty games connected to XBox Live. The games would start up Ok, but then disconnect from XBox Live - not good. Googled a lot but not much out there (a lot about it disconnecting during games but not on start up.)

General advice was to clear the system cache, or wait at the dashboard for a while, open ports on the router, reset the console, recover gamertag, but these didn’t work. Other games like Team Fortress would play OK, though.

Finally I tracked down the solution, which was to set a FIXED IP Address for the XBox on the router. It had been working fine previously on DHCP, but suddenly stopped working. The fixed IP address resolved all the issues on all the games.

I am an utter cult :)

Simple Linux Slideshows

March 6th, 2011

For running in X:

Use feh

sudo apt-get install feh

Set up a directory with photos in it, e.g. ~/photos or ~/Pictures and then run this command:

feh -zZxF -D 10 ~/photos

(-z for random, -Z for autozoom, -x for borderless windows, -F for fullscreen, -D for time on screen)

You might try using unclutter to get rid of the mouse cursor, but on some setups this doesn’t work well with feh, alternatively just move the mouse down into a corner somewhere

For framebuffer: (assumes you have your framebuffer up and running OK, see here for how)

Use fbi

sudo apt-get install fbi

Set up a directory with photos in it, e.g. ~/photos or ~/Pictures and then run this command (n.b. you might need sudo depending on your setup):

(sudo)fbi -ua -t 10 ~/photos/*

(-u for random, -a for autozoom, -t for time on screen)

Press V on the keyboard to hid the status line (although its a nice added feature)

(A nod in the direction of KMandla for getting me going on this :) )