Using Gmail for mail links in Firefox

Copy the following script to your home:

#!/bin/sh
firefox 'https://mail.google.com/mail?view=cm&tf=0&to='`echo $1 | sed 's/mailto://'`

Save it as ~/open_mailto.sh and change its permissions:

chmod u+x ~/open_mailto.sh

In Firefox, go to Edit -> Preferences -> Applications -> mailto and choose /home/username/open_mailto.sh.

Done!

Source: Ubuntu Geek

(To open in a new window instead use firefox --new-window 'https://mail.google.com/mail?view=cm&tf=0&to='`echo $1 | sed 's/mailto://'` instead.)

Posted in Uncategorized | Leave a comment

Disabling Ctrl+Q in Firefox

I always had the impression that Firefox exited randomly, and it always happened when I pressed Ctrl+W to close a tab, which I do some hundred times a day.

I thought it was a bug…    Indeed it is.

The bug is called Ctrl+Q. (How idiot, uh!)

And worse: you can’t disable it. You can’t configure shortcuts in Firefox… what a shame!

The good solution

I found a half solution: Edit -> Preferences -> Tabs -> Warn me when closing multiple tabs.
(no longer works)

Open about:config and set browser.showQuitWarning to true.

You will have to tolerate a bugging dialog every time you truly want to exit. I have done it for years now and it is OK.

Bonus

Ctrl+W closes your window when there only one tab. If you don’t want that, open about:config and set browser.tabs.closeWindowWithLastTab to false.

Extreme solutions, crappy solutions, and some Firefox rant

There is a full solution, which really is a shame for Firefox: replace Ctrl+Q by something else at the system level. I haven’t tested, I’m not even interested.

I have read on some blogs that setting browser.warnOnQuit to true on the about:config page would make Firefox confirm before exiting. This would be an equivalent to my half solution… Anyway, as of Firefox 3.6.6 on Ubuntu 10.04, it simply does not work at all.

There is an add-on called keyconfig that allows you to configure shortcuts in Firefox. I have not been able to find its license, nor its source code. Some blogs and forums point you to keyconfig binary. Some even claim that it’s not a “virus” (probably meaning all sorts of malware and alike). If you want it, go ahead…

keyconfig is not available on Firefox Add-On’s webpage. A bonus for Firefox shame: there is an add-on on their page which only works if you have keyconfig installed (?!).

Posted in Uncategorized | 7 Comments

rm -rf ext4+ecryptfs Undelete

or…

Recovering deleted files in ext4 filesystem with Ubuntu encrypted home

Prologue…

This post may be useful if  you realize the mistake right after running rm -rf foldername.

It uses tools that try to recover deleted ext4 files based on a recent copy of blockpointers in the filesystem journal.

The files I have deleted were inside my home folder, which was encrypted via ecryptfs, the Ubuntu standard home encryption scheme.

Even though the files were innocent standard jpg photos, they were actually written to the disk as horribly named files with meaningless contents (they can only have some meaning after the appropriate kernel module uses your password and does some magic with it… that’s what encryption is all about). So there are two steps in this solution:

  1. recovering deleted ext4 files that are still on the disk
  2. getting your true files from horribly named files with meaningless contents

The instructions below also work if the files were not inside an encrypted home (it’s even easier, just ignore the last part). In such case this is not the only (and probably not the best) way to recover your files. There are methods based on the presence of media files on the disk regardless of the filesystem, of which photorec is an impressively powerful tool.

I’m also curious about using the latter approach with encrypted home. However, one would need to understand deeply the ecryptfs file storage structure to develop a method/tool that would work in this case, since the encrypted files are totally invisible to existing tools. I am unaware of a successful recovery using this approach.

In any case, comments are welcome, whether you know about other recovery methods, whether you tried this and could or could not recover your files.

First thing

First thing one must do is nothing: close the desktop login session, power off normally, and not power on again. (I’m not sure here though… perhaps unplugging battery and power source could be more effective than logging out etc, as less stuff would reach the disk.)

Before applying the instructions below, it is recommended to read a little bit about ext3grep and extundelete.

Assuming:

  • Want to recover files deleted inside the home directory
  • It is encrypted via ecryptfs, Ubuntu’s default home encryption setting
  • The username is $USER
  • The homefolder is /home/$USER
  • The concerned partition is /dev/sda1
  • You already made a raw clone of /dev/sda1
    (If you don’t want to make a raw clone, and you need to mount this partition, make sure you mount with the ro,noload options.)
  • /media/disk/foo is a folder with a lot of free space

So, here we go…

  1. Boot a LiveCD and make sure you don’t mount /dev/sda1

  2. Download, install and compile:

    cd /media/disk/foo
    wget http://downloads.sourceforge.net/project/extundelete/extundelete/0.2.0/extundelete-0.2.0.tar.bz2
    sudo apt-get install -y e2fsprogs e2fslibs e2fslibs-dev g++
    tar xfvj extundelete-0.2.0.tar.bz2
    cd extundelete-0.2.0/
    ./configure
    make
    cd ..
    

    Update: there are newer versions of extundelete, you may want to take a look.

  3. You can limit the search to the instant when you made this deletion:

    sudo extundelete-0.2.0/src/extundelete --after `date -d 'Aug 16 02:35' +%s`\
                 --before `date -d 'Aug 16 02:50' +%s` --restore-all /dev/sda1
  4. But if this is not enough, you can try recovering whatever extundelete can find:

    sudo extundelete-0.2.0/src/extundelete --restore-all /dev/sda1
  5. Check that the recovered data is located in paths like this:

    du /media/disk/foo/RECOVERED_FILES/ --max-depth=4
    :
    :
    :
    46776	/media/disk/foo/RECOVERED_FILES/.ecryptfs/$USER/.Private
    46780	/media/disk/foo/RECOVERED_FILES/.ecryptfs/$USER
    46784	/media/disk/foo/RECOVERED_FILES/.ecryptfs
    9180	/media/disk/foo/RECOVERED_FILES/lost+found
    94804	/media/disk/foo/RECOVERED_FILES/
  6. Reboot, log in as $USER (Remember, this is assuming you already made a raw clone of /dev/sda1 !)

    cd /home/$USER/.Private
    mkdir RECOVERED_FILES
    cd RECOVERED_FILES
    mkdir inodes
    mkdir files
    cp /media/disk/foo/RECOVERED_FILES/inode.* inodes/
    cp /media/disk/foo/RECOVERED_FILES/file.* files/
    cp /media/disk/foo/RECOVERED_FILES/lost+found/ . -r
    cp /media/disk/foo/RECOVERED_FILES/.ecryptfs/$USER/.Private home/ -r

Now see if some of your files may be found in RECOVERED_FILES inside  your home. Maybe with their full paths, maybe only the names, maybe just the files with strange names, maybe nothing at all… Hope this is helpful, though.

Credit

I learnt it mostly from gimi’s post. I found it through googlecache, I couldn’t reach the blog itself at that time, and I couldn’t comment there (I had a problem with bind-mounting the recovered folder inside the encrypted folder, ecryptfs didn’t seem to care about the presence of a folder being mounted there afterwards), so I started my own version of the mini-tutorial. Now gimi’s blog is available, but googlecache isn’t.

Epilogue

Next time just don’t delete. You are struggling against the whole filesystem conception here. From the ext3FAQ:

Q: How can I recover (undelete) deleted files from my ext3 partition?
A: Actually, you can’t! […]
In order to ensure that ext3 can safely resume an unlink after a crash, it actually zeros out the block pointers in the inode, whereas ext2 just marks these blocks as unused in the block bitmaps and marks the inode as “deleted” and leaves the block pointers alone. […]

Have backups, move to /tmp, move to the trash bin, but be careful with rm.

Posted in Uncategorized | 14 Comments

Organize your mp3 collection with free software

Welcome to my first blog post!

This is about organizing mp3 files, by folder, filename, metadata tags, and embedded album arts. Fortunately there are nice free tools that complement each other in this task.

I will not cover: volume leveling, CD ripping, CD burning, playlists.

Quod Libet

I didn’t particularly like Quod Libet for playing music.

For organizing your files, it rocks. Quod Libet has by principle that “you know how to organize your music better than they do”. That’s great! How I wish every free software had a clue on that.

It does take some time to get used to its configuration, and the way you can personalize tag editing and folder/file organizing. But after a while you realize that this nice little tool allows you to easily do whatever you want to your files, in a very flexible, precise, and automated way.

Quod Libet also has two nice plugins: it can download album arts to the same folder as your mp3, and it can fetch CDDB info.

Banshee and Listen

These are the best and cutest for playing.

They can as well download album art and save it inside ~/.cache, which also helps retrieving the covers. Listen is even better in this matter, as it can simultaneously download the missing covers for all your collection at once.

Easytag

It is great as it automatically fixes all the ID3 tags, and can easily embed pictures inside the mp3 files.

Rhythmbox

It is well-integrated with Gnome and the latest version can even sync your iPhone.

Workflow

Initial setup

Move your music to some other folder rather than ~/Music.
Get Quod Libet and EasyTag finely configured, and set the other players to automatically refresh the collection from the ~/Music folder.

Getting your music organized

Move some folders to ~/Music.

Open EasyTag, select these folders, then select something else. It may prompt if you want to save the files, you say yes. EasyTag will be fixing your tags and character encoding to the latest ID3 standard.

If you already have a jpg with the album art you can insert it into the mp3 files now (see below).

Open Quod Libet, refresh or rebuild your collection, right-click on the new albums and fix their tags, track numbering etc. If some songs inside a whole album are badly tagged, use the CDDB lookup to fix it. Quod Libet can also organize the file and folder names once you learn how to set it to your tastes.

Fetching the album art

You can ask Quod Libet to download it and choose which one you want, it will appear in the same folder as the song.

You can also ask Listen and Banshee, it will appear in ~/.cache.

If they all fail to get a nice picture, you can try Album Cover Art Downloader.

Yet you can search in albumart.org and finally in google images. 200×200 or 300×300 files with 90% jpg compression give reasonably sized files, about 1% of the mp3 size.

Saving the album art

“Standards are very good. Everyone has their own.” The only de facto standard that will robustly and gracefully survive copying your folders around, copying between different operating systems etc, is embedding the images inside the mp3 files.

Fortunately EasyTag is very good at it:

Inside EasyTag, select the folder whose files you want to port the image. Select all the files and open the tab “Pictures”. Drag your picture from Nautilus and drop it in this area, click on the little checkbox on the right, so that it applies for all selected songs. Click on “Save All”. Le voilà.

An advise

Start moving your library slowly until you get familiar with Quod Libet and EasyTag.

Sources

http://www.williambrownstreet.net/wordpress/?p=50&page=2 http://code.google.com/p/quodlibet/ http://easytag.sourceforge.net/ http://www.listen-project.org/ http://banshee-project.org/ http://lifehacker.com/397258/find-and-embed-album-art-in-your-mp3-collection http://lifehacker.com/software/mp3/alpha-geek-whip-your-mp3-library-into-shape-part-i–level-the-volume-230105.php http://www.unrealvoodoo.org/hiteck/projects/albumart/

Posted in Uncategorized | Leave a comment

Getting ç instead of ć with Gnome Desktop and Qt applications

Edit: Since Ubuntu 12.04 this has no longer been an issue with the layout “English/US/Alternative International”.


You just came from Windows and you simply don’t understand why you get this horrible ć rather than ç, even if you choose US-International keyboard layout. I don’t understand either.

But it’s easy to fix.

GTK applications

Backup and edit your X11 input configurations:

sudo cp  /etc/X11/xinit/xinput.d/none /etc/X11/xinit/xinput.d/none-backup$RANDOM
gksu gedit /etc/X11/xinit/xinput.d/none

Select the right GTK input module by editing the GTK_IM_MODULE line:

GTK_IM_MODULE=gtk-im-cedilla

Save, exit.

Now backup your new X11 file; backup your GTK libray configuration file, and open it for edition:

sudo cp  /etc/X11/xinit/xinput.d/none  /etc/X11/xinit/xinput.d/none-backup$RANDOM
cd /usr/lib/gtk-2.0/2.10.0/immodule-files.d/
sudo cp libgtk2.0-0.immodules libgtk2.0-0.immodules-backup$RANDOM
gksu gedit libgtk2.0-0.immodules

Add en to the list of languages where ç is used instead of ć:

- "cedilla" "Cedilla" "gtk20" "/usr/share/locale" "az:ca:co:fr:gv:oc:pt:sq:tr:wa"
+ "cedilla" "Cedilla" "gtk20" "/usr/share/locale" "az:ca:co:fr:gv:oc:pt:sq:tr:wa:en"

Save, exit.

Keep a backup, as GTK updates will overwrite it your file:

sudo cp libgtk2.0-0.immodules libgtk2.0-0.immodules-backup$RANDOM

Log out, log in, open gedit, type ‘ and c. It should give ç. Otherwise reboot.

Other applications

Probably non-GTK applications will still give you ć. To fix that you should change the composing configurations corresponding to your Locale language.

First find out what your environment language is, and if there is a configuration folder with the corresponding name:

cd /usr/share/X11/locale/
printenv LANG
ls

Suppose the output is en_US.utf8 and there is a folder called en_US.utf8. Then backup the Compose file and open it for edition:

cd en_US.utf8
sudo cp Compose Compose-backup$RANDOM
gksu gedit Compose

Do the following replacements:

"ć"   -> "ç"
U0107 -> ccedilla
"Ć"   -> "Ç"
U0106 -> Ccedilla

Save, exit.

Backup your new file:

sudo cp Compose Compose-backup$RANDOM

Reboot.

Gtk applications, without root priviledges

If you don’t have root access, or if you don’t want to give ç to other users, or if you are tired of getting your tweaks overwritten by GTK updates, you can do it at the user level:

echo export GTK_IM_MODULE=cedilla >> ~/.gnomerc

Log out, log in, open gedit, type ' and c. It should give ç. Otherwise reboot.

That’s it.

Posted in Uncategorized | 1 Comment