Installing Firefox 3.5.2 (Shiretoko) on Ubuntu using the default repos and customizing the icon to be more recognizable

When Firefox 3.5 came out, I along with many others, was eager to try it. For a while I ran it out of the archive directly but this caused minor issues as it’s a messy solution. At some point I noticed firefox-3.5 in the repository:

tyler@quadjutsu:~$ apt-cache search firefox |grep 3.5
abrowser-3.1 - dummy upgrade package for firefox-3.1 -> firefox-3.5
abrowser-3.1-branding - dummy upgrade package for firefox-3.1 -> firefox-3.5
firefox-3.1 - dummy upgrade package for firefox-3.1 -> firefox-3.5
firefox-3.1-branding - dummy upgrade package for firefox-3.1 -> firefox-3.5
firefox-3.1-dbg - dummy upgrade package for firefox-3.1 -> firefox-3.5
firefox-3.1-dev - dummy upgrade package for firefox-3.1 -> firefox-3.5
firefox-3.1-gnome-support - dummy upgrade package for firefox-3.1 -> firefox-3.5
firefox-3.5 - safe and easy web browser from Mozilla
firefox-3.5-branding - Package that ships the firefox branding
firefox-3.5-dbg - firefox-3.5 debug symbols
firefox-3.5-dev - Development files for Mozilla Firefox
firefox-3.5-gnome-support - Support for Gnome in Mozilla Firefox

and proceeded to install it with the following command:

tyler@quadjutsu:~$ sudo apt-get install firefox-3.5

It runs along-side Firefox 3.0 without a hitch. I often use the two in tandem while testing web applications.

Something that bothered me about this was the default icon isn’t as recongnizable to me as I’d like it to be.

screenshot-about-shiretoko

As such I looked into a way to replace it.

First, I found a replacement icon I liked

hp-firefox-128x128

from the following website (where other nice replacements exist).

Then I went to find the logical location of the files to replace. First I updated my ‘locate’ database file because this software is new, so it’s not yet known. This is done automatically daily on a cron but you can update it any time you’d like as follows:

tyler@quadjutsu:~$ sudo updatedb

Then I probed for icons I might think would be responsible.

tyler@quadjutsu:~$ locate firefox |grep lib |grep icon |grep 3.5
/usr/lib/firefox-3.5.2/icons
/usr/lib/firefox-3.5.2/chrome/icons
/usr/lib/firefox-3.5.2/chrome/icons/default
/usr/lib/firefox-3.5.2/chrome/icons/default/default16.png
/usr/lib/firefox-3.5.2/chrome/icons/default/default32.png
/usr/lib/firefox-3.5.2/chrome/icons/default/default48.png
/usr/lib/firefox-3.5.2/icons/document.png
/usr/lib/firefox-3.5.2/icons/mozicon128.png
/usr/lib/firefox-3.5.2/icons/mozicon16.xpm
/usr/lib/firefox-3.5.2/icons/mozicon50.xpm

The first set in the ‘/usr/lib/firefox-3.5.2/chrome/icons/’ folder will replace the icons used by the application itself (i.e. the icon in the top of your window). The latter, ‘/usr/lib/firefox-3.5.2/icons/’ will replace the ones used by shortcut icons.

Here are all the files for the icons I resized if you’d like to use them.

firefox-3.5_replacement_chrome_icons.zip
firefox-3.5_replacement_shortcut_icons.zip

bash pro-style:

cd Desktop/ && mkdir firefox_replacement_icons && cd firefox_replacement_icons
wget http://www.doknowevil.net/files/firefox-3.5_replacement_chrome_icons.zip && wget http://www.doknowevil.net/files/firefox-3.5_replacement_shortcut_icons.zip
for file in *.zip; do unzip $file; done
sudo cp chrome/* /usr/lib/firefox-3.5.2/chrome/icons/default/
sudo cp shorcuts/* /usr/lib/firefox-3.5.2/icons/

Finding the difference in time between the first and last file in a folder using bash

I was working on running some statistics on log files and it required me to figure out the difference to increase the accuracy. I came up with the following bash script:

#!/bin/bash
# get the dates
start_date=$(date --utc --date "$(ls -Rt --full-time | tail -n1 | awk '{ print $6 }')" +%s)
end_date=$(date --utc --date "$(ls -Rt --full-time | head -n2 | tail -n1 | awk '{ print $6 }')" +%s)
 
# find the difference
difference=$((end_date-start_date))
 
# echo results
echo $end_date - $start_date = $difference seconds
echo $((difference/86400)) days

Which I originally wrote as a one liner:

start_date=$(date --utc --date "$(ls -Rt --full-time | tail -n1 | awk '{ print $6 }')" +%s); end_date=$(date --utc --date "$(ls -Rt --full-time | head -n2 | tail -n1 | awk '{ print $6 }')" +%s); difference=$((end_date-start_date)); echo $end_date - $start_date = $difference seconds; echo $((difference/86400)) days;

I got a little carried away and created this beast, which still isn’t as accurate as I need it to be but it did give me some information:

map_1=nordiccastle;map_2=dance;start_date=$(date --utc --date "$(ls -Rt --full-time | tail -n1 | awk '{ print $6 }')" +%s); end_date=$(date --utc --date "$(ls -Rt --full-time | head -n2 | tail -n1 | awk '{ print $6 }')" +%s); difference=$((end_date-start_date)); echo $... Read Moreend_date - $start_date = $difference seconds; echo logs for $((difference/86400)) days; map_1_ended=$(find -name *00*.log | xargs egrep -A 4 "endmatch|timelimit -1" |grep $map_1 |wc -l); map_1_played=$(find -name *00*.log | xargs egrep "gamestart" |grep $map_1 |wc -l); echo $map_1 endmatched $map_1_ended out of $map_1_played times played; map_2_ended=$(find -name *00*.log | xargs egrep -A 4 "endmatch|timelimit -1" |grep $map_2 |wc -l); map_2_played=$(find -name *00*.log | xargs egrep "gamestart" |grep $map_2 |wc -l); echo $map_2 endmatched $map_2_ended out of $map_2_played times played

It was used to see how many times a map was played and how many times it was voted to end the match.

It should really be a separate script to allow for more organization

feh – lightweight command line image viewer and data tool

While I was looking for a better image viewer than the default ‘eye of gnome’ (eog from the command line), that’s able to play animated gifs, I came across a command line tool called feh

sudo apt-get install feh

feh is is lightweight image viewer that you can call from the command line. It can recursively view files with the following command for example:

feh -r *.jpg

You can navigate through the images with your arrow keys or space bar and backspace. Use the window close button or press esc to quit.

That’s all good and fun and I’ll probably use it from time to time but it’s not what really got me excited about this tool. It has an option for a “list” of image attributes as the screenshot below shows.

screenshot3

By typing for example

feh -l *.jpg

I would list all attributes for jpgs within a specified directory. In my screenshot, I had a text file multiple image extensions, so I did a subshell with an ‘ls’ command piped to ‘grep -v’ which negates whatever pattern that follows it. To rephrase, the command inside $() is run first and that list which has all files minus those ending in ‘.txt’ is called by the ‘feh -l’ command.

I find this very helpful for when I’m slicing images for web pages. When I’m typing out css for example:

#my_image {
  display:block;
  height:25px;
  width:120px;
  background:transparent url('img/my_image.png') 0 0 no-repeat;
}

it’s very handy to have the image dimensions. The nice thing about this raw dimension output is that I can script it further to generate CSS like above.

There are many other tricks this command can do, just type ‘man feh’ to learn more.

By the way, I’ve started using gThumb as my default image viewer, it’s still lightweight and quite powerful. It’s essentially the same as eog with some minor differences and a few major enhancements

sudo apt-get install gthumb

Generating sequences of numbers or characters with bash

If you ever needed to generate a sequence of characters or numbers, the terminal (using bash) is a quick and easy way to do it. Lets explore some examples bash’s brace expansion:

$ echo {a..z}
a b c d e f g h i j k l m n o p q r s t u v w x y z

by defining a start and end character with the ‘..’ in between, we tell bash to fill in the rest and echo a list for us. Those are all lowercase, what if you wanted uppercase? simple:

$ echo {A..Z}
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Or both, with a few extra characters in the mix:

$ echo {A..z}
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [  ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z

It doesn’t always have to be a-z though,

$ echo {A..G}
A B C D E F G

This also works with numbers:

$ echo {0..9}
0 1 2 3 4 5 6 7 8 9
echo {0..100}
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

Descending as well as ascending

$ echo {9..0}
9 8 7 6 5 4 3 2 1 0

There is another method to generate a sequence of numbers from the command line, rightfully called ’seq’

$ seq 1 5
1
2
3
4
5

The difference here is that it’s delimited by a new line, however, we can override that with the -s (seperator) flag

$ seq -s " " 1 10
1 2 3 4 5 6 7 8 9 10