Sunday, October 27, 2013

Configuring xdg-open

Open/Libre-office spreadsheet hyperlinks would not open PDF files with Acroread even though caja was properly set to do so by default.
 

Xdg-open is the freedesktop.org scheme for opening files and URLs with our preferred applications.

First I verified that PDF files were recognized as such:

> xdg-mime query filetype somepdffile.pdf 
application/pdf
Good, and then that Acroread was the default application:
> xdg-mime query default application/pdf
userapp-acroread-9UNI5W.desktop
Excellent, but does it work?
> xdg-open somepdffile.pdf
Error: no "view" mailcap rules found for type "application/pdf"
Opening "somepdffile.pdf" with Document Viewer  (application/pdf)
In this case "Document Viewer"is Atril, not Acroread.

Poking around the mailcap thing I edited the user section in /etc/mailcap as so:

#  User section follows:  Any entries included in this section will take
#  precedence over those created by "update-mime".  DO NOT CHANGE the
#  "User Section Begins" and "User Section Ends" lines, or anything outside
#  of this section!
#

# ----- User Section Begins ----- #
application/pdf;/usr/local/bin/acroread %s; test=test "$DISPLAY" != ""; description=Portable Document Format; nametemplate=%s.pdf; priority=1
# -----  User Section Ends  ----- #
That did the trick.







Monday, May 6, 2013

PICkit2 User Permissions

Problem: Tried pk2cmd on a new box and got:
No PICkit 2 found.
lsusb indicated that the OS recognises it:
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 003 Device 002: ID 1bcf:053e Sunplus Innovation Technology Inc.
Bus 001 Device 003: ID 04f2:b2dc Chicony Electronics Co., Ltd
Bus 002 Device 003: ID 04ca:3006 Lite-On Technology Corp.
Bus 003 Device 003: ID 04d8:0033 Microchip Technology, Inc. PICkit2
It works fine if I sudo which indicates that it is a permission problem.
The solution is to set proper udev rules in /etc/udev/rules.d/ but I 
wasn't successful working it out. I checked another box and it appears 
that MPLABX has installed this:
/etc/udev/rules.d/z010_mchp_tools.rules:

# 2012.01.23 Changed SYSFS reference(s) to ATTR.
# 2011.12.15 Note: Reboot works on all systems to have rules file recognized.
# 2010.01.26 Add reference to "usb" for Ubuntu.
# 2010.01.22 Attempt to further simplify rules files requirements.
# 2009.08.18 Rules file simplified.
# 2009.07.15 Rules file created.

ENV{hotplugscript}="/etc/.mplab_ide/mchplinusbdevice"

ACTION!="add", GOTO="check_remove"
SUBSYSTEM=="usb_device", GOTO="check_add"
SUBSYSTEM!="usb", GOTO="rules_end"

LABEL="check_add"

ATTR{idVendor}=="04d8", MODE="666", RUN+="%E{hotplugscript} add"
GOTO="rules_end"

LABEL="check_remove"

ACTION=="remove", RUN+="%E{hotplugscript} remove %E{PRODUCT}"

LABEL="rules_end"
Note the executable /etc/.mplab_ide/mchplinusbdevice. Things appear 
to work fine without it but the simple solution is to just install
MPLABX.

Friday, May 3, 2013

Device not managed

Problem: NetworkManager indicates 'device not managed' for eth0.

Edit /etc/NetworkManager/NetworkManager.conf:
[ifupdown]
managed=true
Restart:
# sudo service network-manager restart

Friday, April 26, 2013

Sticky Firefox User Agent

From the User Agent Switcher Help page:

Why does the user agent reset when the browser closes? 

Due to a bug in Sun's Java plug-in the extension automatically resets the user agent when the browser closes in order to stop the browser crashing on the next start-up.
If you are unable to start the browser find the file 'prefs.js' in your profile and delete the line containing 'general.useragent.override' to fix the issue.
If you understand this issue and want to disable the auto-reset functionality create a new preference 'useragentswitcher.reset.onclose' and set it to false.
No support is provided for this configuration.

Of course, nobody is using a Java plugin these days. Correct?


Bash'rc stuff


# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

# development tool paths
xc8ver="v1.12"
xc16ver="v1.11"
xc32ver="v1.20"

xc8path="/opt/microchip/xc8/$xc8ver/bin"
xc16path="/opt/microchip/xc16/$xc16ver/bin/bin:/opt/microchip/xc16/$xc16ver/bin"
xc32path="/opt/microchip/xc32/$xc32ver/bin"

# Note: the xc8 tools duplicate some gnu names, e.g.'cpp'. Expect some problems.
PATH=$PATH:$xc8path:$xc16path:$xc32path

echo "(bash) "`whoami`": "`pwd`
PS1='.'

REPO="file:///home/project/svn/repo"
export REPO

CCRRBASE="$HOME/project/ccrr"
export CCRRBASE

MPASMPATH="$HOME/.wine/drive_c/Program Files (x86)/Microchip/MPASM Suite"
export MPASMPATH

#XC8_INCLUDE="/opt/microchip/xc8/v1.12/include"
#export XC8_INCLUDE

XC8_LIB="/opt/microchip/xc8/v1.12/lib"
export XC8_LIB

alias ls='ls --color=never'

Sunday, April 21, 2013

Firefox Tweeks

Firefox 20
  • browser.download.useToolkitUI=true to get the classic download window back.

Thursday, April 18, 2013

Not quite full disk encryption with LVM and LUKS

Andreas Haerter has a step-by-step guide on how to install an Ubuntu Linux system with full disk encryption. However it does not encrypt the GRUB2 or /boot partition.

The purpose of using LVM is that multiple encrypted volumes can be opened with one pass-phrase at boot because they all reside on one encrypted disk partition with a LUKS header.

Here is a summary.

In the following examples:
  • boot partition is sda2
  • encrypted partition is sda5
  • opened encrypted partition is sda5-secure
  • encrypted VG is SecureVG
  • Root LV is secure-root
From the live install disk install LVM2 and cryptsetup.
# apt-get install LVM2
# apt-get install cryptsetup 
# modprobe dm-crypt
Create the LUKS header for the encrypted partition, e.g.
# cryptsetup --cipher aes-xts-plain --key-size 512 --verify-passphrase luksFormat /dev/sda5
Open the encrypted partition, e.g.
# cryptsetup luksOpen /dev/sda5 sda5-secure
This maps to /dev/mapper/sda5-secure
Create the LVM volumns:
# pvcreate /dev/mapper/sda5-secure
# vgcreate SecureVG /dev/mapper/sda5-secure
# lvcreate ...
Install the system.

Chroot to the new system root mounted at /mnt/secure-root.
# mkdir /mnt/secure-root
# mount /dev/mapper/SecureVG-secure--root--01 /mnt/secure-root
# mount /dev/sda2 /mnt/secure-root/boot
# mount -o bind /dev /mnt/secure-root/dev
# mount -t proc proc /mnt/secure-root/proc
# mount -t sysfs sys /mnt/secure-root/sys
# cp /etc/resolv.conf /mnt/secure-root/etc/resolv.conf
# chroot /mnt/secure-root /bin/bash
Install LVM2 and cryptsetup on the new system. 
# apt-get update
# apt-get install cryptsetup lvm2
Add an entry in /etc/crypttab. Generate the line with:
# echo "secure-sda5 UUID=$(ls -la /dev/disk/by-uuid | grep $(basename /dev/sda5) | cut -d ' ' -f 10) none luks"
E.g. "secure-sda5 UUID=6e61c215-b930-41bf-b33a-cfb52cc5b969 none luks"
Add GRUB2 modules for preload to /etc/default/grub:
GRUB_PRELOAD_MODULES="lvm cryptodisk luks"
Update the GUB2 menu:
# update-grub
Regenerate the initrd:
# update-initramfs -u -k all
Do you feel lucky?
# exit
# reboot