Tuesday, December 25, 2012

Wireless Mouse Too Sensitive in Linux Desktop (Cinnamon)

One reason I love (with tears in my eyes) Linux is how absolutely RIDICULOUSLY customizable it is.

My wife got me a generic wireless mouse for Christmas.  The brand name is "Gear Head" and it is (of course) made in China and she told me it was pretty inexpensive.  I had a *slight* doubt that I would have to mess around with it a little to get it to work on the Linux desktop.  To my surprise, I plugged in the little USB wireless dongle and the mouse just started working immediately!

Unfortunately, the first thing I noticed was that the mouse was way too sensitive for my liking.  Pretty simple fix though, right?  In Cinnamon, just go to System Settings --> Mouse and Touchpad --> Power Speed...  hm, sensitivity and acceleration are both set to the minimum values.  Now what?

I found this question on ubuntuforums.org, which basically has the question and the answer, although the original poster was trying to change properties for an ambiguous device.  Here is another way to do it:

wskellenger@marquette ~ $ xinput list
⎡ Virtual core pointer                     id=2 [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer               id=4 [slave  pointer  (2)]
⎜   ↳ DualPoint Stick                          id=12 [slave  pointer  (2)]
⎜   ↳ AlpsPS/2 ALPS DualPoint TouchPad         id=13 [slave  pointer  (2)]
⎜   ↳  2.4G RF MOUSE                           id=15 [slave  pointer  (2)]
⎣ Virtual core keyboard                    id=3 [master keyboard (2)]
    ↳ Virtual core XTEST keyboard              id=5 [slave  keyboard (3)]
    ↳ Power Button                             id=6 [slave  keyboard (3)]
    ↳ Video Bus                                id=7 [slave  keyboard (3)]
    ↳ Power Button                             id=8 [slave  keyboard (3)]
    ↳ Sleep Button                             id=9 [slave  keyboard (3)]
    ↳ Laptop_Integrated_Webcam_HD              id=10 [slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard             id=11 [slave  keyboard (3)]
    ↳ Dell WMI hotkeys                         id=14 [slave  keyboard (3)]
wskellenger@marquette ~ $ 
In my case the 2.4G RF Mouse is the culprit.  Here we can investigate the properties of the device (note it is device id 15):

wskellenger@marquette ~ $ xinput --list-props 15
Device ' 2.4G RF MOUSE':
 Device Enabled (133): 1
 Coordinate Transformation Matrix (135): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
 Device Accel Profile (254): 0
 Device Accel Constant Deceleration (255): 1.000000
 Device Accel Adaptive Deceleration (256): 1.000000
 Device Accel Velocity Scaling (257): 10.000000
 Device Product ID (250): 9781, 1537
 Device Node (251): "/dev/input/event13"
 Evdev Axis Inversion (258): 0, 0
 Evdev Axes Swap (260): 0
 Axis Labels (261): "Rel X" (143), "Rel Y" (144), "Rel Vert Wheel" (555)
 Button Labels (262): "Button Left" (136), "Button Middle" (137), "Button Right" (138), "Button Wheel Up" (139), "Button Wheel Down" (140), "Button Horiz Wheel Left" (141), "Button Horiz Wheel Right" (142), "Button Side" (681), "Button Extra" (682), "Button Unknown" (253), "Button Unknown" (253), "Button Unknown" (253), "Button Unknown" (253)
 Evdev Middle Button Emulation (263): 0
 Evdev Middle Button Timeout (264): 50
 Evdev Third Button Emulation (265): 0
 Evdev Third Button Emulation Timeout (266): 1000
 Evdev Third Button Emulation Button (267): 3
 Evdev Third Button Emulation Threshold (268): 20
 Evdev Wheel Emulation (269): 0
 Evdev Wheel Emulation Axes (270): 0, 0, 4, 5
 Evdev Wheel Emulation Inertia (271): 10
 Evdev Wheel Emulation Timeout (272): 200
 Evdev Wheel Emulation Button (273): 4
 Evdev Drag Lock Buttons (274): 0

Now I just changed the "Device Accel Constant Deceleration" property like so:

wskellenger@marquette ~ $ xinput --set-prop 15 "Device Accel Constant Deceleration" 2


Update 29-Dec-2012:

To get this behavior on every startup, I've created a simple shell script:

# ----- Set mouse decel for wireless mouse if present -----
DEVID=`xinput list | grep "RF MOUSE" | sed -e "s/^.*id=\([0-9]\+\).*/\1/"`
if [ "$DEVID" != "" ]; then
   xinput --set-prop $DEVID "Device Accel Constant Deceleration" 2
   echo Set device deceleration for device $DEVID.

The script basically just does exactly what I described above -- it looks for "RF MOUSE" in the input list.  If it is found, it determines the ID number of the device and stores that number into a variable called DEVID.  Then, if the DEVID isn't empty, it runs the xinput --set-prop command.

I put this into a script file called myxinit.sh and I copied this into my ~/bin directory.   Make sure to set this file as executable with "chmod +x myxinit.sh"

Now you can set this to run when Cinnamon starts up, simply by going to Preferences --> Startup Applications:

And then in the Startup Applications dialog, add the script:

Optional: If this helped you, click one of my ads!  :-)

Sunday, December 9, 2012

Installing Scilab 5.4.0 on Linux Mint 13 (or Ubuntu)

Linux Mint/Ubuntu still has the old scilab in their repository.  Not only that, but it forces installation of openjdk, while I want to use the Oracle jdk:

wskellenger@marquette ~ $ sudo apt-get -V install scilab
Reading package lists... Done
Building dependency tree      
Reading state information... Done
The following extra packages will be installed:
   antlr (2.7.7+dfsg-3)
   ca-certificates-java (20110912ubuntu6)
   default-jre (1.6-43ubuntu2)
   default-jre-headless (1.6-43ubuntu2)
   fop (1.0.dfsg2-6)
   icedtea-6-jre-cacao (6b24-1.11.5-0ubuntu1~12.04.1)
   icedtea-6-jre-jamvm (6b24-1.11.5-0ubuntu1~12.04.1)
   icedtea-netx (1.2-2ubuntu1.3)
   javahelp2 (2.0.05.ds1-6)
   libatk-wrapper-java (0.30.4-0ubuntu2)
   libatk-wrapper-java-jni (0.30.4-0ubuntu2)
   libbatik-java (1.7.ubuntu-8ubuntu1)
   libfop-java (1.0.dfsg2-6)
   libjeuclid-core-java (3.1.9-2ubuntu1)
   libjgraphx-java (
   libjhdf5-java (2.6.1-2build1)
   libjlatexmath-fop-java (0.9.7-1)
   libjogl-java (1.1.1+dak1-11)
   openjdk-6-jre (6b24-1.11.5-0ubuntu1~12.04.1)
   openjdk-6-jre-headless (6b24-1.11.5-0ubuntu1~12.04.1)
   openjdk-6-jre-lib (6b24-1.11.5-0ubuntu1~12.04.1)

   rhino (1.7R3-5)
   scilab-cli (5.3.3-6)
   scilab-data (5.3.3-6)
   scilab-doc (5.3.3-6)
   scilab-full-bin (5.3.3-6)
   scilab-include (5.3.3-6)
   scilab-minimal-bin (5.3.3-6)
   scilab-sivp (0.5.3-3)

Suggested packages:
   fop-doc (1.0.dfsg2-6)
   javahelp2-doc (2.0.05.ds1-6)
   libjlatexmath-java-doc (0.9.7-1)
   libjogl-java-doc (1.1.1+dak1-11)
   icedtea-plugin (1.2-2ubuntu1.3)
   sun-java6-fonts ()
   fonts-ipafont-gothic (00303-5)
   fonts-ipafont-mincho (00303-5)
   ttf-telugu-fonts (0.5.11ubuntu1)
   ttf-oriya-fonts (0.5.11ubuntu1)
   ttf-kannada-fonts (0.5.11ubuntu1)
   ttf-bengali-fonts (0.5.11ubuntu1)
   librhino-java-doc (1.7R3-5)
   scilab-doc-fr (5.3.3-6)
   scilab-doc-pt-br (5.3.3-6)
   scilab-doc-ja (5.3.3-6)
   gfortran (4.6.3-1ubuntu5)
   scilab-swt (0.1.0rc4-5)
   scilab-scimax (2.1.4-1)
   scilab-plotlib (0.42-1)
   scilab-ann (
The following NEW packages will be installed:
   antlr (2.7.7+dfsg-3)
   ca-certificates-java (20110912ubuntu6)
   default-jre (1.6-43ubuntu2)
   default-jre-headless (1.6-43ubuntu2)
   fop (1.0.dfsg2-6)
   icedtea-6-jre-cacao (6b24-1.11.5-0ubuntu1~12.04.1)
   icedtea-6-jre-jamvm (6b24-1.11.5-0ubuntu1~12.04.1)
   icedtea-netx (1.2-2ubuntu1.3)
   javahelp2 (2.0.05.ds1-6)
   libatk-wrapper-java (0.30.4-0ubuntu2)
   libatk-wrapper-java-jni (0.30.4-0ubuntu2)
   libbatik-java (1.7.ubuntu-8ubuntu1)
   libfop-java (1.0.dfsg2-6)
   libjeuclid-core-java (3.1.9-2ubuntu1)
   libjgraphx-java (
   libjhdf5-java (2.6.1-2build1)
   libjlatexmath-fop-java (0.9.7-1)
   libjogl-java (1.1.1+dak1-11)
   openjdk-6-jre (6b24-1.11.5-0ubuntu1~12.04.1)
   openjdk-6-jre-headless (6b24-1.11.5-0ubuntu1~12.04.1)
   openjdk-6-jre-lib (6b24-1.11.5-0ubuntu1~12.04.1)

   rhino (1.7R3-5)
   scilab (5.3.3-6)
   scilab-cli (5.3.3-6)
   scilab-data (5.3.3-6)
   scilab-doc (5.3.3-6)
   scilab-full-bin (5.3.3-6)
   scilab-include (5.3.3-6)
   scilab-minimal-bin (5.3.3-6)
   scilab-sivp (0.5.3-3)

0 upgraded, 30 newly installed, 0 to remove and 19 not upgraded.
Need to get 73.7 kB/88.5 MB of archives.
After this operation, 254 MB of additional disk space will be used.
Do you want to continue [Y/n]?

To get the latest and greatest I just downloaded the scilab 5.4.0 binary from the Scilab website.  Extract the archive somewhere.  Everything should be neatly placed in a folder like "scilab-5.4.0".  I moved the entire folder to /usr/local/bin.  As root:

wskellenger@marquette / $cd /usr/local/bin
marquette bin # mv /home/wskellenger/Downloads/scilab-5.4.0 .

Now tell the system you've installed it:

marquette bin # update-alternatives --install "/usr/bin/scilab" "scilab" "/usr/local/bin/scilab-5.4.0/bin/scilab" 1
update-alternatives: using /usr/local/bin/scilab-5.4.0/bin/scilab to provide /usr/bin/scilab (scilab) in auto mode.

marquette bin # update-alternatives --install "/usr/bin/scilab-cli" "scilab-cli" "/usr/local/bin/scilab-5.4.0/bin/scilab-cli" 1
update-alternatives: using /usr/local/bin/scilab-5.4.0/bin/scilab-cli to provide /usr/bin/scilab-cli (scilab-cli) in auto mode.

Set scilab and scilab-cli as defaults:

marquette bin # update-alternatives --set scilab /usr/local/bin/scilab-5.4.0/bin/scilab
marquette bin # update-alternatives --set scilab-cli /usr/local/bin/scilab-5.4.0/bin/scilab-cli

Now exit root and try to run it as your usual user:

wskellenger@marquette ~ $ scilab

(process:11270): Gtk-WARNING **: Locale not supported by C library.
 Using the fallback 'C' locale.

Probably I should fix that locale warning, but it isn't critical.  You should see scilab 5.4.0.

Sunday, December 2, 2012

Dual Boot Linux Mint 13 with Windows 8 UEFI

I just bought a  new Dell Inspiron 3520 from Best Buy for $399.  I could not pass this machine up for the price:

By far, this is the newest computer I've ever owned. I have currently a 1.4 GHz P4 desktop that I got for free.  This replaced a slightly slower 1.2 GHz P3.  I've been watching Craigslist for a nice used laptop and I when this came along I could not pass it up.

The first thing I learned about this new machine is that it uses a booting spec called UEFI.  It appears that this whole scheme is devised to keep new Windows 8 approved PCs from running anything but Windows 8.

There are many articles on this already but here is my experience with installing Linux Mint 13 next to Windows 8.  I used information from several sources -- this page in particular was very helpful.

So, the first step in all of this is to shrink the existing Windows partition, freeing up space that will be used for the Linux installation.  My new hard drive is 500 GB so after defragging the drive I decided to make as much space available as possible, hopefully splitting the drive in half:  250 GB for Windows and 250 GB for Linux.

Control Panel --> System and Security --> Administrative Tools --> Computer Management --> Storage --> Disk Management

Here you can shrink the existing Windows partition.  It is pretty straightforward.  Right click the main Windows partition and select "Shrink Volume".

Now you've got free space to work with.  Ok, now boot to Linux Mint with the Live DVD.

Here I learned something new -- you can't just boot from whatever device you want anymore.  Remember when you had to specify the device boot order in the BIOS settings?  You could boot from the CD-ROM first, then the floppy drive, then the hard disk, or whatever order you want?  Well, this is now called the 'legacy' method of booting.  In order to boot from the Mint DVD, I needed to start the PC into the boot menu and switch back to the legacy boot method.  With this PC you need to press F12 during the boot to get to the boot options screen:

And then:

Now with the Mint LiveDVD in the drive (I got mine very quickly via Torrent), you should be able to boot the machine into Linux.  Note that some LiveDVDs out there can be booted in the UEFI mode, just that the one I have was not one of them.  So you may not need to change boot options depending on the distro you're installing.

Start the Mint installer (the Install Linux Mint icon on the desktop), and click "Something Else" when asked what you want to do:

Select the free space area that you just created in Windows, and click the Add button.

I just created a 200 MB /boot partition...

Now create a root partition.  Leave enough for a swap partition, which should be the same size as the amount of RAM your machine has, plus a little more.  I have 4 GB of RAM so I've left about 5 GB of space for the swap partition.  Some people like to create a separate /home partition but I've never done this on any other machine.  There may be some compelling reasons to create a /home partition but for most people it isn't necessary.

Here is the swap partition:

Now, select the location for the bootloader installation.  Make this the partition where you created /boot.  In my case it is /dev/sda7:

Now click "Install Now" and you will be greeted with the following message:

Click Continue and let the installation finish.

Now we need to mod the UEFI partition to allow booting to Linux Mint.  Fortunately Ubuntu has a tool to do this.  Ubuntu has information on UEFI and installing on a UEFI system here.  I'll be using the boot-repair tool in order to facilitate booting from UEFI.  Since Ubuntu and Mint are from the same mold, this tool should work fine for us. 

Follow the instructions to install boot-repair.  Basically in a terminal window:

   sudo add-apt-repository ppa:yannubuntu/boot-repair && sudo apt-get update

and then

   sudo apt-get install -y boot-repair && boot-repair

By typing the above commands, the boot-repair tool will immediately start up and start scanning partitions.  Eventually you should see a dialog that looks like this:

All I had to do was click "Recommended repair" and let it go.  There will be a couple of points where it asks you to cut/paste some lines into a terminal.  Do this exactly as directed and click the "Forward" button ONLY after completing those steps.  When it has finished, reboot the computer.  Go back to your boot options and return the the computer to UEFI boot mode.

If you were successful, you should see this grub boot menu on boot:

Optional:  If this helped you, click one of my ads!  If you don't see ads, disable your adblocker for this page!  :-)

Friday, November 23, 2012

Randomize Digital Picture Frame Photos

I just put some photos on a digital picture frame (Smartparts SPX8E) to be displayed at a funeral.  I was disappointed to find that the photos could not be randomized.  In some cases the viewer would see many of the same photos in a row.  I went through all of the settings and could not find a way to fix this.

My first thought was to write a short Python script to rename all of the files with a random name.  This seemed easy enough, but someone must've come across this issue already...

Of course, someone has created a little tool to do this.  Check out this Windows batch file from Jason Faulkner on howtogeek.com.

The script is easy to use.
  • Insert the USB stick with the photos on it.  (I copied all of the photos to a backup folder just in case.)
  • Navigate to the USB stick in a DOS window on your Windows machine.  Here is a directory listing of the F: drive, which is the USB stick:

  • Notice many of the files have consecutive names?  This is what I want to change. 
  • Copy the batch file to this location (in this case F:\).
  • Run the batch file.  Just type "randomnames" and hit enter.  This is what you should see:

  • Type OK.  Don't sweat it.  When the script has finished, do another directory listing (type 'dir'):

Great, the photos all have random names now.  I inserted the stick into the picture frame...

This didn't change the order at all!  Was it the file date that needed to be changed?

With the USB stick back in my laptop, I updated the date on all of the files.  The POSIX utility 'touch' could be used to do this.  I used a program called ZTree to update the date on all of the files to today's date.

I tried again with updated dates.  No difference.  The files were still being displayed in the original order!  Now, the only thing I could think of is that the files are being read at a very low level, meaning they are simply being read from the stick in the physical order they are stored there.  The remedy for this is simply to move all of the files to your hard drive (either by using the move command or by copying them all and then deleting them), and then copy them back to the USB stick.

You should be able to use Windows Explorer to do this.  Again, I used ZTree.  Sort by name before copying back to the USB stick, and they should be copied in a 'random' order, because the names are already randomized.

Finally, it worked!  The photos are now displayed in a random order.  A simplified version of the steps:
  1. Start with a blank USB stick.
  2. Copy all of the photos you want to display into a temp directory on your hard drive.
  3. Copy the batch file "RenameFiles.bat" into the temp folder you just created.
  4. Execute the batch file to rename all of the files randomly.
  5. Use Windows Explorer and sort all of the files by name.
  6. Copy all of the files onto the blank USB stick.
  7. Finished.
Thanks to Jason Faulkner for writing and publishing the script to randomize filenames.