July 12, 2012 0

Restore Dropbox Shell Extension in Nautilus for Gnome3

Dropbox works great on linux, but at some point the shell extension stopped working for me. The shell extension provides little icons over all the files in your dropbox folder indicating their status, and (more importantly in my opinion) the dropbox context menu which lets you link to files, especially those in your Public folder. Here is how you can manually install the very latest version of dropbox-nautilus for your version of Ubuntu.

Add the dropbox linus repository

echo "deb http://linux.dropbox.com/ubuntu $(lsb_release -cs) main" | sudo tee "/etc/apt/sources.list.d/dropbox.list" > /dev/null

Add the dropbox public key

sudo apt-key adv --keyserver pgp.mit.edu --recv-keys 5044912E

Get an updated repository list

sudo apt-get update

Get the latest source code for nautilus-dropbox

sudo apt-get source nautilus-dropbox

Install of the of the necessary dependencies

sudo apt-get build-dep nautilus-dropbox

Install some packages necessary for compiling software in general

sudo apt-get install build-essential dpkg-dev

Change directory into the directory created for your source code, mine was labelled "dropbox-1.4.0"

cd nautilus-dropbox-0.6.7/

The README and INSTALL files are good to review at this point, they go over the basics and details of installation this package.

Following the README, we'll first configure the package.

sudo ./configure

Next we'll compile it with make.

sudo make

And finally we'll install.

sudo make install

At this point we have installed the latest version of nautilus-dropbox from source. We'll have to stop all running instances of nautilus and then reopen it to see our changes.

killall nautilus

That's it! Just run nautilus, or open your file browser as you normally would and you should have the latest version of dropbox's shell extension up and running.

Tags:

June 22, 2012 0

Converting m4a to mp3 with ffmpeg on linux

We're going to write a quick script that will convert m4a files to mp3 files. FFMPEG is actually quite flexible though so if you have different file formats that need to be converted you can probably just swap them in without any other modifications. First things first, install some dependencies

sudo apt-get install ffmpeg libavcodec-extra-53

This installs ffmpeg and the libraries which allow you to work with mp3 files, among other codecs. It should be noted that libavcodec-extra may change or get updated after the time this article was written, so it'd be best to type "libavcodec-extra" and then hit tab to have the appopriate library name autocompleted for you.

Next we're going to write a quick shell script which runs "ffmpeg -i input_filename.m4a -ab 256k output_filename.mp3" for each .m4a file in the current directory. I'm entering mine into a file called m4a2mp3.sh and placing that file into the same directory as the .m4a files that I want to convert.

#!/bin/bash
for i in *.m4a
do
ffmpeg -i "$i" -ab 256k "${i%m4a}mp3"
done

The -ab argument stands for audio bitrate and controls the quality of the output file. You can specify any number of the common bitrates, from 64k all the way up to 128k, 256k, 192k, 320k, etc. Check the man page for specifics as needed.

Give the file execute permissions and run it to convert all files in the directory.

chmod +x m4a2mp3.sh
./m4a2mp3.sh

After you've gotten this script working, if you'd like to have it remove the original files as it converts, you can ammend the script like so:

#!/bin/bash
for i in *.m4a
do
ffmpeg -i "$i" -ab 256k "${i%m4a}mp3" && rm "$i"
done

Careful though, if the conversion fails or doesn't turn out as you expected, you may lose your originals. Always keep backups!

Tags:

June 22, 2012 0

Download all files from directory listing with wget

If you run across a directory listing of files that you'd like to download all at once, you can use a couple wget arguments to help you. Use -m to enable mirroring (equivalent to -r -N -l info --no-remove-listing) and --no-parent to prevent wget from recursing up directories. This command will download everything in the current directory and all directories below it.

wget -m --no-parent http://example.com/path/to/files/

As usual, run man wget for more information.

Tags:

April 27, 2012 0

Send text to clipboard in linux terminal

What we'd like to do is have a quick way of sending text to the clipboard from terminal in linux. We can accomplish this with pipes and xclip. We'll install and configure xclip and then review the proper usage.

First we install xclip:

sudo apt-get install xclip

Next we want to configure an alias for xclip so that the arguments "-selection c" are used every time we call xclip. This ensures that the text is piped (copied) into the correct clipboard. This command will place the alias specification into the .bashrc file in our home directory.

echo "alias xclip=\"xclip -selection c\"" >> ~/.bashrc

Now we need to load our new .bashrc settings into the current window or open a new window.

source ~/.bashrc

Now we can use xclip as follows:

uptime | xclip

In my case I like being able to copy my public keys directly from file into github, so I use it like so:

cat ~/.ssh/id_rsa.pub | xclip

Tags:

August 2, 2011 9

Linux and sharing, so awesome it just might be illegal

I'm a huge GNU/Linux fan and I like to think of myself as a FOSS advocate. So I chose an image of Tux to emblazon on my new credit card. There is some opaque process for determining which images can be used and which cannot, due to licensing issues. Unfortunately my image was flagged and denied, falling under "Celebrities such as actors, musicians, athletes, or cartoons." Now certainly Tux may be a celebrity, but that doesn't mean I can't use his glorious image! I mean, look at that mug!

Tux Credit Card

So not wanting to give up, I call in to appeal the decision. That's when things got funny:

Me: The image on the card is a cartoon penguin named Tux. Not like a cartoon you'd see on television though. He is the Linux mascot. Are you familiar with Linux?

Capital One CS: No response.

Me: Linux is a free, open source operating system for your computer. It is free to use, modify, share or sell. The image is free to use. I know it can be a funny concept for some people.

Capital One CS: Ok, and the organization is?

Me: ... There is no organization, Linux can be freely downloaded, used and modified by anyone, no one necessarily owns or controls it.

Capital One CS: And this is legal?

Me: *chuckles* Yes, it certainly is.

How about that? I've heard of people receiving this exact response before, but it is absolutely stunning to hear it myself. What does that say about our culture? Especially the culture in technology and software. It is certainly disappointing, but I will admit, there is a part of me that feels a glowing pride, knowing that Linux is so awesome, so mind bending to the common person, that hell, it might not even be legal. These days, let's ensure that it remains that way.

Tags:

July 24, 2011 2

UDev rules for Android Development on Motorola Triumph

In short, the published Vendor ID for Motorola is not correct for the Motorola Triumph. Instead of 22b8, use 0489. When we connect our android device to the computer via USB for development purposes, we have to set a UDev rule which specifies how the system should be allowed to access that device. For this purpose we can refer to the Android Developer Docs. These docs give instructions for Ubuntu users. You need to make sure you're using the correct location for the rules file for your distribution. You can can see at the arch wiki, the location for udev rules is /etc/udev/rules.d/.

So to enable our Motorola Triumph android phone for development we must add the following to /etc/udev/rules.d/51-android.rules (again, check for your distribution's docs for the correct udev rules location)

SUBSYSTEM=="usb", ATTR{idVendor}=="0489", MODE="0666", GROUP="plugdev"

Once you save this file UDev should automatically load in your new rule, but you will have to unplug and reconnect your phone in order for the new rule to take effect.

Now browse to the platform tools folder of your sdk (In my case /opt/android-sdk/platform-tools/) and run adb to ensure your device is properly recognized, like so:

$ ./adb devices
List of devices attached
FD1M1019202100 device

Without the proper UDev rule, your Triumph will not be mounted with the correct permissions and neither your nor your Eclipse SDK will be able to access your phone properly. Running adb without the proper UDev rule will yield something like this:

$ ./adb devices
List of devices attached
???????????? no permissions

In order to determine the vendor id and product id of a phone, connect it to your computer (the previously mentioned UDev rules do not have to be in place), and run lsusb and find your phone amongst the devices listed.

$ lsusb
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:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 002: ID 0bda:0158 Realtek Semiconductor Corp. USB 2.0 multicard reader
Bus 002 Device 003: ID 5986:01a6 Acer, Inc Lenovo Integrated Webcam
Bus 001 Device 016: ID 0489:c001 Foxconn / Hon Hai

In this case we're interested in the last one, named "Foxconn / Hon Hai". The Vendor ID and Product ID directly precede the name and are separated by a colon. For example, in the case of this particular Motorola Triumph, the Vendor ID is 0489, and the Product ID is c001. To save yourself time and frustration, take a moment to run this command when you're creating your UDev rules to ensure you have the proper ID's for your particular device.

July 22, 2011 4

Fix Spotify playlist URL’s in Ubuntu / Linux / Gnome 3

Spotify has a great linux client but I had trouble getting Spotify playlist URLs to load properly. When you a click a spotify URL in your browser it utilizes xdg-open to determine which application should be launched. I'm running Ubuntu 11.04 with Gnome 3, and the following solution worked well for me and is quite elegant.

Enter the following into the file /usr/share/applications/spotify-url.desktop

[Desktop Entry]
Name=Spotify
GenericName=Spotify
Comment=Listen to music using Spotify
Icon=spotify-linux-512x512
TryExec=spotify
Exec=spotify -uri %u
Terminal=false
Type=Application
Categories=Qt;AudioVideo
MimeType=x-scheme-handler/spotify
NoDisplay=true

Then run the following command to update your desktop database to enable the new command. If successful this command will return silently, without any error or success message.

sudo update-desktop-database

Spotify links should now work! Have a better solution? Having trouble finding a solution for your particular setup, let me know.

Tags: ,

July 18, 2011 12

Disable the Universal Access accessibility menu in Gnome 3

sudo add-apt-repository ppa:webupd8team/gnome3
sudo apt-get update
sudo apt-get install gnome-shell-extensions-noa11y

In the new gnome-shell, otherwise known as Gnome 3, there is an accessibility menu called "Universal Access" that cannot be removed by any apparent means. Fortunately it can easily be removed, hidden, or disabled by editing a file and restarting the shell. This method works for gnome-shell version 3.0 (this reportedly works in Gnome 3.2 as well), it may or may not work in future versions.

Edit the file /usr/share/gnome-shell/js/ui/panel.js

Look for the following line, (line 38 in my case):

'a11y': imports.ui.status.accessibility.ATIndicator,

Comment out this line like so:

//'a11y': imports.ui.status.accessibility.ATIndicator,

Then restart gnome-shell by typing Alt-F2 to run command, enter "r" without the quotes, and hit enter. This will quickly restart the shell and you should find that the Universal Access menu no longer appears. If you should find a use for it in the future, simply un-comment the lines found in /usr/share/gnome-shell/js/ui/panel.js

Thanks to the endlessly helpful folks who maintain ArchWiki for this tip.

Tags:

July 7, 2011 1

Disable the Ctrl-Q quit shortcut in firefox with keyconfig!

This is a firefox extension which allows you to add, modify, remove and disable keyboard shortcuts for Firefox. We're going to use this to disable the pesky shortcut for quitting firefox which is Ctrl-Q. Ctrl-Q is right next to Ctrl-W which is the handy shortcut for closing tabs, and if you hit it by mistake your entire session will be lost; sometimes it vanishes so quickly you don't even know what hit you.

Simply install the extension, restart Firefox, and then open Preferences for keyconfig in the Add-ons section. Then scroll down and highlight the shortcut for Quit and click disable. Voila, no more Ctrl-Q rage.

This extension was created by dorando, and can be found here: http://forums.mozillazine.org/viewtopic.php?t=72994 and here: http://mozilla.dorando.at

According to the forum post linked above, you can support the creator of this extension by donating something towards his hosting bill here: http://www.dreamhost.com/donate.cgi?id=3048

Since this extensions works so well for many people and the only trace of it seems to be a forum post, I've decided to host a mirror of it on my server, just in case. You can find that here: http://conjurecode.com/keyconfig.xpi

Tags:

June 28, 2011 0

SSH Tunnel for MySQL (or anything else) via Port Forwarding

Let's using SSH port forwarding to tunnel a service from a remote server to our local machine. For example, many servers restrict mysql connections to localhost only. Using this technique we can tunnel our mysql connection through the remote machine transparently and securely. Let's set up our example. We have an instance of MySQL running at mysql.remoteserver.com on the default port of 3306. To make things interesting (and perhaps easier to follow), we're going to assume that you're also running an instance of MySQL on your local machine on the same port. So, let's tunnel the mysql connection from the remote server to our local machine on port 3307 so there are no conflicts.

ssh -L 3307:127.0.0.1:3306 user@mysql.remoteserver.com -N

If you're not using public key authentication, you will be prompted for a password. By specifying the -N option, we suppress opening a shell session and your command prompt will merely hang after you've entered your password. This can be safely omitted if you like, and a shell session will be opened for you. You can read more about the ssh command at it's man page.

To connect to our MySQL server, we need to specify our local address and port (Note: Using "localhost" will NOT work in this case, make sure to 127.0.0.1), and the login information for the instance of MySQL on our remote server. In Python you might use the following:

db = MySQLdb.connect(host='127.0.0.1', port=3307, user='myusername', passwd='mypassword', db='databasename')

Tags:

Dedicated Server Hosting by Hivelocity