Linux Mint 15 CodeLite Unit Tests

When I created my first Unit Test in CodeLite it would not compile because UnitTest++.h was not available.

I loaded libunittest with:

sudo apt-get install libunittest++-dev


Then added /usr/include/unittest++ to the CodeLite compiler includes by opening the Build Settings dialog which is on the Settings menu.


printf format strings

I copied this excellent quick reference guide from Pádraig Brady at PixelBeat lest it should go offline at some point in the future.


%[flags][min field width][precision][length]conversion specifier
  -----  ---------------  ---------  ------ -------------------
   \             #,*        .#, .*     /             \
    \                                 /               \
   #,0,-,+, ,',I                 hh,h,l,ll,j,z,L    c,d,u,x,X,e,f,g,s,p,%
   -------------                 ---------------    -----------------------
   # | Alternate,                 hh | char,           c | unsigned char,
   0 | zero pad,                   h | short,          d | signed int,
   - | left align,                 l | long,           u | unsigned int,
   + | explicit + - sign,         ll | long long,      x | unsigned hex int,
     | space for + sign,           j | [u]intmax_t,    X | unsigned HEX int,
   ' | locale thousands grouping,  z | size_t,         e | [-]d.ddde±dd double,
   I | Use locale's alt digits     t | ptrdiff_t,      E | [-]d.dddE±dd double,
                                   L | long double,  ---------=====
   if no precision   => 6 decimal places            /  f | [-]d.ddd double,
   if precision = 0  => 0 decimal places      _____/   g | e|f as appropriate,
   if precision = #  => # decimal places               G | E|F as appropriate,
   if flag = #       => always show decimal point      s | string,
                                             ..............------
                                            /          p | pointer,
   if precision      => max field width    /           % | %

Linux Mint 15 Codelite C++11 gcc 4.7.3

I'm experimenting with C++11 using CodeLite 5.1 and gcc 4.7.3

The support for C+11 is experimental and has to be turned on with a compiler switch. This page describes the alternatives.

I used -std=c++11


which I set in the Project Settings dialog. Common Settings / Compiler / C++ Compiler Options, like this:


I also made the compiler switch available to all build configurations by adding to the Build Settings dialog which is on the Settings option of the main menu:

Linux Mint 15 Launch Browser with Function Key

On my Compaq 6820s (UK keyboard) the F3 key should have launched the default web browser but didn't.

I used the Keyboard Shortcuts app to redefine the key used to launch the browser:

Linux Mint 15 Suspend when power button is pressed

I wanted my Compaq 6820s to Suspend when the power button was pressed. Using the Power Management application I set the General tab options like this:


But the results were unreliable, something along the lines of:
Press Power -> Laptop Suspends
Press Power -> Laptop Resumes, briefly, then Shuts Down
Press Power -> Laptop boots

I looked at the /etc/acpi/powerbtn.sh

I don't know how this script works but the last two lines caught my eye:

# If all else failed, just initiate a plain shutdown.
/sbin/shutdown -h now "Power button pressed"


Which makes it quite difficult to catch problems. So I commented out the last line:

sudo pluma /etc/acpi/powerbtn.sh

# If all else failed, just initiate a plain shutdown.
#/sbin/shutdown -h now "Power button pressed"


And that was sufficient to give me the result I was looking for. Now the power button consistently follows the actions in the Power Management settings.

Linux Mint 15 Suspend when laptop lid is closed

I tried to use Power Management to set my laptop to Suspend when the lid is closed but instead it simply blanked the screen.

I found a workaround here, thanks to Unrealist.

In the file /etc/acpi/lid.sh comment out this line . /usr/share/acpi-support/screenblank something like this:


sudo pluma /etc/acpi/lid.sh

if [ $? = 0 ]
then
    for x in /tmp/.X11-unix/*; do
 displaynum=`echo $x | sed s#/tmp/.X11-unix/X##`
 getXuser;
 if [ x"$XAUTHORITY" != x"" ]; then
     export DISPLAY=":$displaynum"     
     #. /usr/share/acpi-support/screenblank
 fi
    done


Recompiling Xorg Radeon on Mint 15

As part of my efforts to get my Compaq 6820 ATI Radeon Rv516 video to run at full resolution of 1440x900 I attempted to recompile the Xorg Radeon driver. Ultimately this proved to be a dead end but this blog entry records the useful tidbits I learned along the way. (The working solution is here.)


I'm following the instructions at X.org to recompile Radeon.


apt-get build-dep xserver-xorg-video-ati


fails with:

E: You must put some 'source' URIs in your sources.list


In Mint 15 the new Software Sources screen makes updating the 'sources.list' simple by checking the "Enable source code repositories" checkbox.



The Python script used by the Software Sources screen can be found here:

/usr/lib/linuxmint/mintSources/mintSources.py


The mintSources.py script updates

/etc/apt/sources.list.d/official-source-repositories.list
and a quick 'cat' reveals the source URIs:

cat /etc/apt/sources.list.d/official-source-repositories.list
deb-src http://packages.linuxmint.com/ olivia main upstream import 

deb-src http://archive.ubuntu.com/ubuntu/ raring main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ raring-updates main restricted universe multiverse

deb-src http://security.ubuntu.com/ubuntu/ raring-security main restricted universe multiverse
deb-src http://archive.canonical.com/ubuntu/ raring partner


Back to the x.org instructions:

./autogen.sh --prefix=/opt/xorg


which failed because libdrm was out of date, it required version 2.4.44.

checking for LIBDRM... no
configure: error: Package requirements (libdrm >= 2.4.44) were not met:

Requested 'libdrm >= 2.4.44' but version of libdrm is 2.4.43

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables LIBDRM_CFLAGS
and LIBDRM_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.


I tracked down libdrm.pc using:

find / -name "libdrm.pc"


and manually changed the version number using:

pluma /usr/local/lib/pkgconfig/libdrm.pc


That seemed unlikely to work but it was sufficient to get past ./autogen.sh

However the subsequent "make" command then failed because of a new flag that was used introduced in libdrm 2.4.44:

surface->flags |= RADEON_SURF_HAS_TILE_MODE_INDEX;


So next I downloaded the 2.4.44 source for libdrm:

http://dri.freedesktop.org/libdrm/libdrm-2.4.44.tar.bz2


And following its README that compiled first time.

Back to the x.org instructions and now "make" and "make install" are successful.

But the resolution is still showing only 1152x864.

Running inxi -G reports:

Graphics:  Card: Advanced Micro Devices [AMD] nee ATI RV516/M62-S [Mobility Radeon X1350] 
           X.Org: 1.13.3 drivers: ati,vesa,radeon (unloaded: fbdev) FAILED: fglrx Resolution: 1152x864@60.0hz 
           GLX Renderer: Gallium 0.4 on llvmpipe (LLVM 3.2, 128 bits) GLX Version: 1.4 (2.1 Mesa 9.1.1)


Linux Mint (Mate) Restarting X Server

Making an error in xorg.conf invariably leaves me at the command prompt. To reset xorg.conf and get the X server working again I login and run:

su
service mdm stop
X -configure
cp /root/xorg.conf.new /etc/X11/xorg.conf
service mdm start

Linux Mint System Info

To get the details of the video graphics use:

inxi -G

and for full system info use:

inxi -F

Linux Mint 15 XORG Compaq 6820s ATI Radeon Rv516

I've spent a lot of time trying to get the video to run at its native resolution of 1440x900 and failed miserably finally succeeded.

Step 1
Change grub to use NOMODESET as described in Installing Mint 14 or Mint 15 Compaq 6820s

Step 2
Add these lines to /etc/init.d/rc.local
modprobe -r radeon
modprobe -r drm
modprobe radeon modeset=1

To give something like this:

#! /bin/sh
### BEGIN INIT INFO
# Provides:          rc.local
# Required-Start:    $remote_fs $syslog $all
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:
# Short-Description: Run /etc/rc.local if it exist
### END INIT INFO

modprobe -r radeon
modprobe -r drm
modprobe radeon modeset=1


Step 3
Reboot



Credits
I got the solution from this Redhat kernel thread, specifically Comment #104 so thanks to Lyonel Vincent.

Linux Mint get release version code name

The code name is used in some of the Python scripts to access version specific directories. They use this command:

lsb_release -sc

Linux Mint updating an Environment Variable

To list all the environment variables:

env


To extend the contents of an existing one:

export PKG_CONFIG_PATH=/usr/lib/pkgconfig:$PKG_CONFIG_PATH

Linux Mint Find command

JJ helped me to track down libdrm with:

sudo find / -name "*libdrm*"

Or starting in a more specific directory:

sudo find ./Documents -name "*libdrm*"

Or starting in the current directory:

sudo find -name "*libdrm*"

And no need for wildcards if you know the file name:

sudo find / -name "libdrm.pc"

grep and or case insensitive file contents

A reminder of the common ways I use grep

Case insensitive
grep -i

OR
grep "pattern1\|pattern2\|pattern3"

AND
grep "pattern1" | grep "pattern2"

NOT
grep -v "pattern"

Within Files
grep "pattern" filename

For example:
grep "pattern" *.htm
grep "pattern" *.c

Pluma recently-used.xbel

At launch and shutdown Pluma throws a couple of instances of the following error when used with sudo to edit 'root' files:

Gtk-WARNING **: Attempting to set the permissions of `/root/.local/share/recently-used.xbel',
 but failed: No such file or directory


A quick use of mkdir fixes it:

sudo mkdir /root/.local/
sudo mkdir /root/.local/share

Installing Mint 14 or Mint 15 Compaq 6820s

The Mint 14/15 LiveCD worked fine on my old Compaq 6820s but after installation Mint would hang with a black screen during the boot process. After much rebooting and editing the grub config (hold down shift key during BIOS POST process to display the Grub menu) I found the solution that apparently everyone knows. Until I knew the answer I didn't know the correct question to pose to Google.

For some reason the Radeon video card doesn't like the graphical splash screen and has to be turned off with "nomodeset" command-line option, something like this:


sudo pluma /etc/default/grub

Change this line:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nomodeset"

And apply the change with:

sudo update-grub

Manually installing Debian packages

SolydKX doesn't automatically install downloaded packages in the same way Mint does, so I did it manually:

sudo dpkg -i packagename.deb

Hello World written in C on Mint

I have no immediate plans to write C code but I bumped into "Hello World" and thought I try it to prove that gcc was installed and working.

Create the helloworld.c source in Documents:

#include <stdio.h>
int main (void)
{
  printf("Hello World!\n");
  return 0;
}


Compile it with:

gcc helloworld.c -o helloworld


And run it with:

./helloworld



Windows Delete all print jobs

For when the spooler gets stuck in the "Deleting ..." print job state.

net stop spooler
del %systemroot%\system32\spool\printers\*.shd
del %systemroot%\system32\spool\printers\*.spl
net start spooler


I've also added those commands to my desktop as DeletePrintJobs.cmd

The instructions were taken from Microsoft Support

Banshee Remote

Congratulations and thanks to Nikitas Stamatopoulos and Kristopher Dick for creating the excellent Banshee Remote. Not perfect (it hangs from time to time) but gives me the remote control of Banshee from my Android phone that I wanted.

The installation instructions here are simple to follow and it worked first time.

Some reminders for me:
su
cd /usr/lib/banshee/Extensions
cp ~/../home/mhs/Downloads/BansheeRemoteListener.dll .

Connecting Banshee to Samba Server

Banshee is running on the Mint media player PC and needs to access the music files on the Ubuntu-based server running Samba.
Create a folder on the Mint box /mnt/remote
Mount the remote file system
Point Banshee at /mnt/remote

mkdir /mnt/remote
sudo mount.cifs //Lounge/mhs /mnt/remote -o user=username%password rw noperm

I then added the following to /etc/fstab to mount the remote file system during boot:
#Mount the Samba share for the music on the //Lounge server
//Lounge/mhs /mnt/remote cifs username=username,password=password 0 0

Restarting ssh server

After making changes to the ssh configuration, restart the OpenSSH Server service:


/etc/init.d/ssh restart

Enabling ssh in Mint

LinuxMint by default does not enable SSH server.


apt-get install openssh-server

Samba smbclient

To list the shares on a Windows server from Ubuntu and Raspbmc:

smbclient -L //windowsservername -U domain/username%password

To connect to a shared folder on the Windows server

smbclient //windowsservername/sharename -U domain/username%password

Finding Network Devices

To find all the devices on my home network I used arp-scan from Mint/Ubuntu Terminal.

sudo apt-get install arp-scan

sudo arp-scan --interface=wlan1 --localnet

Where wlan1 is the name of the network interface which can be found with:

ifconfig


Posting code snippets

This is the simple markup I use for posting code snippets on this blog.



<pre style="font-family: Courier New, Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; ">
<code>

content here

</code>
</pre>

Launching Banshee

When my Mint-based media player logs on I want Banshee to launch and start playing. For some reason the --play command line option doesn't work when Banshee starts up. So I wrote this script to launch Banshee and then issue the "play" command.
#!/bin/bash

##############################################
# Launch Banshee
##############################################

banshee &

##############################################
# Wait until Banshee appears in the
# list of running processes
##############################################

let watchdogcount=30

while :
do
 ps -A | grep -w "banshee"
 if [ $? == 0 ]
 then
  break
 fi
 echo "sleeping"
 sleep 1

 # Ensure that the script doesn't loop forever
 ((watchdogcount--))
 if [ $watchdogcount == 0 ]
 then
  echo "timeout"
  exit
 fi
done

##############################################
# Issue "play" command until Banshee's
# state is "playing"
##############################################

while :
do
 echo "checking state"
 banshee --query-current-state | grep -w "playing"
 if [ $? == 0 ]
 then
  break
 fi
 banshee --play
 sleep 1
 echo "sleeping"
done

I saved the script in my Documents folder as "banshee_play", made it executable then added it as one of my Startup Applications...

Open in Terminal

This post gave me a handy tip that has made navigating with Terminal much nicer.


sudo apt-get install nautilus-open-terminal


adds a context menu item to open a new terminal window in the selected folder.

Appears to already be in Mint 14 (Mate).

Mint / Ubuntu Wireless Adapter

Found this excellent post that solved all my "no-name" wireless adapter installation woes.

I used the v3.4.4 (2012/11/12) driver on Mint 14.

I got one error during installation:
ERROR: Module 8192cu does not exist in /proc/modules

and changed Step 5 to use pluma instead of gedit

sudo pluma /etc/modprobe.d/blacklist.conf


In case the original post ever disappears here are the essential bits:

Download the Realtek RTL8191SU drivers from here

Navigate to the downloaded folder and install the drivers with:

sudo bash install.sh

Blacklist the original drivers with:

sudo pluma /etc/modprobe.d/blacklist.conf

Go to the end of the file and add the line: blacklist rtl8192cu

Reboot