Wednesday, October 19, 2011

OpenOffice.org SVG Import/Export

I posted some OpenOffice.org SVG Import/Export comments on OpenOffice.org recently. The export procedure first featured on Wikipedia SVG Help.

Importing SVG files into OpenOffice.org

The only solution I have found to properly import svg files into OpenOffice.org 3 is to download and execute the standalone OpenOffice.org 2.0 SVG Import Filter from http://haumacher.de/svg-import/

java -jar svg2office-1.2.2.jar <some-file.svg>

Exporting OpenOffice.org SVG files

Exported OpenOffice.org svg files may require manual modification before successfully being used elsewhere (e.g. uploaded to wikipedia). To achieve this;
  • change all fonts types to supported fonts (E.g. change "Sans embedded" to "DejaVu Sans")
  • add "px" to all font-size references (E.g. change "font-size:100" to "font-size:100px")
  • remove all additional x coordinate references in tspans (E.g. change <tspan x="17583 17917 " y="10943"> to <tspan x="17583" y="10943">)
  • [Not required for OO 2.3.0:] explicitly colour all text (E.g. black) by replacing relevant "stroke:none;fill:none" instances with "stroke:none;fill:rgb(0,0,0)" (note that simply explicitly colouring text black in openoffice 3.2.1 does not appear to work)
NB vector graphics line widths may also need to be set explicitly in OpenOffice.org Draw.

SVG code replacement guide (executing replace all using Nedit regular expressions):

Original Text Replacement Text
Sans embedded DejaVu Sans
font-size:([0-9]*); font-size:\1px;
tspan x="([0-9]*) ([0-9 ]*)" tspan x="\1"
<g style="stroke:none;fill:none"><text> <g style="stroke:none;fill:rgb(0,0,0)"><text>

This svg export procedure has been tested using OO 2.3.0 and OO 3.2.1 with a simple .odg candidate.

Planner task Predecessors on EL6

Planner is currently unusable on EL6 due to a break in task Predecessors. Note the bugzilla report. (Feedback from Red Hat indicates a fix might be arriving soon on a new release).

Compiz Fusion Install on EL6

Here is some basic documentation for compiz-fusion on EL6 that wasn't immediately obvious (posted on Centos.org);

A. To install compiz fusion;
1. install epel-release (rpm -i epel-release-6-5.noarch.rpm)
2. yum install compiz-fusion-extras compiz-plugins-main compiz-manager compiz-fusion-extras libcompizconfig compiz-plugins-main-gconf ccsm compiz-gnome compiz-gtk compiz-fusion-extras-gnome fusion-icon

(rpm -i ccsm-0.8.2-5.el6.noarch.rpm compizconfig-python-0.8.2-3.el6.x86_64.rpm compiz-fusion-0.8.2-8.el6.x86_64.rpm compiz-fusion-extras-0.8.2-6.el6.x86_64.rpm compiz-fusion-extras-gnome-0.8.2-6.el6.x86_64.rpm compiz-manager-0.6.0-11.el6.noarch.rpm fusion-icon-0.1.0-0.9.5e2dc9git.el6.noarch.rpm fusion-icon-qt-0.1.0-0.9.5e2dc9git.el6.noarch.rpm libcompizconfig-0.8.2-9.el6.x86_64.rpm
[Dependencies may include; libsexy-0.1.11-13.el6.x86_64.rpm protobuf-2.3.0-7.el6.x86_64.rpm PyQt4-4.6.2-8.el6.x86_64.rpm python-sexy-0.1.9-9.1.el6.x86_64.rpm sip-4.9.3-1.el6.x86_64.rpm etc])

B. To enable compiz-fusion;
1. System - Preferences - desktop effects - compiz
2. Applications - System Tools - Compiz Fusion Icon

C. To use compiz-fusion;
1. Right click on Blue CompizFusion icon - Settings Manager
2. Make changes
3. Right click on Blue CompizFusion icon - Reload Windows Manager

D. To load compiz-fusion on startup;
1. System - Preferences - Startup Applications - Add
2. enter "fusion-icon" in command box, then press 'Add'

For reference, "ccsm" is the compiz fusion settings manager (System - Preferences - CompizConfig Settings Manager), and "fusion-icon" is the compiz fusion initialiser / system tray icon

NB To install compiz fusion optimised themes (?);
yum install emerald-themes emerald
(emerald-0.8.2-3.el6.x86_64.rpm emerald-themes-0.5.2-5.el6.noarch.rpm)

How To Reinstall Grub Boot Loader (EL5 and EL6)

Here are some extracts from fedoraforum.org on how to reinstall the Grub Boot Loader (EL5 and EL6) which were recently updated. Note these instructions appear to be published now by Red Hat.

How to Reinstall EL5/EL6 Grub Boot Loader
(Eg this is required if a Windows reinstallation overwrote/disabled your Linux boot partition)

***disclaimer; advice offered with no warranty***

1. Insert EL5/EL6 DVD
2. Reboot PC
3. type 'linux rescue' when prompted
4. Accept standard options (Eg English)
5. If necessary, select your Linux partition used during the original EL5/EL6 installation when Grub was originally installed (Eg 'sda')
6. when prompted, select allow write access (ie, NOT read only)
7. type 'chroot /mnt/sysimage' (as suggested by linux rescue)
8. type '/sbin/grub-install /dev/sda' (assuming you wish to use the Primary boot sector of 'sda' - you will wish to use this if you installed it here during the original EL5/EL6 installation. Type the command '/sbin/fdisk -l' to determine where you installed Linux)
9. restart PC
10. Grub should load, and your previous grub settings (before you reinstalled Windows) should have remained

---

I would not recommend using the Windows Boot Manager to start anything other than Windows. I personally install Grub as my primary boot manger (on the primary boot sector).

Ideally, Windows is installed first, and then Linux (eg EL5/EL6) is installed (with grub) - which generally overwrites the Windows boot sequence. Grub automatically detects the Windows partition and adds to grub.conf the necessary command to load it.

However, if Windows is installed after Linux, grub can be extended to load the windows partition (eg XP, Win7) by manually adding the necessary command to grub.conf.

Added are some examples of grub.conf windows boot commands below. "PARTITIONINDEX" in these examples should be set to the partition index of Windows. This should generally be "0" if Windows was installed first*. You should use the command "/sbin/fdisk -l" (referenced by ppesci) to determine/confirm the partition index of Windows (or the Windows Boot Manager). Note, there is no blank line between the line "title..." and the line "root...".

title Windows XP

root (hd0,PARTITIONINDEX)
savedefault
makeactive
chainloader +1

title Windows 7

rootnoverify (hd0,PARTITIONINDEX)
chainloader +1

* Note again; you shouldn't have to modify grub.conf at all if Windows was installed before Linux. However exceptions do exist. An example of an exception would be if you RE-installed Windows and Windows changed the partition in which it needed to initialise its boot sequence/manager. These things happen, from experience - particularly on laptops with pre-installed copies of Windows.

Tuesday, October 11, 2011

Mouse button customisation instructions for Linux (EL6) with MX620 Cordless Laser Mouse

I have added mouse button customisation instructions for Linux (EL6) with MX620 Cordless Laser Mouse to the Logitech forums. These assume the user wishes to map BackSpace and Return to buttons 8 and 9, and the Search button to Firefox. NB the horizontal scroll wheel should be enabled by default on current distributions, but this method can be used to explicitly map it if necessary.

[The following step is neither required nor recommended for current Linux distributions]
1. determine usb-Logitech_USB_Receiver-event-mouse event# (eg event8):
ls -lh /dev/input/by-id/
    e.g. output;
    lrwxrwxrwx. 1 root root  9 Oct 12 09:01 usb-Logitech_USB_Receiver-event-if01 -> ../event9
    lrwxrwxrwx. 1 root root  9 Oct 12 09:01 usb-Logitech_USB_Receiver-event-mouse -> ../event8
    lrwxrwxrwx. 1 root root  9 Oct 12 09:01 usb-Logitech_USB_Receiver-mouse -> ../mouse2
    lrwxrwxrwx. 1 root root 10 Oct 12 09:01 usb-Sonix_Technology_Co.__Ltd._USB_2.0_Camera-event-if00 -> ../event10

2. install xorg-x11-drv-evdev:
yum install xorg-x11-drv-evdev [rpm -i xorg-x11-drv-evdev-2.3.2-8.el6.x86_64.rpm]
{Ubuntu: sudo apt-get install xserver-xorg-input-evdev}

[The following step is neither required nor recommended for current Linux distributions]
3. update xorg.conf:
su root
nedit /etc/X11/xorg.conf

Section "ServerLayout"  [add the following of text;]
    InputDevice "Logitech MX620"

Section "Module"  [add the following line of text;]
    load "evdev"
  
[add the following lines of text {NB event#};]  
Section "InputDevice"
    Identifier "Logitech MX620"
    Driver "evdev"
    Option "CorePointer"
    Option "Device" "/dev/input/by-id/usb-Logitech_USB_Receiver-event-mouse"
    #Option "Device" "/dev/input/event8"
    Option "Resolution" "800"
    Option "RelHWHEELMapTo" "Buttons 7 6"
EndSection

4. install key executer software: choose either 4a) or 4b) or 4c) {RECOMMENDED};

4a) install xvkbd:
su root
yum install Xaw3d [rpm -i Xaw3d-1.5E-15.1.el6.x86_64.rpm]
rpm -i xvkbd-2.8-1.el4.rf.x86_64.rpm [download xvkbd from http://pkgs.repoforge.org/xvkbd/]
{Ubuntu: sudo apt-get install xvkbd}
xvkbd -xsendevent -text "\b"
xvkbd -xsendevent -text "\r"
        http://www.linuxquestions.org/questions/linux-desktop-74/mouse-keys-as-modifier-keys-ctrl-and-alt-605154/
        http://linux.die.net/man/1/xvkbd
        \b - Backspace
        \r - Return
  
4b) install xsendkeycode:
download xsendkeycode.c from https://bbs.archlinux.org/viewtopic.php?id=114799 / http://lineakd.sourcearchive.com/documentation/0.9/xsendkeycode_8c-source.html
yum install libXtst-devel [rpm -i libXtst-devel-1.0.99.2-3.el6.x86_64.rpm]
gcc -o xsendkeycode xsendkeycode.c -lX11 -lXtst
    http://dev.man-online.org/man8/xsendkeycode/
    Eg1 ./xsendkeycode 38 1; ./xsendkeycode 38 0;
    Eg2 ./xsendkeycode 50 1; ./xsendkeycode 38 1; ./xsendkeycode 38 0; ./xsendkeycode 50 0;

4c) install xsendkey {RECOMMENDED}:
yum install libXtst-devel [rpm -i libXtst-devel-1.0.99.2-3.el6.x86_64.rpm]
download xsendkey from http://people.csail.mit.edu/adonovan/hacks/xsendkey.html
gcc -o xsendkey -lX11 -lXtst xsendkey.c
./xsendkey BackSpace  
./xsendkey Return
   [see keysyms in keysymdef.h]
su root
cp xsendkey /usr/bin/

5. install xbindkeys:
su root
rpm -i rpmforge-release
yum install xbindkeys [rpm -i guile-1.8.7-4.el6.x86_64.rpm xbindkeys-1.8.2-1.el6.rf.x86_64.rpm]
rpm -e rpmforge-release
{Ubuntu: sudo apt-get install xbindkeys}

[The following step is neither required nor recommended for current Linux distributions]
6. create a new rule file for udev with the following command:
su root
cd /etc/udev/rules.d
nedit 19-local.rules &
add the following;
    KERNEL=="hiddev*", NAME="%k", MODE="666"
    KERNEL=="event*", SYSFS{../name}=="Logitech USB Receiver", NAME="input/mx620"

7. create the xbindkeys bind file (see http://www.nongnu.org/xbindkeys/xbindkeys.html#configuration for more info and example configuration files):
   NB  You can see a default file with the --defaults option or create a default $HOME/.xbindkeysrc with
    'xbindkeys --defaults > $HOME/.xbindkeysrc'
    To find out a keyboard button is called, use xbindkeys -k
    To find out what a mouse button is called, you can use xev.
        button 1; left  
        button 2; middle
        button 3; right
        button 4; up scroll
        button 5; down scroll
        button 6; left scroll
        button 7; right scroll
        button 8; back
        button 9; forward      
su user
nedit ~/.xbindkeysrc
add the following;

"xsendkey BackSpace"
m:0x0 + b:8

"xsendkey Return"
m:0x0 + b:9

[The above assumes 4c). If 4a) then use the commands "xvkbd -xsendevent -text "\b"" and "xvkbd -xsendevent -text "\r"" instead]

8. Autostart xbindkeys;
System - Preferences - Startup Applications - Add;
    Name: xbindkeys
    Command: /usr/bin/xbindkeys
{Ubuntu: System > Preferences > Sessions. Select the Startup Programs tab. Add: /usr/bin/xbindkeys}

9. To configure the mouse Search Button;
(NB the Logitech mouse search button is special in that it actually acts like the keyboard search button XF86Search).
System - Preferences - Keyboard Shortcuts
Disable the current keyboard shortcut mapped to XF86Search (e.g. "Search")
    Select "Search" and press the Backspace key (this should disable it)
Either a) Create a new keyboard shortcut mapped to XF86Search (e.g. "CustomSearchButton")
    Press "Add",
    enter name e.g. "CustomSearchButton"
    enter command e.g. "firefox -new-window http://www.google.com"
    press close
    map XF86Search to this new shortcut definition by pressing the Search button on the mouse.
Or b) assign XF86Search to an existing function (eg 'Close Window')

---

NB For Ubuntu specifically, you could try btnx:

(How to Customize Extra Mouse Buttons in Linux)

http://www.ghacks.net/2011/06/28/how-to-customize-extra-mouse-buttons-in-linux/

sudo apt-get install btnx
Applications > System Tools > btnx