Translate

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.

Saturday, 22 June 2013

Streaming mp4 videos from an Android device to gmediarender on a UPNP-enabled remote device

gmediarender is a resource efficient UPNP-compatible media renderer suitable for lower specification devices such as the Raspberry pi.

Skifta can be used as both media server and control point (i.e. the remote) but in my experience mp4 files can't be streamed from the Skifta server on the phone (HTC One V in this case) to gmediarender. This results is an error "media unable to perform play".

One solution is to use BubbleUPnP as the control point with the setting Mime-type check unchecked (this setting can be found under "UPNP tweaks"). Within BubbleUPnP on the Android device either Skifta or BubbleUPnP  can be used as the media server.  

Another app which works well with gmediarender is MediaHouse which plays back mp4s without any need to configure the app.   

The UPnP Play app seems to have the same issue with mp4's being streamed to gmediarender, it returns "unsupported format video/mp4"