PDFs Opening in Gimp after Default Install

June 20, 2013 Leave a comment

I ran into another problem with my Debian install (see previous post). When I click a PDF in Chromium, it opens Gimp! I’m fairly confident that is not what anyone wants.

Because I do not run a fancy desktop environment, there did not appear to be an obvious way to fix this. However, after some research, the following worked:

$ mkdir -p ~/.local/share/application
$ xdg-mime default evince.desktop application/pdf
Advertisements
Categories: Uncategorized

Reinstalling Debian on Existing LUKS+LVM Partition

June 19, 2013 3 comments

Today, I reinstalled Debian on an external hard disk with a LUKS+LVM encrypted volume. Two requirements:

  • I did not want my /home logical volume touched.
  • I did want all other logical volumes to be formatted.

While I recall doing this years ago without much trouble, the current Wheezy Debian installer took some tinkering.

When I got to the partitioning screen, my encrypted volume was not detected. (I found this a little odd, because if I booted the USB stick I was using in rescue mode, I was automatically prompted for my password.)

Moreover, when I switched to another VC to mount the volume manually, I found that cryptsetup was not available. http://wiki.debian.org/DebianInstaller/Rescue/Crypto was helpful, but it did not quite do the trick. (I tried to update the page, but I could not seem to recover my old account. Will have to save that for another day.) The following worked for me:

# anna-install cryptsetup-udeb partman-crypto-dm
# depmod -a
# cryptsetup luksOpen /dev/sdc1 asdf
# vgchange -ay asdf

Then, I went back to the installation VC, and asked it to configure the logical volume manager. Until I did this, it would not detect the existing file systems on the logical volumes. I was then able to select which LVs to format and which to keep, as well as where to mount everything.

(By the way, I was installing over WPA-encrypted wifi and found it necessary to manually install wicd-curses during setup. None of my wifi settings were saved during installation, so the initial boot did not have internet access. I could not find networkmanager either and am too impatient for wpa_passphrase. All of this may have been the result of only installing the standard system utilities task.)

At any rate, the installation unfortunately did not write /etc/crypttab (and then generate initramfs) for me like it does when you create and install a new LUKS+LVM during a typical installation. Therefore, grub gave me an error on the initial boot and I had to manually unencrypt and activate the LVs.

# cryptsetup luksOpen /dev/sdb1 asdf
# vgchange -ay asdf

Then ctrl+d to start the boot process. Once it has booted, I edited /etc/crypttab and added something like the following:

asdf UUID=[UUID of physical device holding LUKS+LVM partition] none luks

Then I regenerated initramfs

# update-initramfs -u -k all

Everything worked fine for me on reboot. HTH

Categories: Uncategorized

Print recent pidgin messages

March 14, 2012 Leave a comment

Below is a command I use once in a while to print the last few lines of any pidgin log modified in the past 24 hours. I find it useful if I am logged in remotely to a machine currently running pidgin. Also, it sometimes happens that I am unable to review new messages before pidgin closes due to a variety of unexpected circumstances, such as power outages.

$ find ~/.purple/logs \
> -type f \
> -mtime -1 \
> ! -wholename '*/.system/*' \
> -print0 \
> | sort -z \
> | xargs -0 tail \
> | less -RF

Obviously, it makes sense to assign an alias to this long command.

Categories: Uncategorized Tags: , ,

Weather Alias

July 8, 2011 Leave a comment

I use a quick alias to get weather conditions and a 7-day forecast from NOAA. I found the links for my current location at http://mobile.weather.gov/.

$ grep weather .bashrc
alias weather='(w3m -dump -cols 80 "http://mobile.weather.gov/port_mp_ns.php?select=3&CityName=Minneapolis&site=MPX&State=MN&warnzone=MNZ060"; w3m -dump -cols 80 "http://mobile.weather.gov/port_mp_ns.php?select=1&CityName=Minneapolis&site=MPX&State=MN&warnzone=MNZ060") | less -F'

I’d invest more time in making the output less wordy, but the layouts at http://www.weather.gov/ seem to change quite a bit.

Categories: Uncategorized Tags: , ,

Adduser or Useradd?

June 17, 2011 Leave a comment

I always used to get adduser and useradd mixed up. My trick now is that adduser sounds like more natural English, which reminds me that it is the more user-friendly of the two.

Categories: Uncategorized

Pidgin Audio in Chroot

May 30, 2011 Leave a comment

I run pidgin in an unstable debian chroot. Sound never really worked. Until now I had been too lazy to figure out why and instead just had it call mplayer. All other sound applications in the chroot work normally. Anyway, I got it to work today by installing gnome-media and gstreamer0.10-alsa :P

Categories: Uncategorized Tags: , ,

Downloading Chat Logs from GMail

August 17, 2009 Leave a comment

Update (Summer 2013): Google has again disabled IMAP access to chat logs with their introduction of Hangouts.

Update (2011/9/16): It appears chat logs are back in IMAP! (Settings->Labels->Check “Show in IMAP” for “Chats”)


GMail disabled access to chat logs via IMAP some time ago. At that point, I stopped using the GMail interface and started using Pidgin. Unfortunately, I unknowingly logged 2098 chat conversations on GMail servers between the moment GMail disabled access and my realization they had done so. (I was not using IMAP during this period, but assumed the functionality was still there and that I would download them all for safekeeping at some point.) Below is the process I used to recover these data.

I should mention that while this task succeeded, it was quite a messy process. Keep in mind that the alteration of code on Google’s side could render useless any and all steps listed below. :(

First, I tagged all of my chat logs with an arbitrary label (“cl”), since this appears to be the only way to get them to show up in GMail’s HTML mode.

I then made sure GMail was set to display 100 conversations per page and downloaded the conversation indices. GMail reported a total of 2098 chat conversations. The random string below appears to change from user to user and possibly from session to session. It can be determined by looking at URLs in HTML mode.

$ cd tmp
$ for st in `seq 0 100 2098`; do w3m -dump_source "https://mail.google.com/mail/h/[random string]/?s=l&l=cl&st=$st" > index.$st.html 2>> index.log; sleep .$(($RANDOM % 3))$(($RANDOM % 9)); done

Next, I scraped the indices for links to chat conversations and downloaded these links. Again, you may have to look at URLs to find the appropriate random string.

$ grep -h '?v=c&' index.*.html | sed 's/<a href="\(.*\)">/\1/' | while read u; do w3m -dump_source "https://mail.google.com/mail/h/[random string]/$u" > "con.$u.html" 2>> con.log; sleep .$(($RANDOM % 3))$(($RANDOM % 9)); done

I then downloaded the plain text chat transcripts. Careful, Google temporarily disabled my account after the loop below grabbed about 1500 conversations. You may want to increase the sleep time. Notice the bold string changed again…

$ cat con.*.html | grep -h '^<a name="m_.\+"></a>' | sed 's/^<a name="m_\([[:alnum:]]\+\)"><\/a>$/\1/' | while read th; do w3m -dump_source "https://mail.google.com/mail/h/[random string]/?v=om&th=$th" > trans.$th.txt 2>> trans.log; sleep .$(($RANDOM % 3))$(($RANDOM % 9)); done

So I then had each conversation in a file. The next step was to put these in a maildir.

$ mkdir -p maildir/tmp maildir/new maildir/cur
$ for f in trans.*.txt; do tail -n +2 "$f" | sed 's/^M$//' | perl -e 'use MIME::Words qw(decode_mimewords);while(<>){if($_=~/^Subject: (.*ANSI_X3.*)$/){$r=decode_mimewords($1);print "Subject: $r\n"}else{print $_}}' | perl -e 'use utf8;use Encode;while(<>){if($_=~/^Subject: (.*) \?\?\?\?\?\?\?\?$/){print "Subject: ",encode("MIME-Header","$1 さんとのチャット"),"\n"}else{print $_}}' > "maildir/cur/$f"; done

What a mess. The plain text version of the messages has a blank line at the top, so I used tail to filter it out. They also have DOS newline characters. I am not sure if GMail or w3m added these on, but they were easily removed with sed. Remember to type Ctrl+v <enter> to insert the ^M above. Google also appears to have some bugs in the MIME header code for chat logs. Several conversations took place during a period when GMail was set to present a Japanese interface, so I had to dig out the Perl for this.

Categories: Uncategorized Tags: , , , , ,