Tuesday, February 28, 2012

How to set default apps (aka how to use xdg-mime)

How to set default apps in Chromium / Chrome / Firefox / Ubuntu Linux

Situation: You hate the default app that opens when you double click a file or when you open it with chromium browser and you want to change it.

a) In Unity (and probably Gnome 3 Shell), some default apps can be changed through gnome-control-center: System settings > System info > Default applications



b) You can also right-click on a file > select Properties > Open with. See what applications/programs are listed there. You can also add them and set them as default.


c) If none of the above work, you can use xdg-utils (xdg-mime) to set a default application for a specific Mime Type

First, you have to figure out what text string to use as a "mime type". An easy way to find it is to look into the default application's desktop file.

Example: Chromium opens magnet links and bittorrent files with transmission-gtk by default. The .desktop files are usually in folder /usr/share/applications/. We use "cat" command to look into the file /usr/share/applications/transmission-gtk (a line that starts with "MimeType"):

$ cat /usr/share/applications/transmission-gtk.desktop
[Desktop Entry]
Name=Transmission
[...]
Exec=transmission-gtk %U
Icon=transmission
Terminal=false
TryExec=transmission-gtk
Type=Application
MimeType=application/x-bittorrent;x-scheme-handler/magnet;
Categories=Network;FileTransfer;P2P;GTK;

Bingo! x-scheme-handler/magnet and application/x-bittorrent are the mime types we're after.

How to use xdg-mime command? Simple: xdg-mime default myapp.desktop mymimetype

..where we substitute myapp.desktop and mymimetype with the values from above.

Following the example above, we want magnet links and bittorrent files to open with Deluge (deluge-gtk) application. First you have to install the deluge-gtk package (otherwise the .desktop file won't exist). Then you have to execute:

xdg-mime default deluge.desktop x-scheme-handler/magnet
xdg-mime default deluge.desktop application/x-bittorrent
grep -i deluge ~/.local/share/applications/*

The last command (grep) should return "application/x-bittorrent=deluge.desktop" and the other mime type for magnet. Otherwise, something went wrong (maybe the desktop file didn't exist?).

And that's about it! Close and open chromium-browser again (or logout/login).

For the sake of documentation, the files that have to do with mime types and default apps are:

~/.local/share/applications/defaults.list
~/.local/share/applications/mimeapps.list
~/.local/share/applications/mimeinfo.cache
/usr/share/applications/mimeinfo.cache
/usr/share/applications/mimeapps.list
/usr/share/applications/defaults.list

Error creating XPS file


Error creating XPS file: Source _rels/.rels not found in archive
If you see the above error when trying to use xpstopng, xpstopdf, xpsto* tools provided by libgxps, then you probably suffer from this bug:
https://bugzilla.gnome.org/show_bug.cgi?id=670895

In short, the problem lies with libarchive versions prior to 3.x and zip files created by windows.
Solution?
a) Just update to 3.x or newer and you'll be good to go.
b) As a workaround, you can recreate the zip file:

unzip lorem-ipsum-and-image.xps -d temp/
cd temp/
zip ../newfile.xps *
cd ..


You now have a working copy of your XPS document.

Saturday, February 11, 2012

How to install 1385:5f01 Netgear WPN111 (ar5523 driver)

Bus 002 Device 004: ID 1385:5f01 Netgear, Inc WPN111 (no firmware)
If you have the above device or a usb wifi dongle that requires ar5523 driver, you can try the commands and packages I've documented in order to make it work.

The weird thing with this device is that the firmware adds +1 to its ID. If you look at the code (SVN repository), you'll see that it's registered as "1385:5f00".

How to install the device driver
1. Install this package, depending on the version of ubuntu you may have:

2. Execute the following commands, copy-paste them one by one:
sudo apt-get update
sudo apt-get -f install
sudo apt-get upgrade
sudo apt-get install build-essential linux-headers-generic module-assistant
sudo m-a a-i ar5523-source
wget http://verein.lst.de/~hch/ar5523.tgz
tar xvf ar5523.tgz ar5523/uath-ar5523.bin --strip 1
sudo mv uath-ar5523.bin /lib/firmware

3. Restart your computer and replug your usb dongle. Hopefully it works. :)


Source(s):