Tag Archives: ubuntu

Two-Finger Scrolling Unavailable—Not

So I’m using a different laptop.  It has a touchpad for mousing around, and on the touchpad are arrows indicating you are able to use edge scrolling.  This laptop is new enough it presumably has two-finger touch sensitivity, yet for whatever reason Unity’s System Preferences showed “Two finger scrolling” as greyed.

I prefer two-finger scrolling and thus I poked around the Webz to see what I could see.

I found this question asked and answered which had a solution to enable two-finger scrolling.  Essentially the solution (work-around really) is a collection of three commands which enable two-finger scrolling (why it is greyed is another matter for another time).

I tested it and it worked on my machine (a Lenovo w500) as well.  Great.

As advised in the article one could add those three lines as part of one’s start-up scripts (.bashrc in most cases), but I was feeling differently.  First I consolidated those three lines into one line using double-ampersands.  Then I created an alias called touchpad which contained those three-now-one lines of code.

Confusedly, this work-around only remained effective until the machine went to sleep.  I would understand any logout, but you’ll see from the code that this effects X and X must relaunch after sleep (or at least changes state enough to reset this).

Checking the man page for alias (which I had to find on-line as my bash in Ubuntu 14.04 doesn’t have it) I found that I could make an alias persist (or at least make it get recreated) by adding it to my .bash_aliases file in my home directory.

Now it works great.  I have added that alias to each user account I use on this laptop so it is easy to call.  Perhaps one day I’ll add the work-around elsewhere so I won’t have to instantiate it, but for now I have this.

Below you will see the code I used.  I hope this helps you today.

##
#!/bin/bash
# by JamesIsIn from JamesIsIn.com
# Do something nice today.

# Here is my alias. The code between the single quotes is what you would need if your aim was merely to test-fix your touchpad.

alias touchpad='xinput --set-prop --type=int --format=32 "SynPS/2 Synaptics TouchPad" "Synaptics Two-Finger Pressure" 4 && xinput --set-prop --type=int --format=32 "SynPS/2 Synaptics TouchPad" "Synaptics Two-Finger Width" 8 && xinput --set-prop --type=int --format=8 "SynPS/2 Synaptics TouchPad" "Synaptics Two-Finger Scrolling" 1 0'

# Here is my .bash_aliases file.

cat .bash_aliases
# command to enable two-finger scrolling

alias touchpad='xinput --set-prop --type=int --format=32 "SynPS/2 Synaptics TouchPad" "Synaptics Two-Finger Pressure" 4 && xinput --set-prop --type=int --format=32 "SynPS/2 Synaptics TouchPad" "Synaptics Two-Finger Width" 8 && xinput --set-prop --type=int --format=8 "SynPS/2 Synaptics TouchPad" "Synaptics Two-Finger Scrolling" 1 0'

##
Share

Tweak Opera to Befriend Transmission

I use Opera as my main browser and I use Transmission as my torrent client.  The problem begins that Opera is its own torrent client.  Nothing wrong with that except that I want Opera to pass torrents over to Transmission instead.

There are really two operations that you need to consider in dealing with torrents today.  The first is to inform Opera what you want done with .torrent files; the other is to inform Opera what you want it to do when it encounters a so-called Magnet Link.

With the torrent file you are probably already familiar.  It’s a tiny file containing just enough identifying information for your torrent client to participate in the torrent for which you seek.  Is that too esoteric?  Well, that’s because it is.  It’s about as interesting as the number you pull out of that thing at the DMV and wait.  Sure it’s important because it’s necessary, but you’re just going to throw it away.

The Magnet Link obsoletes the torrent file.  A Magnet Link passes the needed number, the hash (which is all the torrent file really carries) directly to the torrent client.  (Here is good article on magnet links with links to a potentially useful script.)

Since we can’t guarantee that all sites will use one or the other we want to address both of them.

Getting Opera to pass .torrent files to your torrent client is a simple matter of changing that particular file association in Opera itself.  This way when you click on a torrent file link you are done.  I have mine set up to ask me what to do.  I like it that way.  You should be able to set it up to open them directly with the information which follows if you are so inclined.

Torrent File Modification

There are three things to note in making this alteration.  You want to make this in the Downloads section  of the Preferences dialog.  You want to ensure that the “Hide file types opened with Opera” check box is unchecked.  And finally if you sort by extension (by clicking File extension(s)) you can just roll down to T to select torrent.  Click the Edit button (duh!).  Pick the option you prefer for this file extension.

(If there is no torrent entry, and there ought to be, you can add one using the MIME type and File extension you see in the image above.)

Magnet Links are working (see Update below).  The other bit, the Magnet Link, I haven’t sorted out as yet.  Transmission supports Magnet Links as of version 1.9 or so (and I’m using a supported version).  Here is how I have my Opera preferences arranged:

Magnet Link Modification
Magnet Link Modification

For this I went into Programs (also in the Preferences dialog) and clicked the “Add…” button.  The Protocol is magnet, of this I am certain.  I also believe that my shortcut to Transmission is called out correctly.  (If you are using a different client, modify accordingly.)  And yet I get this error when I attempt to use a Magnet Link: You should no longer get this error if you follow the Update directions below.

Magnet Link Error
Magnet Link Error

Bummer. No bummer here.

I tried using %s, %u, and no modifier.  Without a modifier the link does nothing.  With either %s or %u I get the above error message.  I’ll update this post as I am able to figure this out.  In the meantime prefer torrent links.

Clearly these instructions are for Ubuntu (well, that may not be clear to everyone), but there ought to be enough information here for you to sort it out for Mac or Windows.

Happy torrenting.

(Firefox users will find this link useful.)

Update:

As of the release of Opera 11.10 magnet links are working.  You will want add /usr/bin/transmission into the Open with other application box and put %s into the Parameter box.

Share

Script for Skipping Tracks

I use Rhythmbox to play music on my hi-fi system.  There is a command line element for Rhythmbox called rhythmbox-client.  This element can be used to initiate a series of commands in Rhythmbox.  The problem is that these commands end up being a bit longish if you are attached to that machine via ssh.  Here is an example:

DISPLAY=:0.0 rhythmbox-client –play-pause

That’s a lot of typing especially when you are attached via ssh from your Android phone.  It was just too tedious to type all that out on that on-screen keyboard.  So I wrote a script that would manage the arguments I felt were most important.

##
#!/bin/bash
# by JamesIsIn from JamesIsIn.com
# Do something nice today.


   if [ "$1" = "n" ]; then
      argument="--next --print-playing"
      printf "\nI am skipping to the next track:\n\n"
   elif [ "$1" = "p" ]; then
      argument="--play-pause"
      printf "\nI am toggling between play and pause.\n\n"
   elif [ "$1" = "s" ]; then
      argument="--print-playing"
      printf "\nThis is what is currently playing:\n\n"
#   if [ "$1" = "q" ]; then
#      $argument="--enqueue"
   else [ argument = "" ]; 
      printf "\nI'm sorry.  I only understand the following commands:\n\n"
      printf "p (play/pause)\n\n"
      printf "s (show what's playing)\n\n"
      printf "n (skip to next track)\n\n"
      printf "Please try again.\n\n"
      exit
      # I could add --enqueue but I have to figure out to make it work
   fi


# assuming DISPLAY does not matter for local runs (though this is for a single monitor configuration)

DISPLAY=:0.0 rhythmbox-client $argument
echo


exit

##

The use of DISPLAY is required so that rhythmbox-client knows on which monitor Rhythmbox is present.  The configuration above is for a single monitor arrangement.  You’re on your own to figure out what you need in there if you have a different monitor configuration.

So, using my script, if you wanted to issue the same command I mentioned above you would merely type:

Rb p

(Now I just need to streamline the ssh command and this whole procedure will be much easier and thereby more impressive.)

I placed this script in /usr/local/bin on the hi-fi machine. I called it merely Rb. That way the script is available to all users on that machine. Be sure to make the file executable:

sudo chmod a+x /usr/local/bin/Rb

(Since I use my server as a proper server now I moved my script to the share: /media/[share]/Rb so that it would be available across the network.)

Have fun with that.

Share

BASH Examples

I have been earnestly studying BASH for a while now, but I recently came across something that will be very useful and I thought I’d pass it along.

Famously enough I run Ubuntu (a Debian-based distribution of Linux).  This is where I do my scripting in BASH, though I also use BASH on my Mac (native) and Windows (through Cygwin).

I have discovered a package called bash-doc which contains a plethora of BASH example scripts and code chunks.

To install bash-doc you just mark it for installation in Synaptic and Apply that change.

  • System —> Administration —> Synaptic Package Manager
  • Scroll down to locate bash-doc
  • Right-click on bash-doc and select Mark for Installation
  • Click the Apply button
  • Double-check the package you are installing and click OK

Alternatively you could enter this simple line of code directly into BASH via the terminal: sudo apt-get install bash-doc (your password will be required either way).

Once you have installed this package you will find a host of examples:

/usr/share/doc/bash/examples/

Have fun with that.  I know I will.

Share

Backup Script: A Love Story

I have written a few backup scripts by now. Every time I do I find a new interesting challenge somewhere in the task. As such I’d like to talk a little about my most recent backup script and offer my script to the community at large.

First of all, I tend to use rsync for backups. It’s powerful and it works well. You can use rsync to backup any file system and so it is also very flexible in a network or on a virtual machine. I’m not going to dive into the man page for rsync, but you will want to take a look there (man rsync) because there is a wealth of information about the various switches available for that command. I have selected the switches that fit my purposes and that is what is displayed below.

Next, where possible I prefer to leave my backup drives unmounted until they are actually needed for the backup process. I consider my current system for dealing with this imperfect, but again that is what you will see in my current script.

Finally, the server I have written this script for is running the desktop version of Ubuntu. This is not likely important in any way except that (as you will see) if I had been running the server version I would not likely have had the same problems when I did my test run.

Ok, so here is my current script.

##
#!/bin/bash
# Simple Back Up Script
# by JamesIsIn from JamesIsIn.com
# Do something nice today.


# run in cron Mondays at 4 AM
# [0 4 * * 1 /home/[scriptpath] >/dev/null 2>1]

# redirect from script --> sends all STDERR to log file

exec 2> /home/[username]/Desktop/$(date +%Y%m%d)
## 2> routes standard error as well as standard output together the rest uses a dated folder at the specified location



## backup [DriveA]


if ! mountpoint -q /media/[BUDriveA]
then
   mount -t [filesystem] -U [UUID goes here; no brackets or quotes] /media/[BUDriveA]
fi

# Note rsync -a copies permissions but will not copy owner:group if not run as root

rsync -ailS --delete --progress /media/[DriveA]/[Folder] /media/[BUDriveA]

umount /media/[BUDriveA]


## backup [DriveB]


if ! mountpoint -q /media/[BUDriveB]
then
   mount -t [filesystem] -U [UUID goes here; no brackets or quotes] /media/[BUDriveB]
fi

# Note rsync -a copies permissions but will not copy owner:group if not run as root

rsync -ailS --delete --progress /media/[DriveB]/[Y] /media/[BUDriveB]
rsync -ailS --delete --progress /media/[DriveB]/[Z] /media/[BUDriveB]

umount /media/[BUDriveB]

#

As you can see I like to keep my scripts well documented. I encourage you to do the same. Memory is fallible, after all.

(Note: Everything in square brackets [] will be replaced in your script.)

[filesystem]

This is where you specify the file system type you are using and is called out by the -t argument. For my script it was ext3.

[UUID]

This is a unique identifier for a drive and it is called out by the -U argument. I prefer using UUID’s because other drive/partition designations can change (for instance, sda1 can become sdb1 if you add a new drive). (For information on adding drives to your system see this post.)

My backup script manages the backups for three directories (recursive) over two drives. I first test to see if a backup drive is mounted and if it is not I mount it. That’s the job of the if statements. (This is what I consider imperfect and will seek to improve as time moves forward.) It works well enough, and if you don’t want your backup drives to be mounted all the time this is a decent way of dealing with the matter.

You will also note that I unmount each drive as I finish with it (umount).

You will also see that in the DriveB example I backup (synchronize) two directories (Y & Z). This also helps to make it clear that you do not need to specify the name of the directory at the backup location.

Lastly, you see my note about -a copying permissions and requiring root to copy also the owner and user information. As such I put this script into a cron job as root.

What?

It’s easy enough to do. Just open cron as root:

#
#
sudo crontab -e

You will be prompted for your password. You can learn more here. You can see my cron entry for this script in a comment in my script above. The man page for cron (man cron) will help you understand how 0 4 * * 1 means every Monday at four in the morning.

Let’s talk about some of the mistakes I made.

The first big snag was not having the if statements correct. I left out the UUID’s and so the script did not mount the drive for the first sync operation. The if statement tested to see if DriveA was mounted and found that it was not. Then it ran the mount command which failed because no valid drive (UUID) was specified.

Because the drive was not mounted at the mount point rsync began synchronizing data to the mount folder and not the mounted drive. This caused the script to fail (once the OS drive containing / was full—about 105 GB later) and borked the / partition.

I was not able to restart Gnome (Gnome, the desktop environment, requires some free space on your / partition to function and mine was 100% full). I ssh’d into the machine from a Windows box nearby (using Cygwin) and maybe two hours later I sorted out what I had done. I was able to remove (using the rm command) the offending folder after making absolutely certain DriveA was in fact not mounted. After that I was able to reboot and get back into Gnome. (However, I did have to run fsck on the drive probably due also to the drive having filled itself. If you boot your system and get a shell stating you cannot login try running fsck and answering y to all the fixit questions.)

Oops. This is why we make test runs, right?

So I fixed the if statements (specifically the mount and umount commands) and that took care of that.

Then the script ran fine through the backup for DriveA but finished DriveB in a few seconds. Not possible. I looked back at the script and realized that I had specified the backup location for both the source and the destination. Damn it. Fixed that and DriveB was synchronizing properly.

I hope this helps you out.

(Thanks to Ian over at the Ubuntu Forums for his suggestions while I was troubleshooting.)

Happy scripting.

Share

Don’t Lose Your Grip

You may recall my article on using the wonderful Gnome ripping software Grip.  You didn’t read it?  Well, you ought to.  It’s right here.

As fortune would have it, this particular application has been languishing as concerns development.  That is to say that it’s a bit out of date and is using archaic libraries.  As such, or so I am told, Grip has been dropped from the Ubuntu repositories with 9.10 and I see nothing to indicate it will be returning with 10.4 either.  Woe is me.

Now I did find one person who took the time to arrange a repository and installation script all his own.  You can find that over on the Ubuntu forums:

http://ubuntuforums.org/showpost.php?p=8759491&postcount=25

It’s a bit of command line work, but it’s easier than compiling the program yourself.

You should report any troubles you might have on that forum post as you are likely to get faster responses.

Share

Go Do that Gnome-Do that You Do so Well

Gnome-Do is an application launcher, among other things.  It is the fastest, slickest application launcher I have found for any platform.  It was originally designed after Spotlight from the Mac operating system.  However, it has outclassed its predecessor entirely.

With a couple of key-strokes I can launch any application on my system.  Or I could open a folder location.  Or I could just as easily search for something which came to mind.  Or I could use Gnome-Do to access the inner workings of many different applications on my system through its extensive plugins.   Or I could search the Internet.  Or I could search my del.icio.us bookmarks.

Pretty much anything I could imagine.  Just a few key-strokes.

It’s like magic.  I’m surprised Sarah Silverman doesn’t have a show about it.

If you are running Ubuntu (and you ought to be by now), Gnome-Do is available through Synaptic and the standard Ubuntu repositories.  However, if you would like to latest version of Gnome-Do you can add their repositories directly.

Open your repositories (System —> Administration —> Software Sources) and add these two entries (Third-Party Software tab; Add button):

[CODE=HTML]

deb http://ppa.launchpad.net/do-core/ppa/ubuntu [YourVersionHere] main

deb-src http://ppa.launchpad.net/do-core/ppa/ubuntu [YourVersionHere] main

[/CODE]

(Substitute your version as appropriate.  I am running 8.10 and 9.10 so I use intrepid and karmic, respectively.)

You’ll also want to add the verification key for this repository.  The simplest way to do that is by running two commands (Applications —> Accessories —> Terminal):

[CODE=HTML]

sudo apt-key adv –keyserver keyserver.ubuntu.com –recv-keys 77558DD0

sudo apt-get update

[/CODE]

If you are already running Gnome-Do, you can now update your system (System —> Administration —> Update Manager) and you will get the latest version.  If you need to install Gnome-Do, hop into Synaptic (System —> Administration —> Synaptic Package Manager) and look for it by name.

You will have to start Gnome-Do manually before you can use it (Applications —> Accessories —> GNOME Do) and I set it to auto-start (located in its Preferences dialog, which is where you will also find its plugins).

I believe by default you call up Gnome-Do by using cltr-alt-space.  I have a Microsoft keyboard and so set mine to super-space (Windows-space).  You can choose something you like and which is convenient for you.

Have fun with this.  You’ll wonder how you ever got by without it.  And you will sincerely miss it when you are working on other operating systems.

Thanks to this post for the repository information.

Share

Stitch Some AVI’s Together

So you have that video of your cat doing that thing and that other video of your brother getting startled by the can of joke peanuts, and now you’re thinking “I’m such a wicked director I’m going to edit these films together and put them on the Interwebz”.  Ok.  That sounds important.

In Ubuntu there is a little utility called avimerge which (wait for it) merges avi files.

[BASH]##
#
avimerge -c -o [WhatYouWantItCalled].avi -i [a].avi [b].avi

#[/BASH]

I know; you’re thinking “dude, that looks like something you type into the terminal window; how am I supposed to do this?”.  Fear not, little tomato.  You just want to replace the stuff in the square brackets with your stuff.  A and B are the two files you are wanting to merge and WhatYouWantItCalled is, well, I think you can manage that one.  Yours might look like this:

avimerge -c -o ScorseseMe.avi -i CuteKitty.avi BroJumps.avi

If your file names have spaces you’ll have to tell the shell (the terminal) how to interpret them:

[BASH]##
#
avimerge -c -o “Scorsese Me.avi” -i “Cute Kitty.avi” “Bro Jumps.avi”

or

avimerge -c -o Scorsese\ Me.avi -i Cute\ Kitty.avi Bro\ Jumps.avi

#[/BASH]

(The quotes tell the shell to interpret what comes between them as a single item or word; normally words are space-delimited and here the quotes prevent the command from interpreting the space as the end of the file name. The slash is what is known as an escape character; the character which follows the escape character is escaped and thus not interpreted by the shell but read just as another character.)

Could it be any easier?

Have fun with that.

Share

Returning Encryption to the Latest Ubuntu

Older versions of Ubuntu included a space for each user, encrypted by default and decrypted as that user logged in, under the home area within the folder hierarchy.  The most recent version of Ubuntu (9.04) does not include this feature out of the box.

I rather like this implementation.  Each user has a secure folder-space which is continually encrypted and protected from access by even other local users (though administrators would still have the power to access the user’s account by changing the password and then logging in as that user).  Its simplicity is where this shines.

Essentially, for those unfamiliar, under your Home directory there will be a folder called Private.  That folder and its contents are stored in an encrypted format (using a special file system) and are only decrypted as that user logs into the machine.  Simple and effective, I was rather surprised to see it removed from the latest release.

As fortune would have it this feature is very easy to re-implement for anyone using the newest release of Ubuntu.  It’s merely two lines of code into a terminal (Applications —> Accessories —> Terminal):

  • sudo aptitude install ecryptfs-utils
  • ecryptfs-setup-private

(Thanks to this page at Ubuntu for the information.)

Happy hunting.

Share

My Pidgin Ain’t Yodelling Today

Ah, the sounds of Spring…

Well, yeah, it’s the middle of summer but never mind that.  I have been having difficulties with my Yahoo connections.  I don’t use their bulky, rancid chat client.  No, I use a multi-protocol chat client.  My preferred client is Trillian but it doesn’t run perfectly on Wine (a Windows emulator I use in Ubuntu), so sometimes I bite the bullet and run Pidgin.

Pidgin is an open-source option for the multi-protocol chat clients.  Allow me to explain that for the uninitiated in the audience.  Pidgin is a program that allows one to interact within many chat venues—like Yahoo! and Windows Live and AIM—without having to run the proprietary software generously foisted on us by those behemoths.  (Pidgin also publishes its source code for all to enjoy.)

Of course those behemoths would prefer each of should use their chat client, adore the ads they place before us, and sacrifice our first borns on the alters of their corporate ledgers. But I digress.

These companies sometimes make changes to the manners in which their clients interact with their servers.  Standard operations for them.  Plays occasional havoc for the developers of applications like Trillian and Pidgin (and Adium).

Anyway, my Pidgin hasn’t been able to consistently connect to Yahoo for some time now.  After the usual research I found a couple of articles which finalized the problem (here and here).  Basically, Yahoo has changed its authentication method and Pidgin hasn’t caught up quite yet.

I went ahead and installed the beta version of Trillian Astra (their newest client, currently in beta) on my Ubuntu machine using Wine, but there are problems with the visual displays within those Trillian windows (specifically the contact list) which make it effectively unusable.

Hopefully the folks at Pidgin will be able to get this sorted out soon.  Alternatively, the folks at Wine might get the issues with Astra sorted out too.

Share