Translate

Saturday, 27 January 2018

Raspbery Pi3 (RPI3) as a multimedia server and client, and general purpose PC  

  • DLNA/UPNP server with  local and remote (Internet) clients, DVR client and server, Subsonic server with Android client
  • Use of the Raspberry Pi as a general for web browsing and access to email using Dillo, Kweb, Netsurf, Yahoo! mail and Gmail   


These are some technical notes on:
  • streaming music and video services over a LAN and over the Internet using two Rasperry Pis
  • use of a Pi3 as a general purpose PC  for web browsing and email using Dillo, Netsurf, Kweb and Alpine (including some tips on using this software on the Pi)

These are not comprehensive notes but some tips on what can be time-consuming to set up initially but quite quick to install if a defined process is followed.

Hardware and software
  • RPi3 running 
    • Web browsers
    • Kodi (inc a mythtv client) and mythfrontend 
    • Subsonic server
    • minidlna (DLNA compliant server)
    • bubbleupnpserver available over the Internet
    • email clients 
    • libreoffice
  • Separate (remote on the LAN) RPi3 running:
    • mythbackend and connected to a PCTV USB Freeview tuner
  • Panasonic Viera TX-40DX700B as a DLNA client
  • Google Pixel as an Android client running:
    • Subsonic clients
    • mythtv client (using the excellent mythling app)

Startup
Some basic notes on setting up an RPI3 for multimedia 

Connect a minimum 8GB flash card to another PC.  For Linux users the flash card can be formatted with Gparted. Now mount the flashcard

sudo mount [flash card device]

Download NOOBS onto the flash card. For some reason, I find NOOBS a more reliable way of booting a new Pi than the Raspbian image. Unzip the zip file onto the flash card place into the pi and boot to the Pi. On an 8 Gb card there is not enough room for the full Raspian graphical desktop install so a workaround is to install Raspian lite and then upgrade to a graphical desktop, e.g.:

sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install lxde [if you want lxde]

This takes up less space than the default graphical install.

The first two steps must be carried out otherwise the relevant packages will not be retrieved.  Next some configuration is required in order to make the display look acceptable and make some other useful tweaks:

sudo raspi-config

Some useful settings at this stage (which are well-documented elsewhere):

set the monitor resolution
set an overscan option (if black borders appear around your screen)
change the user password
allocate 256B to GPU memory for smooth HD video playback
set an audio output option (analog headphone socket or HDMI) 

Web browsers 

Standard Web browsers can be extremely slow on the Raspberry Pi. Some recommendations below.

dillo 

sudo apt-get install dillo

A very fast and lightweight browser best for searching and reading web pages which are predominantly text (pages with frames can be almost unusable). No Javascript so many web pages won’t have their full functionality but it can feel like a holiday not to be continually bombarded by adverts.

This browser has an interesting history as it originated with the noble aim of ensuring everyone could access the Internet no matter how basic their connection equipment (e.g. dial-up)

Tip. It is interesting to launch dillo from a terminal window and look in the terminal window at what dillo shows about which sites are trying to receive your browsing history. Example:

Domain: DENIED www.bbc.co.uk  b.scorecardresearch.com

kweb 

A good compromise between speed and functionality. Can be installed as follows (for Stretch):

wget http://steinerdatenbank.de/software/kweb-1.6.9.tar.gz
tar -xzf kweb-1.6.9.tar.gz
cd kweb-1.6.9
./debinstall

Installing from the git repsitory is more complicated because dependencies are not automatically installed

You can comfortably use kweb for a site like blogger which needs Javascript.

Tip. You may find it necessary to install the following additional package:

sudo apt-get install python-tk Tip.

Tip. Install omxplayer (a brilliantly efficient media player) so you can press the Play button in kweb and play media without Javascript or cookies enabled

Tip. Keep Javascript switched off for speed of browsing and Cookies off for privacy. Enable both if required for navigation/page rendering aannd certainly for Internet shopping. Complex sites may however make the Pi run very slowly.m

Tip. Many of us are used to entering searches in the browser address bar. Kweb can do this if the search string is prefixed by ? e.g.:

?how to install kweb

netsurf

Fast, and the page rendering is good but lacks Javascript, apparently not by design but because Javascript support has not yet been implemented.

Feels more like a standard browsing experience than dillo (although not as fast). Tabbed browsing is helpful

Using the Raspberry Pi for e-mail

For a lightweight client Claws Mail is a good choice. Can handle multiple email providers including  Yahoo! and Gmail.

For Web mail, Gmail works well in html view

Yahoo! Mail uses far too much memory in the default view. With Javascript switched on, go into settings and switch the view to Basic. You can subsequently access Yahoo mail without the Javascript and hence without the adverts.

There is a problem using Yahoo! Mail with Netsurf because Yahoo seems to think Netsurf is a mobile phone (and it seems impossible to configure the Netsurf User Agent in order to present Netsurf as another browser to Web sites). Hence you can't seem to get beyond a page promoting the Yahoo! app. A workaround is to display the Inbox in another browser and copy the mailbox URL into a Netsurf bookmark. In Netsurf you then need to log on (with cookies enabled) and then call up the Inbox from the bookmark.

Yahoo! Mail feels clunky in any view on the RPi. If you have multiple email providers a good option is to configure Gmail to use the other provider(s).  Note that the option to do this (Accounts and Import)  is not present in HTML view, you have to switch to standard view. However, once you switch back to HTML view you can see, and use, the imported emails. You can configure Gmail to respond to emails using the recipient's identity (e.g. respond to an incoming Yahoo! email using your Yahoo! email identity) and this works in HTML view. However in HTML view you can't seem to choose which identity to use at the point of replying (that appears to need Javascript).   

Alpine

Alpine is a fast and highly configurable text-based email client. There are a number of guides to setting up alpine with gmail including this one.

If you are using 2-step verification with gmail you need to set up a 16-character password associated with alpine. The command
touch .pine-passfile
in your home directory will cause Alpine to prompt you to save the password.


Alpine address book 

The Alpine address book is typically stored in ~/.addressbook and has a simple tab-delimited format. It is fairly straightforward to convert address books from other email clients into the Alpine address book format.  

Here is an example of such a conversion. If you can export and address book in the LDAP Data Interchange Format (LDIF) (e.g. in Claws-mail), there is a useful shell script you can download to convert an LDIF file to CSV. To use this script, download it, make it executable, "cat" the file and then pipe the output to the shell-script, adding to the shell script name a space-separated list of LDIF fields, e.g.

cat ldif.txt  | ./ldif-to-csv.sh givenName displayName mail > output.csv

where givenName etc. are the LDIF field names. 

To note that inverted commas must be edited out of the LDIF file otherwise the shell script will not work. 

The file can now be opened in Libreoffice calc, edited, and then output as a tab-delimited file (which should be saved in ~/.addressbook.
   


mythtv client


In my experience kodi works better as a mythtv client on the pi I assume because the excellent omxplayer is used (if you set it) to play the video. The mythtv client is good for SD resolution, HD resolution is OK but memory usage has to be minimised as far as possible. kodi playback is detectably better.

I tested this using a short section of recorded video where the mythtv frontend produced a small amount of pixellation with the mythtv frontend but no pixellation with the kodi frontend.    

the mythtv frontend

Instructions here: https://www.mythtv.org/wiki/MythTV_Light

As noted in the instructions, the firmware does need to be updated otherwise the frontend will report missing libraries and will not start. Don't try to skip the firmware update.

Memory dedicated to non-mythtv tasks needs to be minimised. The graphical desktop or windows client makes a big difference, I use dwm which is reported to run on only 1MB of RAM. A standard window manager can be abandoned altogether and just the mythtv frontend run instead. For instance a .desktop file can be created in /usr/share/xsessions such as the following:

[Desktop Entry]
Encoding=UTF-8
Name=myth
Comment=Mythtv frontend
Exec=mythfrontend
Icon=dwm # I retained this icon
Type=XSession

With this file created, an option to use mythfrontend appears in the menu on the password screen of Light Display Manager. So you run mythfrontend instead LXDE, Openbox etc. This is not officially endorsed because there can be problems running external programs from mythfrontend but for functionality internal to mythtv it seems to work fine.

In the video profile screen of mythfrontend, OpenMAX High Quality or openMAX normal must be used. In addition, select the Edit button against the "if" statement governing the selection of a renderer:

if res > [etc]

and make sure that the decoder is openmax.

For sound, use mythtv's internal volume controls and set the mixer as OpenMAX (analog or digital depending on your setup).

It is possible to create a directory of links to mythtv recordings using the Perl script mythlink.pl and run omxplayer from the command line. The script (which works fine with v.0.28 of mythtv and which resides in /usr/share/doc/mythtv-backend/contrib/user_jobs/) should be excutable. It needs an additional Perl module which can be installed as follows:

 sudo cpan install IO::Socket::INET6

The script can be run as simply as:

./mythlink.pl --link [outputdirectory]

The location of the database is automatically detected and the default options make identification of the relevant file straightforward.

kodi as a mythtv client

The performance of kodi as a mythtv client on the Pi is impressive, both the interface and the playback. I think this is the way to go for viewing mythtv content   To install:

sudo apt-get install kodi
sudo apt-get kodi-pvr-mythtv

There is little to configure if the backend is set up correctly. HD playback is crisp and smooth.

The command line may still be useful if you wanted to sequentially play all media in a directory for which the following can be used:

for file in [directory]/*
do
omxplayer $file
done

minidlna
  
Minidlna allows a DLNA-compliant server to be run on the Pi. It is simple to set up and works very well with my Panasonic Viera TX-40DX700B Smart TV as a client.

There is plenty of guidance on the Web. A key setting in the configuration file is:

inotify=yes

which means the database will be updated as soon as any new media is added to the relevant directories.    
 

Subsonic 

Download Java from the Oracle Website. As far as I know there is no way to install the right version of Java using apt-get.

This is a useful site for information about installing Java and setting up Java environment variables:

https://lifehacker.com/how-to-turn-a-raspberry-pi-into-a-private-streaming-mus-1583221462

A deb file can be downloaded from here [relfects the current version at the time of writing]:

http://www.subsonic.org/pages/download2.jsp?target=subsonic-6.1.3.deb

then:

sudo dpkg -i subsonic-6.1.3.deb

Note that, as downloaded, transcoding will not work because Subsonic installs incompatible binaries for ffmpeg and lame  in /var/subsonic/transcode. This has the effect that Subsonic will try to transcode a media file (if the original file is larger than the allowable streamed size) but this will fail and the Android client sticks at "Downloading 0B". Install ffmpeg and lame separately and copy to the Subsonic directory:

sudo apt-get install ffmpeg
sudo apt-get install lame 
sudo cp /usr/bin/ffmpeg /var/subsonic/transcode/ffmpeg 
sudo cp /usr/bin/ffmpeg /var/subsonic/transcode/lame

Subsonic is configured using a Web interface:

http://localhost:4040

I find this is never accessible by default if the Subsonic service is run as a user (rather than root). It appears to be something to do with permissions on the /var/subsonic folder (where the database resides). I find it is possible to get the service running as a user (rather than root) by changing ownership of /var/subsonic to the user. This seems to also require deleting the database in /var/subsonic/db and letting Subsonic recreate it. Due to a lack of documentation it is difficult to know exactly what fixes this but using these techniques I can get the service running as a user.    

bubbleupnpserver

Very useful and flexible server which acts as container for other UPNP servers and provides access to them over a LAN and over the Internet. All DLNA and UPNP server content can be made available including mythtv. Well documented and has extensive configuration options, especially on the mobile client.   

Instructions are here:

https://bubblesoftapps.com/bubbleupnpserver/

To install on the Pi:


wget https://launchpad.net/~bubbleguuum/+archive/bubbleupnpserver/+files/bubbleupnpserver_0.9-5_all.deb

sudo dpkg -i bubbleupnpserver_0.9-5_all.deb

Make sure port 58050 is open as the service is configured using:

http://localhost:58050

I had no problems connecting (unlike Subsonic). 

Connection over the Internet is possible using a dynamic DNS service.

The version of ffmpeg installed using apt-get must be copied to the /usr/share/bubbleupnpserver folder on the server otherwise transcoding will not work.  The default binary will not work on the Pi (same issue as Subsonic). 


It is straightforward to download music and videos at different levels of the folder hierarchy and then play the media offline. So a directory, album, song etc can be downloaded. 

Android clients

mythling

A reliable mythtv client. Provides, on both the local network and the Internet access to:
  • Live TV
  • Recordings
  • Programme guide
  • Videos
  • Music  
In order to access the Mythtv over the Internet you just configure Mythling with your external address, preferably using a static IP service (dynDNS, No-IP etc) if your external address is dynamic and likely to change frequently.    

Sunday, 5 November 2017

Creating a photo slideshow from the Linux command line

This is a quick and fairly straightforward way to create photo slideshows from the Linux command line using a script called dvd-slideshow and a related script called dir2slideshow.

The examples below generate a 720p  slideshow and are based on Ubuntu.

First, install  dvd-slideshow:

apt-get install dvd-slideshow

This will also install dir2slideshow.

The dvd-slideshow script is quite old (it was last updated in 2011) but it still works and is very useful. The script needs to be edited in order to generate an acceptable bit rate for higher definition videos because dvd-slideshow was designed for DVD resolution. 

On Ubuntu, the  dvd-slideshow script is in /usr/bin. To check its location on other distributions you can enter:

which dvd-slideshow

Since we are going to be using  the Flash video format (which works well for these purposes) we need to change the default bit rate for the flv format.

As superuser, open the script in an editor.

sudo gedit /usr/bin/dvd-slideshow

We need to navigate to the following section of code. At the beginning of this section, the script is checking whether the user has requested high quality (in which case the bit rate will be 2000000 bytes per second, or 2 megabits per second) or low quality (in which case the bit rate will be 5000000 bytes per second, or 500 kilobits per second). If neither, the bit rate will default to 1000000, or 1Mbps. All of these are too low for our purposes so we need to add an extra zero to the default bit rate. It should now read: video_bitrate=10000000 which is 10 Mbps (actually higher than Google's recommended bitrate for 720p).          

if [ "$output_format" == 'flv' ] ; then  # FLV
# need to change this to be dynamic (proportinal to size)
# video_bitrate=$(( 6000 * $dvd_width / 480 ))
if [ $high_quality -eq 1 ] ; then
video_bitrate=2000000  # this works ok for 320x240. 
qscale='-qscale 1'
framerate=30;
frames_per_ms=30000;
ppmtoy4m_frc='30:1'  # 30 fps
elif [ $low_quality -eq 1 ] ; then
video_bitrate=500000  # this works ok for 320x240. 
qscale='-qscale 7'
else
video_bitrate=1000000  # this works ok for 320x240. 
qscale='-qscale 5'
framerate='15'  # is this needed for .flv?
frames_per_ms=15000  # in ms
ppmtoy4m_frc='15:1'  # 15 fps
fi


Since we have hard-coded the bitrate for Flash video we need to remember not to request high or low quality when running dvd-slideshow otherwise that will override the default bit rate. 

We can now proceed to create a slideshow. Ensure all the images  for your slideshow are in a single directory, or a directory plus its sub-directories. I am not sure if all images have to be in JPEG format, but mine always are.  The dir2slideshow script allows to you set certain parameters for your slideshow which it will then output to a text file (which acts as an input to dvd-slideshow). There is documentation on Sourceforge about this script or you can  man dir2slideshow. The obvious parameters to set are the location of input and output directories as well as the duration of images and the type/duration of transitions. Here is an example:

dir2slideshow -n TEXT_FILE -c 1 -notitle IMAGE_DIRECTORY

In this example, the script builds TEXT_FILE from the image filenames in IMAGE_DIRECTORY and specifies a crossfade between each image of 1 second. The default image duration is 5 seconds but  a different duration can be specified with the -t switch. I usually avoid a title slide being generated because I design the title slide in Gimp and put it in the image directory. 

Once the TEXT_FILE has been generated it acts as an input to dvd-slideshow.There is documentation on this script on Sourceforge  or, once again, you can  man dvd-slideshow.    
Here is an example of the use of dvd-slideshow:

dvd-slideshow -s 1280x720 -n SLIDESHOW_NAME -f TEXT_FILE -a AUDIO_FILE -V 2 -w -o OUTPUT_DIRECTORY -flv

This means:
Switch and value Meaning
-s 1280x720 Size of the video in pixels (720p)
-n SLIDESHOW_NAME Name of the video file that will be generated
-f TEXT_FILE Text file that was output by the dir2slideshow script
-a AUDIO_FILE Audio file which will provide the soundtrack
-V 2 Verbose output, useful for checking that the script is behaving as expected
-w Widescreen format
-o OUTPUT_DIRECTORY Output directory of the video file
-flv Flash video format

For finer-grained control of the audio format and bit rate the audio file can be muliplexed with the video file using ffmpeg (the subject of a future blog post).


      

Sunday, 29 January 2017

Getting mailto links to work with Google Chrome and DWM

The issue here is that mailto links in Web pages should run up client email software (where installed) when clicked in Google Chrome  under Linux. However this doesn't work unless a desktop environment (like Gnome) is installed.

This blog post provides a workaround for dwm users and was tested under Ubuntu Xenial (6.04.1 LTS). It might cause mailto links to fail under other desktop environments so take a backup of your work as recommended below.

When a mailto link such as nonesuchperson@nonesuchaddress.com is selected, Google Chrome calls a program called xdg-email located in /usr/bin.

xdg-email is a script which checks to see which desktop environment (DE) is being used and then, if possible, runs up a mail compose Window in email client software like Thunderbird. It is called by Google Chrome (but not apparently by Firefox) when a mailto link is clicked. However,  if you are not using a desktop environment, Chrome just runs up an empty browser window.  

The solution I identified was to force xdg-email to think I am using the LXDE environment in which case it correctly runs my email client software (Claws Mail).

First, check to see which email client is associated on your system with a mailto link by running:

xdg-mime query default "x-scheme-handler/mailto" 

By default (and I am not sure why) this command returns the following on my system: 

thunderbird.desktop 

By adding the line

x-scheme-handler/mailto=claws-mail.desktop; 
#or thunderbird.desktop etc

to the file

 ~/.local/share/applications/mimeapps.list 

the xdg-mime command shown above now returns

claws-mail.desktop;

Next, it is necessary to force the /usr/bin/xdg-email script to think we are using the LXDE DE (you have to do this as superuser and it is wise to make a backup copy of the script). The script will then check mimeapps.list to see which email client is being used.

Within the  detect_DE()  function (line 412 in my version) replace all of the following code with just DE=lxde;

    if [ -n "${XDG_CURRENT_DESKTOP}" ]; then
      case "${XDG_CURRENT_DESKTOP}" in
         # only recently added to menu-spec, pre-spec X- still in use
         Cinnamon|X-Cinnamon)
           DE=cinnamon;
           ;;
         ENLIGHTENMENT)
           DE=enlightenment;
           ;;
         # GNOME, GNOME-Classic:GNOME, or GNOME-Flashback:GNOME
         GNOME*)
           DE=gnome;
           ;;
         KDE)
           DE=kde;
           ;;
         LXDE)
           DE=lxde;
           ;;
         MATE)
           DE=mate;
           ;;
         XFCE)
           DE=xfce
           ;;
         X-Generic)
           DE=generic
           ;;
      esac

    fi

Now run xdg-mail in a terminal window which should run up your email client software instead of an empty browser window. 

In my case the revised xdg-mail script also works under the desktop environments such as KDE and LXDE.  However, to note this is a workaround for dwm users so it might cause the script to fail in another DE.

Friday, 2 September 2016

Review of the Panasonic Viera TX-40DX700B

This Panasonic TX-40DX700B is a 4K and HDR 40" TV.
  • I agree with many of the reviews that this TV has an excellent picture both for DVB broadcasts and content received over the Internet such as Amazon video. 4K content, although limited at the moment, looks great
  • Despite being 89.5 cm in width, the arrangement of the legs usefully enables the TV to be placed on a stand which is not so wide. It will actually fit on an 80cm stand (just) although I'd advise a slightly wider stand. To note the legs cannot be moved towards the centre of the 40" TV, unlike the larger models.  
  • The TV worked fine at the outset then it became impossible to access any live broadcasts. Pulling out the plug to reset the TV resolved this. This issue hasn't reoccurred
  • The TV incorporates a DLNA client in order to render content stored on a DLNA server. Bear in mind that the media server must be DLNA-compliant not just UPNP-compliant. DLNA is fussier than UPNP but I find the DLNA client on this TV reasonably flexible in terms of playing media formats (obviously not as flexible as media player like mplayer). However, see below regarding photos 
  • Some observations about DLNA servers
    • For users of the open source DVR Mythtv, the DLNA client on the TV is compatible with v.0.28 of Mythtv. As a DLNA server, mythtv is useful for browsing and showing TV recordings. However if you want to watch videos, they are all grouped into one directory which not very useful if you have them grouped into sub-directories
    •  The TV also works well with minidlna which is good for browsing directories of videos as (unlike mythtv) the directory structure is preserved 
    • The media browser includes a slideshow option for photos. This is surprisingly basic since there are no transitions between the photos (such as crossfade) and the music (if selected) is pretty dire. Only JPEGs are supported and I also found a JPEG edited and exported back to JPEG in Gimp would not display ("File not supported", but a further conversion to JPEG in ImageMagick resolves this issue. kodi, which i have running on a Raspberry pi 2 connected to the TV is much better: you can run music in the background, kodi uses decent transitions and Kodi will play a range of image formats
  • The Apps interface is slick but the selection of apps quite limited compared with an Android TV (judging by the reviews). Personally I prioritised the picture quality and screen size over the Smart TV functionality

Panasonic Viera TX-40DX700B as a DLNA client rendering content from a Mythtv UPNP server

The Panasonic TX-40DX700B is a 40" 4K/HDR LED smart TV  which includes a DLNA client.

This blog describes a configuration which includes the TV as a renderer and a Raspberry Pi 2 running a UPNP/DLNA media server.

Having received the Panasonic TV, the aim was to replace an HTPC sitting under our old TV with something more minimal while retaining the ability to record programmes using Mythtv and stream them to the TV. While this works well, it  is probably a temporary configuration because an HTPC with mythtv's full functionality provides much greater flexibility than a Smart TV with DLNA.

The TV tuner is a PCTV 290e HD USB tuner which is supported in the Linux kernel. This is connected to a Raspberry Pi 2 running a mythtv backend (v.0.28). Raspbian  Jessie is installed on the Pi 2.

Jessie includes mythtv-light which provides the frontend for mythtv. There are instructions here on how to install and configure it. Debian Jessie does not include the packages for the mythtv backend. It is necessary to add a backports repository to /etc/apt/sources.list e.g.:

deb http://ftp.debian.org/debian jessie-backports main

A useful way to sort out the dependencies for the mythtv backend on the Pi2 is to install Synaptic and then install these run-time dependencies (as described here):

mysql-server-5.6 ntp libicu55 libqt5sql5-mysql mysql-client-5.6

I assume that most if not all the other dependencies for the backend must have been installed by the mythtv-light package. I couldn't find libicu55 in backports and libicu52 is running on the backend. I have not yet had any issues using this earlier version of libicu.

The Pi 2 has to be overlocked in raspi-config in order to receive HD television broadcasts via the PCTV tuner otherwise fast-moving video will be pixellated.

In this configuration, TV broadcasts are stored on a remote PC running Gentoo and a Mythtv frontend. Having installed a mythtv backend on the Pi 2, it automatically runs a UPNP server. As noted in the v.028 release notes DLNA compliance is improved in this version of Mythtv.

The Mythtv DLNA server can be accessed via the Devices menu on the Panasonic TX-40DX700B. The Mythtv UPNP server displays the friendly file name and includes menus by channel, recording time etc. A minidlna server is more convenient for videos if you have them arranged in folders because minidlna preserves the folder list whereas Mythtv displays all videos in a single list.

I am not transcoding any of the recordings on Mythtv and it is useful that the Panasonic TV can handle Mythtv's native recording format. Many but not all videos stored in my Mythtv videos directory also played on the TV with navigation including videos in .avi, .mpg and .mp4 format. As expected, not everything was compatible with the TV's DLNA client and some transcoding will be necessary.

For users of Mythtv, my recommendation would (if possible) be to retain the use of the Mythtv frontend rather than to rely entirely on a smart TV. Mythtv accepts a huge range of formats and I find the menus a bit less clunky than the DLNA interface. However there is additional cost involved in having two video renderers feeding the same display device. The costs could be kept to a minimum by using a single board computer for the frontend, perhaps dedicated to it. In my experience, the Pi isn't powerful enough to run a frontend and backend at the same time although it does an amazing job of running the backend which I can access and configure remotely. It is also possible to standard definition  live TV on the remote frontend, HD is a bit laggy using this configuration. I have yet to try the Pi 3but this is an obvious candidate for a  mythtv frontend or backend.

Saturday, 23 April 2016

HP Envy 7640 printer under Linux: review and tips

This printer works well under Linux.

I found that the HP Linux Imaging and Printing (HPLIP) didn't find the printer automatically but with an Ethernet connection it was only necessary to tell HPLIP the internet address. The printer/scanner was then ready to use.

The printer requires a properly configured Ethernet connection if you are using a wired network setup. Otherwise the printer might not wake up from sleep mode even if you press the front panel to activate it. For some reason I found that a connection through a switch to a router caused this issue but a direct connection to the router was fine.

Xsane works well, in addition to flatbed scanning you can carry out multipage scanning using the document feeder.

There is a useful, configurable HP Web interface to the printer with options to scan, configure settings, view usage statistics etc. Sometimes, but not always, I find that accessing the Web interface causes the HPLIP interface to freeze, and you have to close down the Web interface to access the HPLIP interface again. I also found that Firefox displayed blank PDF pages after scanning via the Web interface. A message is displayed: "This PDF document might not be displayed correctly". Clicking on the Firefox button  Open with a different viewer and then choosing Evince resolved this for me.

Certain actions like aligning the printer and cleaning the cartridges can't apparently be carried out by using HPLIP or the Web interface, you have to
use the front panel of the printer.





        

Sunday, 13 March 2016

Amazon video under Linux

Amazon video now works great under Linux. Once Amazon had rolled out an HMTL5 player it was no longer necessary to spend time on workarounds because there was no Linux version of Silverlight. Of course Google Chrome is a necessity, other browsers can't be used.

There seems to be a compatibility issue with running the Amazon player under Gnome 3, a distracting white border appears down the right hand side of the screen and along the bottom. Using a window manager (like the excellent Openbox) solves this.

Another quirk is that the mouse pointer doesn't disappear automatically when using a window manager. Right clicking solves this although you have to wait for the player overlay ("Options", volume control etc.) to fade out.  

Sunday, 17 January 2016

Automount a USB media player in Linux

It is useful to be able to automount USB file systems when the USB device is plugged into your computer.

This is an example of automounting an mp3 player (Creative Zen xfi) running Rockbox in a Gentoo system.

I did this in 2 stages.

Since the device name of the mp3 player will vary (could be /dev/sdd1 /dev/sdf1 etc.) the first stage is to ensure the device name is always the same. This is a useful site with good examples of how to do this.  I created a file as shown on this site called /etc/udev/rules.d/65-stick.rules containing:

# # Rockbox device
KERNEL=="sd*", SUBSYSTEMS=="usb", ENV{ID_VENDOR}=="Rockbox", \ ENV{ID_SERIAL}=="Rockbox_Internal_Storage*", SYMLINK+="zen%n", GOTO="stick_end"
LABEL="stick_end"

This rule uses unique information about the device which you can gather through a couple of commands. First, dmesg, which in this case allows you to identify the device name. Here is an extract from the dmesg output:

[1203747.956962] usb 4-1: New USB device found, idVendor=041e, idProduct=4162
[1203747.956965] usb 4-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[1203747.956967] usb 4-1: Product: Rockbox media player
[1203747.956969] usb 4-1: Manufacturer: Rockbox.org
[...]
[1203748.988809] sd 243:0:0:1: [sdf] 31291392 512-byte logical blocks: (16.0 GB/14.9 GiB)
[1203748.992059] sd 243:0:0:0: [sdb] Write Protect is off
[1203748.992064] sd 243:0:0:0: [sdb] Mode Sense: 0b 00 00 08
[1203748.994794] sd 243:0:0:1: [sdf] Write Protect is off
[...]
[1203749.040790]  sdb: sdb1
[1203749.047790]  sdf: sdf1
[1203749.088771] sd 243:0:0:0: [sdb] Attached SCSI removable disk
[1203749.091768] sd 243:0:0:1: [sdf] Attached SCSI removable disk

From this I can tell that the device's internal drive is /dev/sdb1 and that the SD memory card in the device's memory slot is /dev/sdf1.

The command udevadm info /dev/sdb1 shows some further information about the device including the following lines: 


The ID_SERIAL and ID_VENDOR values are now used to uniquely identify the device in the udev rule shown above. 

The udev rule ensures that symoblic links is created for the Creative Zen device. The device names are always  zen and zen1.

The following command ensures that any new udev dule is active:

udevadm control --reload-rules

Now to autofs for which I found this Gentoo wiki page the most useful. I emerged autofs and then ensured it was enabled and started in systemd:

systemctl enable autofs.service
systemctl start autofs.service

Next I edited the /etc/autofs/auto.master file to include:

/media   /etc/autofs/auto.misc    --timeout=15 --ghost 

This means that the mount instructions in auto.misc will mean that the filesystem is mounted under /media.

My /etc/auto.misc has the following line:

zen          -fstype=vfat,rw,uid=1000,gid=100          :/dev/zen1

 This means that a mountpoint /media/zen will be created for the device /dev/zen1 and that the filesystem is writeable by the user. 

Monday, 11 January 2016

Musescore 2.0 on Gentoo

Good to find out today that the development version of version 2.0 of Musescore compiles successfully on Gentoo using the instructions on this page.

I need to keep Qt4 on my system as it is quite old so I installed Qt5 into my home directory and set the path for Qt as described in the compile instructions. The nightly build I used from Git was 10 January. I followed the instructions to build a binary called mscore-self.

So far the new version has run without any issues and the new default soundfont is great, it transforms the playback of scores.    

Sunday, 3 January 2016

Building the Polyphone soundfont editor on a Gentoo system

Polyphone is very useful soundfont editor. Version 1.7 compiled without any issues on my Gentoo system once I had edited the polyphone.pro file (one of the source files) and uncommented these lines (taking the initial hash out):

#DEFINES += USE_LOCAL_RTMIDI
#DEFINES += USE_LOCAL_STK
#DEFINES += USE_LOCAL_QCUSTOMPLOT

This stops qmake trying to find the relevant files in your main Gentoo library directories. As it says in the polyphone.pro file:

# Uncomment a line if your distribution doesn't come with some of the following libraries

It is possible to emerge rtmidi (one of the dependencies) from the Gentoo lorelei overlay but Polyphone's installation script still won't find it.

Using the process described here, you end up with a Polyphone binary which works fine.

The version of GCC used was i686-pc-linux-gnu-4.9.3.

Thursday, 15 October 2015

Brief review of linux mail clients for a lightweight desktop environment

Opera mail

I have found this an excellent mail client (v.12.16). It's fast and the integration with the Web browser is brilliant. It wasn't until I started investigating other Linux email clients that I realised how convenient it is for Web pages accessed through HTML emails to display on a new tab in the same browser. Other email clients with the exception of Claws-mail open  Web pages in a separate browser window. Same sentiment expressed this forum post.

Opera scrolls through my  inbox of over 12,000 emails very smoothly. This client is really the benchmark by which I measure others mail. Perhaps the main drawback of Opera mail in my version is the lack of filters i.e. processing emails into    

Disappointing to learn (a) that the email client is now standalone and even more that (b) there is currently no Linux version of Opera mail.    

Evolution

Seems sluggish in use especially when downloading HTML emails. So difficult to recommend for a lightweight desktop environment. However, integration with Google for mail, calendaring and contacts is excellent. Important to remember to set google account options in gnome-online-accounts not from within Evolution (which was the old way).

Claws mail

Superfast, outperforming Opera mail in terms of speed. This is the program I chose to use following the demise of Opera.

Powerful configuration options and processing tools. Ability to create emails in external editors like vi (if that floats your boat) is a nice feature.

Web pages can be viewed in the same pane as the message by selecting a link although I have not yet found a way to get this to work consistently, sometimes a right click seems to be required.       

Sunday, 4 January 2015

Installing the latest version of Compiz for tear-free Flash playback in Gentoo Linux

The aim here is video playback without screen tearing in Linux, a common issue with  Adobe Flash. If you have this issue with Flash videos embedded in browsers, the effect can be seen clearly in this Youtube video.

Ubuntu users have reported (e.g. in this forum post) that the issue can be resolved by running Compiz as your window manager with its Sync to VBlank  setting enabled. I tested this on Ubuntu and Gentoo and the results were markedly better in Ubuntu. The reason appears to be that Ubuntu is running the latest release of Compiz  (0.9.10.2) whereas the version available through portage is 0.8.8 (described as "the latest stable release" on compiz.org). There are more display setting options in the later version and, possibly because of this, it works better with Flash videos.

It's important to note that the procedure described here shouldn't be followed if it's critical you don't break your system. I use my Gentoo installation as a sandbox as well as a working tool, a way of keeping up to date with, and learning new, Linux skills. Hence it's not critical if something breaks. This being said, I have ended up with a useful and fully-functioning Compiz desktop under Gentoo.

To install the latest release of compiz you have to remove all Compiz components if they have been installed through Portage. In my case:

*  dev-python/compizconfig-python
*  x11-libs/compiz-bcop
*  x11-libs/compizconfig-backend-gconf
*  x11-libs/compizconfig-backend-kconfig4
*  x11-libs/libcompizconfig
*  x11-plugins/compiz-plugins-extra
*  x11-plugins/compiz-plugins-main
*  x11-plugins/compiz-plugins-unsupported
*  x11-wm/compiz
*  x11-wm/compiz-fusion
*  x11-apps/ccsm
*  x11-apps/simple-ccsm

Note that simple-ccsm (simple Compiz Configuration Settings Manager) is not currently available for the latest version of Compiz.

Fortunately,  all the sources for Compiz have now been merged into one repository, which makes configuration, compilation and installation much easier.

Obtaining the latest source code is straightforward as described here:

bzr branch lp:compiz

This creates a compiz directory in the location where you have entered this command. Now:

mkdir build

and

cd build

Next is the configuration stage. You need to run cmake with flags indicating the location of the installation and the options and plugins to install. Currently on Gentoo the 0.9.10.2 default compile configuration won't work  because of a missing header file kdecorationbridge.h. I worked around this by disabling the KDE window decorator option:

-DUSE_KDE4=false

You also have to nominate a location for the installation which by default will otherwise be /usr/local. I installed in the standard location to avoid having to set additional library paths:

-DCMAKE_INSTALL_PREFIX=/usr

Hence in the build directory the full configuration command was:

cmake -DUSE_KDE4=false -DCMAKE_INSTALL_PREFIX=/usr ..

I found with the subsequent make install command the code compiled without a hitch on Gentoo.

A useful initial way of testing if the compiz command is running is:

compiz --version

which should give the output:

compiz 0.9.12.0

Next you need a working desktop running Compiz. I decided to make this as lightweight as possible by running Compiz alongside the excellent fbpanel (which can be emerged through Portage for this purpose). In the directory /etc/X11/Sessions on Gentoo I have a compiz file containing:

#!/bin/sh
xsetbg /home/my_name/.fluxbox/backgrounds/sid_fluxbox.jpg
setxkbmap gb
fbpanel &
exec /usr/bin/compiz ccp 
 

This sets a background, the keyboard to British, runs the Fluxbox panel in the background and then calls compiz. Note that, contrary to the guidance in this Archlinux wiki the ccp switch is still necessary otherwise settings in  ccsm appear to have no effect.

Next, to create a user-selectable desktop option in a graphical login manager (I use lightdm) I have the following compiz-session.desktop file in /usr/share/xsessions:

[Desktop Entry]
Encoding=UTF-8
Name=Compiz 

Comment=dynamic window manager
Exec=/etc/X11/Sessions/compiz
TryExec=/usr/bin/compiz ccp
Icon=
Type=Application


I achieved good results in Adobe flash with the following configuration:

  • the nouveau video driver (the proprietary Nvidia driver still caused screen tearing)
  • the following options:
    • In cssm General => OpenGL => Sync to VBlank
    • In /etc/X11/xorg.conf:
      •  Option "GLXVBlank" "True" #as described here


This setup produced significantly better results in Flash videos (including the the test Youtube video) than the same videos run under a different window manager.

Tip: following recent development work on the nouveau driver, Nvidia cards can be re-clocked to some degree. Add nouveau.pstate=1 to your kernel line in Grub. In my case I then use the command:

cat /sys/class/drm/card0/device/pstate

which results in the output:

20: core 350 MHz shader 350 MHz memory 532 MHz
--: core 200 MHz shader 0 MHz memory 401 MHz *


To re-clock based on this output, in root:

echo 20 > /sys/class/drm/card0/device/pstate

resulting in:

20: core 350 MHz shader 350 MHz memory 532 MHz *
--: core 351 MHz shader 0 MHz memory 532 MHz
 

Tuesday, 25 February 2014

How to play audio from a smarthone through a PC running Linux

Last tested on bluez 5.15 

A few notes on how to setting up an audio connection between a smartphone and a PC running Linux. Skifta is useful just for mp3's but I need to run iReal jazz backing tracks through my PC's speaker system for keyboard improvisation practice for which bluetooth is required.

I am using Gentoo but these notes should be applicable to other distributions.

The key software to install is bluez version 5 and Pulseaudio (the latest at the time of writing is 4.99.4). Pavucontrol (Pulseaudio volume control should also be installed).  Kernel options to enable are described here.

Hardware I am using is the Atheros Communications AR3011 bluetooth dongle (badged as Trust and bought from Ebuyer). The phone is HTC One V.

Blueman currently doesn't work with bluez 5 so is no use for this purpose. Bluedevil (a KDE dongle) does work. I haven't tested Bluetooth using the Gnome control center.

In my experience it is much easier to use the bluetoothctl interactive command line utility than it is to use GUI programs like Blueman and Bluedevil. If the connection fails the GUI programs don't give very helpful output. Connection attempts may appear to "hang" and it's not clear why. The Arch wiki is a useful guide to bluetoothctl but there doesn't seem to be a great deal of documentation available apart from this.

The bluetooth daemon (service) has to be running either through /etc/init.d/bluetooth start or through systemd (where the command is systemctl start bluetooth).

There are some forum posts about configuration of /etc/bluetooth/audio.conf, for instance whether Disable=Socket is necessary. Unless specific bluetooth services are to be disabled, none of these service should be specifically enabled or disabled. Every service that is implemented on your system with then be available. 

There are two main stages to the bluetooth audio setup: pairing and connecting.

Bluetooth obviously must be enabled on the phone, discoverable to all nearby devices and within range of the dongle.

Enter bluetoothctl which will give you the bluetoothctl command line:

[bluetooth]#

Subsequent commands below are all within the bluetoothctl utility.

Power on the controller. if you don't do this, neither the controller (dongle) or the phone may be picked up:

[bluetooth]#power on

Make the dongle discoverable: 

[bluetooth]# discoverable on
 
Another useful command if the phone isn't showing (e.g. when you enter the devices command) is: 

[bluetooth]# scan on

Use the devices command to check what devices have been picked up. This should return  a MAC (hardware) address which looks like this: 

[bluetooth]# Device E6:48:C2:AB:91:32 my_smartphone

Use the info command to check what bluetooth services are available, e.g.

[bluetooth]# info E6:48:C2:AB:91:32 

Before trying to pair the dongle and the smartphone make sure you register the agent:

 [bluetooth]# agent on

There are other options for this command, but this is sufficient to ensure the dongle and smartphone are ready to be paired. If this command isn't used, a pairing  prompt appears on the phone but without a passkey. Although this prompt can be accepted, the phone and teh dongle won't be paired. 

Use show command  to check the controller is pairable and likewise the device command for the phone. If both are shown as pairable, enter the pair command with the phone's MAC address e.g.:

[bluetooth]# pair E6:48:C2:AB:91:32

You are returned to the bluetoothctl prompt. Wait until bluetoothctl confirms the pairing is successful. 

Now run up pavucontrol (pulseaudio volume control). Select the "Playback" tab and then  select "All streams" from the picklist at the bottom of the screen. pavucontrol helps you monitor whether a successful audio connection has been made using the A2DP protocol. 

Next try to connect the phone to the dongle, e.g.

[bluetooth]# connect E6:48:C2:AB:91:32

bluetoothctl should indicate if the connection is successful. If so you should also see the phone shown as a "loopback" device in pavucontrol.

At this point, I sometimes find that the phone appears to be connected as an audio source but there is no sound. The only workaround for this issue appears to be to using the bluetoothctl disconnect command followed by connect.