Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Sunday, 21 February 2021

Replacing CRLF from files

Remove CRLF from files


The following is a number of methods you can use to strip ^M from files.

This was more of an exercise than a feature I need regularly. However, there was a recent incident at work where someone had checked-in such an abomination. Some tools just don't like Windows line endings in files, ie. CRLF, Carriage Return Line Feed. So, as an exercise, here is a collation of the numerous ways to fix these aberrations ...

Note Most editors have a quick way of doing this.

file

You can see whether a file has ^M using the file command:

Example

Consider a file containing ^Mfile reports:

$ file test.txt
test.txt: ASCII text, with CRLF, LF line terminators

After stripping ^M, we have:

$ file test-fixed.txt
test-fixed.txt: ASCII text

dos2unix

Probably the simplest way is to use the dos2unix command.

Example

Show file has ^M line endings:

$ dos2unix -i test.txt
       3      16       0  no_bom    text    test.txt

Now fix:

$ dos2unix test.txt

Proof that file has been fixed:

$ dos2unix -i test.txt
       0      19       0  no_bom    text    test.txt

Haskell

There is a simple Haskell program to do this:

fixcrlf.hs
#!/usr/bin/env runhaskell
 
import           System.Environment (getArgs, getProgName)
 
main = getArgs >>= \args -> case length args of
  1 -> mapM_ (putStrLn . filter (/= '\r')) . lines =<< readFile (head args)
  _ -> getProgName >>= \p -> error $ "Usage: " ++ p ++ " [file_name]"

Example

$ ./fixcrlf.hs test.txt > test-fixed.txt
$ file test.txt test-fixed.txt
test.txt:       ASCII text, with CRLF line terminators
test-fixed.txt: ASCII text

Perl

Using Perl:

$ perl -pi~ -e 's/^M//g' source.file

Where ^M is a control character entered by CTRL-v followed by CTRL-m.

This will keep a backup with the original file saved to source.file~.

Example

$ perl -pi~ -e 's/^M//g' test.txt
$ file test.txt~ test.txt
test.txt~: ASCII text, with CRLF line terminators
test.txt:  ASCII text

Python

Using Python:

fixcrlf.py
#!/usr/bin/env python3
 
import sys
 
if len(sys.argv) == 2:
    with open(sys.argv[1], "r") as f:
        for line in f:
            print(line.rstrip('\r\n'))
else:
    print(f"Usage: {sys.argv[0]} [file-to-fix] > [fixed-file]")

Example

$ ./fixcrlf.py test.txt > test-fixed.txt
$ file test.txt test-fixed.txt
test.txt:       ASCII text, with CRLF line terminators
test-fixed.txt: ASCII text

Ruby

Using Ruby:

fixcrlf.rb
#!/usr/bin/env ruby
 
raise "Usage: #{$PROGRAM_NAME} [file-to-fix] > [fixed-file]" if ARGV.length != 1
 
File.foreach(ARGV[0]) { |line| puts line.chop }

Example

$ ./fixcrlf.rb test.txt > test-fixed.txt 
$ file test.txt test-fixed.txt
test.txt:       ASCII text, with CRLF line terminators
test-fixed.txt: ASCII text

Using shell tools

Using the translate tool, tr:

$ cat source.file | tr -d '\r' > source.file.fixed

This can also be used in a more general fashion to remove non-printable characters from a file:

tr -dc '[:print:]\n' < source.file > source.file.changed

Example

$ cat test.txt | tr -d '\r' > test-fixed.txt 
$ file test.txt test-fixed.txt
test.txt:       ASCII text, with CRLF line terminators
test-fixed.txt: ASCII text

Tuesday, 6 September 2016

Converting MS Documents to PDF using LibreOffice

I've been a long time user of LibreOffice. I first started with StarOffice, before moving to OpenOffice, and finally the latest incarnation, LibreOffice. While I use office suites less, preferring Wiki's and if a versioned document is required, LaTeX, I still on occasion receive MS documents. Rather than reading these documents in MS-Word or MS-PowerPoint formats I prefer to convert to a PDF. Here is how to do that. The following shows how to convert a presentation to a PDF. It is a headless operation that works just as well over a set of documents.
loimpress --headless --convert-to pdf presentation.pptx 
Similarly,
lowriter --headless --convert-to pdf document.doc 

Friday, 7 March 2014

Bash arrays - what is the difference between array[*] and array[@]?

I've just been updating some Bash scripts and noticed that there are two ways to refer to array elements: one using the "*" the other using "@". So what is the difference? According to the manual
The "@" variable allows word splitting within quotes (extracts variables separated by whitespace). This corresponds to the behaviour of "$@" and "$*" in positional parameters.
So you get two different outcomes as demonstrated below:
$ ARRAY=(0 1 2 3 4 5 6 7 8 9)
 
# first using "@" inside quotes,
# you get the same output with no quotes ...
$ for i in "${ARRAY[@]}"; do echo "$i"; done
0
1
2
3
4
5
6
7
8
9
 
# same as above but using "*" ...
$ for i in "${ARRAY[*]}"; do echo "$i"; done
0 1 2 3 4 5 6 7 8 9
 
# but without quotes ...
$ for i in ${ARRAY[*]}; do echo "$i"; done
0
1
2
3
4
5
6
7
8
9
Source: http://www.tldp.org/LDP/abs/html/arrays.html

Friday, 28 September 2012

How To Upgrade Linux Mint Debian Edition

Upgrade

I recently had to perform upgrades for multiple machines from Update Pack 4 to Update Pack 5. It was really rather easy to do as the following instructions show.
Thanks to this blog for correcting some of my mistakes.

Update the Update Manager

The update manager will indicate when updates are available. For a distribution upgrade like Update Pack 5, I revert to command line. Use CTL-ALT-F1 to switch to a native console session. Then update the update manager with the commands
sudo apt-get install mint-debian-mirrorssudo apt-get install mintupdate-debiansudo apt-get --fix-missing --list-cleanup updatesudo apt-get install mintupdate-debian

Run Distribution Upgrade

So, now we are ready to perform the upgrade with
sudo apt-get --fix-missing --list-cleanup updatesudo apt-get dist-upgrade

Questions Asked During Upgrade

Questions will be asked during the upgrade. If you have a default installation you can normally use the package maintainers version. If unsure check the differences.
With kernel updates you will be asked where to install Grub.
Answer with the location of your current Grub menu, which on most systems is /dev/sda.

Post Upgrade Tasks

Get Best mint-debian Mirror

After installation refresh mirrors with
sudo dpkg-reconfigure mint-debian-mirrors
When I did this I got the following error.

How to Solve NO_PUBKEY 07DC563D1F41B907

Thanks to this blog for this solution.
If we add the repository http://www.debian-multimedia.org  on Debian testing
it can happen that when we try to execute the comand apt-get update, we see a GPG error:
W: GPG error: http://www.debian-multimedia.org squeeze Release:The following signatures couldn't be verified because the public key is not availableNO_PUBKEY 07DC563D1F41B907
To solve this problem we need to install the debian-keyring package
apt-get install debian-keyring
And then execute this command:
gpg --keyring /usr/share/keyrings/debian-keyring.gpg -a --export 07DC563D1F41B907 | apt-key add -
After that, when we try to execute apt-get update, there will be no the GPG error anymore.

Google Chrome

The repositories for Google Chrome (I use the beta releases) are no longer valid. Google recommends downloading the Debian package and re-installing. This updates the Debian repositories.

Thunar Slow to Start

This is due to Thunar trying to auto-mount network drives. It is easy to fix with,
vi /usr/shares/gvfs/mounts/network.mount
And set 
AutoMount=false

Monday, 6 August 2012

Using True Type Fonts in XTerm

I’ve not had to use TrueType fonts before as my desktop display resolution never warranted it. Now with eyesight failing and much better monitors, I decided to give them a go. Fonts are globally managed by settings in /etc/X11/app-defaults. However, TrueType fonts can be locally set using ~/.Xresources.
To browse the list of fonts use
fc-list :fontformat=TrueType -f "%{family}\n" | sort -u | less
Test a font by specifyng in the xterm command -fa option
xterm -fa 'Luxi Mono' -fs 10
Where fa refers to the fonts face name, and fs, the font size.

Once happy with your font, apply to your application in ~/.Xresources
For example to apply for XTerm
! my customisations
XTerm*faceName: DejaVu Sans Mono
XTerm*faceSize: 11
The final step is to set these resource changes using xrdb
xrdb -merge .Xresources
So, next time you invoke a plain xterm command you will be greeted with your new font.

Friday, 6 July 2012

How To Generate SSH Keys for automatic login to target host


To Generate Key

On source host run ssh-keygen(1)
ssh-keygen -t rsa -b 2048Take defaults on prompts.
This will generate two files in .ssh
.ssh/id_rsa.pub
.ssh/id_rsa
Copy these from source to target host with
cat .ssh/id_rsa.pub | ssh user@target "cat >> .ssh/authorized_keys; chmod 600 \ .ssh/authorized_keys"
Now you can login without password from source to target using
ssh target

References

http://www.openssh.org/manual.html
http://www.wikihow.com/Use-SSH
http://en.wikipedia.org/wiki/RSA_(algorithm)

Saturday, 19 November 2011

Linux Mint on HP Mini 110

I have a little experimental machine for playing with different distributions. Lately, the HP Mini 110-1081TU has been running MeeGo. Now it has been commissioned to run Linux Mint. This comes in a variety of flavours. The one reviewed here is Linx Mint Debian 201109. While the download was a monstrous 1.1G, the installation is the fastest I've ever seen. It literally took 10 minutes! 
Post Installation - Wireless
This is where the fun begins. First off, I had trouble getting wireless to work.  Reading dmesg gave very helpful instructions.  Read the recommendations carefully! Doing so can save you much time and effort. The HP Mini 110 uses a Broadcom 4312 WLAN. Install the packages b43-fwcutter and firmware-b43-lpphy-installer. I recommend the Linux Wireless page as it has exceptionally good documentation.
Post Installation - Sound
Sound quality is actually better than under previous Linux distributions I've tried. So I was very happy that I need no special post installation tasks. This is more a reflection on the hardware than the software.
The settings for the HP Mini 110 are HDA Intel (Alsa mixer) with Master, Headphone and Beep controls active. Use the last control to silence that nasty boot-up PC beep. The beep is issued from GDM. If you get errors about not being able to open shared library libasound_module_ctl_pulse, then try using the device parameter, alsamizer -c 0  For more, see the related posts on LinuxQuestions.
Post Installation - TrackPad
Most posts I've read about this are asking how to turn it off, not on!
The instructions that worked for my machine are here.


This has been one of the easier installations I've done. The system starts up quickly, and is responsive. The Xfce interface is clean and adaptable for the smaller screen size.  And, I really like the idea of a rolling release! I think Linux Mint and I will be friends ...

Sunday, 14 August 2011

The zypper Package Manager


Zypper is the package manager used by MeeGo. And now had some time to work with the zypper package manager I can say this is a nice tool. It has good functionality, a consistent interface and is easy to use and well documented. In comparison to apt-get I'd say it is superior. That is a big admission for a long time Debian user! What won me over was when I tried unsuccessfully to upgrade from MeeGo 1.2.0 to 1.2.8, by adding the repositories. Xorg was broken. I tried to fix. But gave up so decided to revert back. I thought this would take a re-installation. But, no! I just removed the offending 1.2.8 repositories and refreshed. Zypper correctly indicated the downgrade. After some network issues, resiliently managed by zypper, I was back and running. Marvellous! So, while I only be using MeeGo on my netbook, I am now comfortable enough in its use and management to use it as an alternative to Ubuntu. The other advantage I see is professionally it is good to understand how alternate systems are supported by RPM or Deb packages.

Working with Packages

MeeGo is RPM based system using the zypper package manager. I've not used an RPM based system in a very long time. So I will have to learn once again how to,

Help

zypper help orzypper help [command]

Listupdates

zypper lu

Update

zypper up

Search for a package

zypper se [package name]

Install a package

zypper in [package name]

Remove a package

zypper rm [package name]

List packages

zypper pa

Show package info

zypper if [package name]

Working with Repositories

This is the one thing that I was concerned with most. In Debian based systems, package sources are easily maintained. Happily, Zypper is just as easy. Maybe even easier as the command interface is consistent with normal package management. MeeGo can be augmented by OpenSuse package repositories. See the examples below for the repositories use to install Skype.

List repositories 

zypper lr

Add a repository

zypper ar [url to repository] [name of repository]

Remove a repository

zypper rr [name of repository]

Enable a repository

zypper mr -e [name of repository]

Disable a repository

zypper mr -d [name of repository]

Refresh repositories

zypper ref –force Source: http://www.freetechie.com/blog/using-opensuse-zypper-for-package-management-adding-removing-repository-management

Example – add keepassx

This is not in the default MeeGo repositories. So lets install from an alternate repository.
zypper ar http://download.opensuse.org/distribution/11.4/repo/oss/ 11.4-OpenSuse-oss

Search for package:

$ zypper se keepassx Loading repository data... Reading installed packages... S | Name | Summary | Type--+----------+---------------------------------+-------- i | keepassx | Cross Platform Password Manager | package

Install package:

$ zypper if keepassx

Get package information:

$ zypper if keepassxLoading repository data...Reading installed packages...Information for package keepassx:
Repository: @System
Name: keepassx
Version: 0.4.3-1.2
Arch: i586
Vendor: obs://build.opensuse.org/openSUSE:11.4:Contrib
Installed: Yes
Status: up-to-date
Installed Size: 2.7 MiB
Summary: Cross Platform Password Manager
Description:
KeePassX is a free/open-source password manager or safe which helps you to manage your passwords in a secure way. You can put all your passwords in one database, which is locked with one master key or a key-disk. So you only have to remember one single master password or insert the key-disk to unlock the whole database. The databases are encrypted using the best and most secure encryption algorithms currently known (AES and Twofish).zypper in KeePassX

Example - add Skype

Include the following repositories,
zypper ar http://download.opensuse.org/distribution/11.4/repo/non-oss/ 11.4-OpenSuse-non-osszypper ar http://download.opensuse.org/distribution/11.4/repo/oss/ 11.4-OpenSuse-oss

Sunday, 7 August 2011

MeeGo

Out with the Slow
I've been running Ubuntu Netbook Remix on my HP Mini 110, from 10.04 then onto Unity with 10.10, 11.04. I really like Unity. It is clean and simple and pretty for a small netbook. However, upgrading from 10.10 to 11.04 saw a distinct performance hit. Start-up was so slow. Once started it was acceptably responsive. You really needed to be patient with the slow start-up, and worse, the even slower login. Those using MS-Windows may not have noticed anything, but seasoned Linux users would. What to do? I shut-down unnecessary services. Still no noticeable improvement. This is using SSD! How can it be so slow? Once logged in the network was available. But that was the only benefit. Time to try something new.
A new chapter
Good device support There are Linux choices for netbooks. You could even run a standard desktop and configure for the small form factor. That is small screen and small keyboard. After some thought, these are my requirements:
  • Minimal setup
  • Optimal use of small screen 
  • Easy upgrade path 
Easy, right? Well, sort of. There were three distributions that looked interesting,
Once I read that MeeGo was hosted by the Linux Foundation I decided to give that a go. You see I'm a member so it's best to support the people you, well, support!
The Meego v1.2 for Netbooks was a heavy weight download at 900MB. But it looked like it had everything I needed out the box. I was also mesmerised by the promise of really fast boot-up and resume times.
The installation was simple and uncomplicated, but I fully expected to have download and install several 100MB more of updates. Not so! But there were problems. The installation notes were spot on in there known issues and workarounds. There other problem: no wireless. A quick google search found an excellent write-up written by Glen Gray here. The steps are,
  1. Activate the MeeGo toolbar and select the applications icon
  2. Choose the Accessories section and select Terminal (or type terminal in the search box)
  3. Install the various tools you will need
    sudo zypper install rpmdevtools
  4. Install the compilers and other toolssudo zypper install pattern:meego-development-tools
  5. Install the kernel-netbook-devel package
    sudo zypper install kernel-devel
  6. Now we’re ready to build and install the new broadcom drivers, my moblin srpm works
    wget http://slaine.org/meego/releases/1.2/ia32/source/wl-kmod-5.100.82.38-1.src.rpm

    (This build will download the broadcom driver archive directly from their site)
    rpmbuild --rebuild --target=i586 wl-kmod-5.100.82.38-1.src.rpm
  7. Install the resulting rpm
    sudo rpm -ivh ~/rpmbuild/RPMS/i586/wl-kmod-5.100.82.38-1.i586.rpm
  8. Loading the modulesudo modprobe -a wl
  9. You should be able to now connect to a network
On restart I was able to connect.
Packages
MeeGo is RPM based system using the zypper package manager. I've not used an RPM based system in a very long time. So I will have to learn once again how to,
Update a system
zypper up
Search for a package
zypper se [package name]
Install a package
zypper in [package name]
And all those other things you do with packages.
Am I Happy?
It will take a little getting used to a new desktop, but so far, yes I am happy with the outcome. It is fast, it was easy to setup and easy to customise. I love the full screen windows. I love the speed. I love the consistent configuration. I will get re-familiar with working with RPM packages. After all, it is good to know how to do things using the two principle Linux package managers. It might even be fun to do a side by side comparison for common package tasks ...

Sunday, 3 July 2011

podracer - a podcast aggregator


Do you listen to podcasts? Do you want to manage these outside of normal web-surfing time? Do you want easy configuration? Then podracer is the software you need.

Podracer was written by Lorenzo Taylor. It is a simple command line tool that has only two plain text configuration files:

$HOME/.podracer/podracer.conf – configure podracer behaviour
$HOME/.podracer/subscriptions – the list of subscriptions

configuration

This file is used to customise podracers download behaviour. With sane defaults, the only settings that I changed were,

poddir – the default root location to save podcasts into

And two other entries indicating where the log files are to be recorded.

subscriptions

Like the name suggests this a plain text file listing the podcasts you subscribe to.
The format is simple:

RSS feed <tab> target directory relative to poddir
As this is a plain text file, where comments can be added by appending “#” to a line, it becomes a useful historical record of podcasts I listen to.

maintenance

To get the most out of podracer, schedule jobs to run during off-peaks times.

# update podcasts (run every day at 03:03) 3 3 * * * podracer

To effortlessly manage podcasts so I don't become overrun with them, I keep only one months worth. This is managed by another crontab entry,

# clean-up old podcasts
@daily find $HOME/music/podcasts/ -name '*.mp3' -type f -mtime +31 -exec rm -v {} \;

Ubuntu 11.04 - an opinion

Family and friends depend on me to provide support for their Linux PC's. What is great is that does not require that much support. But it does mean keeping at least one step ahead. A variety of issues are at stake:


  • Do all applications still work? 
  • Are the devices still supported? 
  • Will the user interface changes be problematic? 
  • Are there new must have features?


So, while most stayed back on stable UNR 10.04 systems, I charged ahead to see if the upgrade path was safe ...


Upgrading from UNR 10.04 to 10.10 introduced the Unity desktop. For the netbook form factor, this desktop is excellent. It uses limited screen space well. It can be run with minimal use of the trackpad. It looks good. It is very responsive. All the applications that are required to work, do. Devices are recognised and work. So all looks good!  But, as 10.10 was not a LTS release I recommended holding back until 11.04 came out.


So I was very eager to see what the next release had in store.


Instead of upgrading though, I decided on a new installation. This was made practical since the netbook records any localisations into the Ubuntu One cloud. So restoration was trivial. The installation was, as we have grown to expect from Canonical, smooth. Everything worked wonderfully. But boot-up and login was very slow! This was a major disappointment. Even after switching off all non-essential services it still is noticeably, irritatingly slow! Slower than either the 10.04 or 10.10 releases. What's more battery life was much shorter.


A netbook must be fast. You don't want to wait for a portable device to start-up. It will sour the experience. There are workarounds. Using hibernate or suspension will assist, but at the cost of even shorter batter life.
The Unity interface has matured and now that I understand the design philosophy, it's functionality and usability make sense. Customisation was easy.


For the casual users currently on UNR, then the move to 11.04 would not be too traumatic.


Overall, I like what Canonical have done with 11.04. But, can I safely recommend it to all? Sadly, no. For UNR users it is a good upgrade, if you have the hardware. For the rest of us on older hardware, there are much lighter weight options.


Canonical's upgrade cycle is starting to hurt. Six months is way to fast, and it seems that years are getting shorter too! So, rolling releases like Linux Mint are starting to look attractive ...

Sunday, 8 May 2011

[Update] Ubuntu Netbook Remix - Tethering to iPhone

Ubuntu 11.04
My previous instructions successfully worked for natty!

Saturday, 2 April 2011

Installing MCE Remote for XBMC

The remote I purchased was a Media Center Remote Control / Receiver, RC118 / IR6065A / QIR606A / Q. This being a MCE certified device I thought it would be easy to set-up. However, it took a little more effort than expected. Fortunately the steps are easy, and it was a useful problem solving exercise. 
System
I am running Ubuntu 10.04 LTS with kernel 2.6.32-31-generic for use as a server for XBMC version 10.1.  I received advice from Jarod Wilson of lirc that,
lirc_mceusb is obsolete. This device is already supported by the in-kernelmceusb driver.
So hopefully you are much luckier than I was in setting this up!
Getting the remote to work
Even though dmesg reported that I had a infrared receiver, lirc failed to recognise it when testing with irw. dmesg reports:
[ 23.721796] generic-usb 0003:147A:E03E.0003: timeout initializing reports
[ 23.722033] generic-usb 0003:
147A:E03E.0003: hiddev97,hidraw2: USB HID v1.00 Device [Formosa21 eHome Infrared Transceiver] on usb-0000:00:1d.2-1/input1
[ 23.722127] usbcore: registered new interface driver usbhid
[ 23.722136] usbhid: v2.6:USB HID core driver
To configure lirc I used the command,
dpkg-reconfigure lirc
Selecting Windows Media Center Transceivers/Remotes (all), and transmitter, none. The default remote device was /dev/lirc0, see /etc/lirc/hardward.conf. But no such device exists! However, checking with lsusb the receiver is being recognised:
# lsusb -v -s 004:002
Bus 004 Device 002: ID
147a:e03e Formosa Industrial Computing, Inc.
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 8
idVendor 0x147a Formosa Industrial Computing, Inc.
idProduct 0xe03e
bcdDevice 10.01
iManufacturer 1
iProduct 2
...
So, why does lirc not recognise it? Are the modules being loaded?
# lsmod | grep lirc
lirc_mceusb 12100 1
lirc_dev8890 3 lirc_mceusb
...
So, yes modules are being loaded. So is the device known by the modules? To answer that question, I have to install lirc-modules-source:
apt-get install lirc-modules-source
Now look in /usr/src/lirc-0.8.6/drivers/lirc_mceusb/lirc_mceusb.c for your receiver,
grep -i formosa /usr/src/lirc-0.8.6/drivers/lirc_mceusb/lirc_mceusb.c
#define VENDOR_FORMOSA
0x147a
/* Formosa eHome Infrared Transceiver */
{ USB_DEVICE(VENDOR_FORMOSA, 0xe015) },
/* Formosa21 / eHome Infrared Receiver */
{ USB_DEVICE(VENDOR_FORMOSA, 0xe016) },
/* Formosa aim / Trust MCE Infrared Receiver */
{ USB_DEVICE(VENDOR_FORMOSA, 0xe017) },
/* Formosa Industrial Computing / Beanbag Emulation Device */
{ USB_DEVICE(VENDOR_FORMOSA, 0xe018) },
/* Formosa21 / eHome Infrared Receiver */
{ USB_DEVICE(VENDOR_FORMOSA, 0xe03a) },
/* Formosa Industrial Computing AIM IR605/A */
{ USB_DEVICE(VENDOR_FORMOSA, 0xe03c) },
So, my receiver isn't listed here! Easy to fix, just add:
/* Formosa21 / eHome Infrared Transceiver */
{ USB_DEVICE(VENDOR_FORMOSA,
0xe03e) },
Next, rebuild modules using,
dpkg-reconfigure lirc-modules-source
Restart lirc:
service lirc restart
This should have recreated the device /dev/lirc0. But it still didn't exist! But using,
# ls -lh /dev/lirc*
lrwxrwxrwx 1 root root 19 2011-03-30 08:57 /dev/lircd -> /var/run/lirc/lircd

/dev/lirc:
total 0
crw-rw---- 1 root root 61, 0 2011-03-30 08:57
0
I saw that there was indeed a device created, just not where I had expected it to be. So, change the entry in /etc/lirc/hardward.conf, from:
REMOTE_DEVICE="/dev/lirc0"
to:
REMOTE_DEVICE="/dev/lirc/0"
Restart lirc:
service lirc restart
And test with irw to check to see if it responds!  Success!
References
XBMC on Acer Aspire Revo R3700
lirc.org
xbmc.org
Mediagate MG-IR01BK and Ubuntu

Friday, 18 March 2011

Xfce no panel

It doesn't happen often (but I'd love to know why), but I lost by Xfce panel again today. Luckily this is easy to fix. Open a terminal (right mouse click) and re-start the panel with:
xfce4-panel &
Now that you have you're panel working make this permanent by removing current session information:
rm -rf ~/.cache/sessions/
Logout and restart your session.
One final hint, backup your Xfce4 settings! I alias the backup command and keep a local and remote copy of the generated archive:
alias backupxfce='cd ~;tar jcvf Backups/xfce4.tar.bz2 .config/xfce4'
This alias will create a bzip2 archive.

Friday, 11 March 2011

XBMC on a ACER Aspire Revo R3700

The following guide is to assist installation of XBMC onto an ACER Aspire Revo R3700 320G/ 2G RAM Mini PC running Ubuntu 10.04. See also my notes on installing MCE remote for XBMC.

Please feel free to suggest corrections or clarifications.

Installation of Ubuntu 10.04
I installed Ubuntu 10.04 from USB. Instructions for this can be found at Ubuntu here.

References

https://help.ubuntu.com/community/Installation/FromUSBStick
http://forum.xbmc.org/showthread.php?t=53812
http://wiki.xbmc.org/index.php?title=Installing_XBMC_for_Linux

Enable SSH

Enable ssh for easy remote management.
  • enable X11 forwarding, in /etc/ssh/sshd_config set,
    X11Forwarding yes
  • enable SSH daemon with,
    update-rc.d
    ssh defaults
  • restart SSH daemon with,
    service ssh restart
  • on the server allow an X client with,
    xhost +[ip_of_client]
To start a session with X enabled,
ssh -X user@192.168.0.6
To copy a file from local to remote host use,
scp local_file user user@192.168.0.6:/home/user/

References

http://www.cyberciti.biz/faq/howto-runlevel-configuration-tool-to-start-service/
http://www.go2linux.org/linux/2011/02/my-top-five-ssh-tips-and-tricks-small-cheatsheet-914

Replace GDM On Startup

I’ll assume that the user name for access to you XMBC box is xmbc.
  • Auto-login xmbc user, edit /etc/init/tty2.conf
    exec /bin/su xmbc -l -c "/bin/bash --login -c /usr/bin/startx > ~xmbc/.tty2.errors 2>&1"

    Where errors are reported into ~xmbc/.tty2.errors
  • Put xmbc startup in users X initialisation, edit ~xmbc/.xinitrc
    exec /usr/bin/ck-launch-session /usr/bin/dbus-launch --exit-with-session /usr/bin/xbmc --standalone -fs > .xinitrc.errors 2>&1

    Where errors are reported into ~xmbc/.xinitrc.errors
  • Ensure user has correct authorities. The following fixes the error,
    X: user not authorized to run the X server, aborting.
    Edit /etc/X11/Xwrapper.config and replace allowed_users=console with
    allowed_users=anybody

  • Remove GDM from startup.
    mv /etc/init/gdm.conf /etc/init/gdm.conf.bak
    update-rc.d -f gdm remove

  • Reboot.
To recover GDM reverse the fourth step. GDM will then start despite errors being logged by xbmc complaining that startx is already active.

References

http://ubuntuforums.org/showthread.php?t=625230

Sound over HDMI

This was by far the trickiest to set up on the Acer. I've used alsa in preference to pulse. I also un-installed pulse just to be sure it wouldn't clash with my alsa settings.
  • For this XBMC installation I've used the custom audio output of plughw:1,7
  • In /etc/asound.conf I added,
    # source: https://bbs.archlinux.org/viewtopic.php?id=100759
    pcm.dmixer {
         type dmix
         ipc_key 2048
         slave {
             pcm "hw:1,7"        # always use pure hw. dmix will resample
             period_size 512     # a reasonable default
             buffer_size 4096
             rate 48000          # HDMI assumes 48kHz
             format S16_LE       # a  reasonable default
         }
         bindings {
             0 0
             1 1
         }
     }
     pcm.!default {
         type plug
         slave.pcm  "dmix:1,7"
     }
  • Open alsamixer and ensure channels are not muted. Muted are keyed as (MM), non-muted are something like, (00).
  • Save the volumes of alsamixer with,
    alsactl store 0
  • To test, aplay -D plughw:1,7 /usr/share/sounds/alsa/Front_Center.wav

References

https://bbs.archlinux.org/viewtopic.php?id=100759
http://guide.ubuntuforums.org/showthread.php?t=1625530&page=2
http://ubuntuforums.org/showthread.php?t=1532355
http://forums.boxee.tv/showthread.php?t=21106

Wireless drops connection periodically

The Revo wireless card raLink rt3090 is known to cause some problems.
  • First check with setup with,
    lshw -C network
    This will show a wealth of wireless information.
  • To see what drivers are actually loaded try,
    lsmod | grep -e rt2 -e rt3
    For this device we only want to see rt3090 and not any of the rt2* drivers.
  • To exclude the rt2* drivers append to /etc/modprobe.d/blacklist.conf the following,
    # cat /etc/modprobe.d/blacklist.conf
    blacklist ndiswrapper
    blacklist rt2800pci
    blacklist rt2860sta
    blacklist acer-wmi
  • <note – the last line must be blank>
  • Next ensure wireless driver is loaded in /etc/modules
    # wireless drivers for Ralink 2860
    rt3090sta
  • To get interface information, use on or all of,
    nm-tool
    lshw -C network
    iwlist scan
  • To check clients to your local network,
    nmap -sP 192.168.0.0/29
  • To restart wireless,
    service network-manger restart

References

http://crunchbanglinux.org/wiki/howto/rt2860sta_wireless

Saturday, 5 February 2011

upgrade - a simple Debian package script

While Ubuntu and variants have a good package upgrade mechanism, I find that this little script can sometimes help when these fail.

echo "Sources:\n"
grep '^deb ' /etc/apt/sources.list
sudo apt-get --fix-missing --list-cleanup update
sudo apt-get dist-upgrade
sudo apt-get -f check
sudo apt-get autoclean
sudo apt-get autoremove
sudo deborphan -Pz
This script has the following dependencies:

deborphan sudo apt
To install, use:

install -p -m 755 -o root upgrade /sbin/upgrade
Occasionally, run this to check for redundant packages:

deborphan --guess-all -Pz
And run this to clean local repository:

apt-get clean
One finally problem may be reported by gnupg about package authentication keys. To fix this, follow this example. I followed the example described here.
I recently updated this script to include the following:

sudo dpkg --configure -a
This is to complete installation of unpacked but unconfigured packages.