Archive for the ‘Xubuntu-Linux’ Category

Home Hub 3 & BT Infinity

Tuesday, February 21st, 2012

At long last super fast broadband has come to our location, so I bit the bullet and went with BT, following a long relationship with Zen, who did offer the service but were just too damned expensive.

The engineer from Openreach appeared on Friday and within the hour I was connected up. The online calculator offered 36 down and 6 up, but immediate experience showed somewhere between 12 & 22 down and 3up, still a vast improvement on 1 down and 0.25 up ;) Was able to do in minutes what previously took hours. I hadn’t expected great things in terms of speed. Given I was paying the same price for 1mb any improvement was worth the switch.

First job was to customise the router (Home Hub 3 HH3). easy to do, but a bit more limited than my trusty old Netgear. No remote access, limited range of IP addresses. This latter point was a pain the in backside, as I have been running my LAN on 10.10.10.x, and the HH3 wouldn’t do this. So some major reconfiguration of my LAN was in order, resetting all the PC’s and devices with new static IPs, rewriting my NFS exports, adjusting host files, editing scripts for sshing in and out. I did forget about my hosts and hostname files on my linux server to start with so internet access (both ways) and sshing didn’t work as expected, but resolved that once I had figured out what was wrong. Had most of this done by the evening.

You need to get into the advanced settings of the HH3 to properly sort out your port forwarding. This is less intuitive than other routers I have used, but that knowledge helped me sort out the ports required for the server.

We then had problems with Firefox, on both Linux and Windows machines. It kept freezing for a few seconds and then starting up again. No fun, so we switched to Chrome/Chromium and all these issues went away. What is odd is you find out how slow the web servers are at the other end, you are limited by how quickly they can load pages, so the speed increase is not necessarily noticeable when generally browsing the web, only when you go to grab a file. (Took 15 minutes to download a 2.2gb iso, for example :)) it is also quicker to copy a file/s from the internet than it is to transfer them from one partition to another on my PC!

BT seem to throttle some file sharing sites and bit torrent which is annoying when you want to fetch a linux distro. I tried using rapidleech but my online server didn’t like it much. The HH3 doesn’t give any visual feedback, just three blue icons staring back at you all the time, with an occasional flicker from the Openreach modem. I got a spare CAT5E cable with the modem so rigged that up to my main PC and the HH3 to get gigabit speed between the two (won’t really help as my LAN is mostly 10/100).

The Dynamic DNS function on the HH3 seems to work OK, the acid test will be when I reboot the HH3 and it gets a new address ;)

Kids are happy as youtube and iplayer are superfast, and multiple user bogging down is no longer a problem.

So all in all, very happy with the changeover, Zen are a better, more flexible and open ISP, but for general use BT are doing just fine. I’ll do an update in a couple of weeks.

Xrandr - turn off one of your multiple monitors

Monday, February 6th, 2012

Xrandr is not just for setting up resolutions and multiple monitors, it will do all sorts of other stuff too, but one thing I need for my carpc project was to be able to programmatically turn off the screen on the netbook (carpc) once it was up and running on the main screen on the car dash. I couldn’t play with X because both screens were running from “one display”. Xrandr to the rescue:

xrandr -q

will give you the names of the screens you have running. Once you know this you can issue a command to turn off which ever screen you like:

xrandr –output LVDS1 –off

where LVDS1 is the name of my netbook display (there are two double hyphens in the above code!)

xrandr –output LVDS1 –auto or  xrandr –output LVDS1 –on will bring it back on

Car-PC Project

Wednesday, 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

Friday, 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

Monday, 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>

Run programs without sudo ?

Saturday, 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

Thursday, 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

Saturday, 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

Wednesday, 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……

Simple Linux Slideshows

Sunday, 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 :) )