Archive

Posts Tagged ‘ubuntu’

Ubuntu: xbindkeys to replace Firefox’s clippings extension

June 4th, 2010 4 comments
Number of Views: 126

I’ve been a loyal user of Firefox for years and plan to still use it as my secondary browser (and will use it regularly for Zotero).  But Google’s new browser, Chrome, has really impressed me and I’m going to start using it as my primary browser for email, surfing the web, and every day online activities.  Why is it better?  It’s faster, does a better job rendering flash on Linux, doesn’t require restarts to install extensions, and isolates tabs, so if one crashes it doesn’t kill all of your other tabs.  In short, Chrome has become a better browser than Firefox for everyday browsing.

I had held off switching to Chrome for several months because I was hoping someone would create a Chrome extension similar to clippings for Firefox.  I’m still hoping someone will, but I figured out a way to work around it on Ubuntu Linux.  It’s not for the faint-of-heart or novice computer user, but it does work, and works quite well.  Basically, what I’ve done is installed some software that allows me to paste text into any window, unlike clippings, which only let me paste text into Firefox.

Here’s how you do it:

Ubuntu comes with some cool keyboard shortcuts built in, and includes the ability to customize a lot of those shortcuts.  But it doesn’t come with the ability to paste text as a keyboard shortcut with the default install (learned this here).  In order to do that, you need to install a program called “xbindkeys.”  While you’re at it, you may as well install the GUI for setting the keybindings “xbindkeys-config” and the program you’ll use to generate the text “xvkbd“.  You can install them all at once from the terminal (or find them in the Synaptic Package Manager and install them there):

$  sudo apt-get install xbindkeys xbindkeys-config xvkbd

Once you’ve installed “xbindkeys,” the first thing you need to do is create a default configuration file for it from the terminal:

$  xbindkeys -d > /home/your-user-name/.xbindkeysrc

Once that’s done, go ahead and open the xbindkeys GUI by typing the following at the terminal:

$  xbindkeys-config

This will pull up the xbindkeys GUI:

In here, you can create the key bindings to generate the text you want.  This involves 6 steps.

1) At the bottom of the GUI, select “New”:

A new line in the list of keybindings will appear.  Select it.

2) At the top right, choose a name for the keybinding and put it in the field labeled “Name:”

I don’t know that the name you choose here is particularly important, but you should probably make it something you’ll recognize.

3) Set the key binding.  the xbindkeys GUI includes the ability to capture key combinations.  All you have to do is press the “Get Key” button, wait a second for a small window to pop up, then press the desired key combination (e.g., Control+Mod2+Mod4+1).  The GUI should capture everything for you correctly.  The key combination will be coded into the language xbindkeys understands and will be put in the “Key:” field (e.g., Control+Mod2+Mod4+1 | m:Ox54 + c:10).  What all of the code in the “Key:” field means, I’m not sure, but some of it is explained in the actual configuration file (which you created above; it’s located here: /home/your-user-name/.xbindkeysrc).

4) You then need to tell xbindkeys what to do when you press the key combination you just set up (this is called the “Action”).  In order to paste text into a window, you have to actually call up a different program, which is why we installed it earlier.  That program is xvkbd, an on-screen keyboard program.  You won’t see the keyboard when you press the key combination, but it does generate the text for you.  Here’s the command you use in the “Action:” field to generate text:

xvkbd -xsendevent -text “your text here

The first part “xvkbd” opens the xvkbd program.  The second part “-xsendevent” tells it to send an event to the X window. The third part “-text” tells it what type of event – text.

A couple of notes on the text you can include using this command are in order.  First, you can put pretty much anything you want inside the quotes, except additional quotes, which the program doesn’t seem to recognize are quotes inside the quotes.  So, don’t try quotes inside quotes.  You can also include things like “Return” and “Tab.”  I couldn’t figure out how to do that initially, which is why I ended up writing this tutorial.  What I wanted to include in the text I was pasting was the text I usually include in my email signature:

Best,

Ryan

I was able to include the text, but couldn’t figure out how to include the line break.  So, what I was initially getting when I pressed my key combination was:

Best,Ryan

I initially thought, erroneously, that the command for “Return” would be included in xbindkeys list of commands.  Nope.  The command for “Return” is part of xvkbd.  I eventually found it on that software’s website: \r.  So, if you want to create something like an email signature with a line break, here’s how it would look:

xvkbd -xsendevent -text “Best,\r\rRyan”

Note I’ve included two Return commands (i.e., “\r\r”) as one will just return me to the next line.  I needed 2 for a blank line between “Best,” and “Ryan.”

5) You’re not quite done at this point.  I found the GUI for xbindkeys to be a bit buggy.  Before you do anything else, you should hit the buttons “Apply” and “Save & Apply & Exit”:

This will close the program, but it will also make sure that everything you just typed in will be saved in the configuration file.  I have 5 different keyboard bindings for text I use regularly, 3 email signatures and 2 other text snippets.  I created the first email signature, then started on the second and the GUI crashed, losing all my work.  So, just hit the “Apply” and “Save & Apply & Exit” button after every keyboard binding you create just to be safe.

6) Test it.  Open up a file or browser and try your keyboard combinations.  If the text is pasted in – voila, you’re done.  If not, well, you did something wrong or, well, who knows.  The nice thing about this approach is that it is browser agnostic – it will paste your text into any browser or any other text input box for that matter.

Notes:

There are a couple of additional things you should do with xbindkeys before you’re done.  First, a nifty keybinding that is included in the default configuration file is “CONTROL+SHIFT+q”, which opens up a list of all of your current keybindings:

This isn’t all that important to know, but it is a nice little feature.

You should also know that you can edit your configuration file by hand, though doing so is a bit tricky as the code for the key combinations isn’t all that intuitive.  To do so, use the following command at the terminal:

$ gedit /home/your-user-name/.xbindkeysrc

Finally, once you’ve gotten everything working, if you want to make sure xbindkeys starts when you boot your computer, add it to the Startup Applications: “System -> Preferences -> Startup Applications”

Categories: technology Tags: ,

Ubuntu: Resizing Virtual Screen in X11

April 22nd, 2010 1 comment
Number of Views: 98

Thanks to a little surplus grant money, I was able to purchase a nice, large, external monitor for my office.  With my docking station, that meant I could use two monitors simultaneously – my laptop monitor and my external monitor.  I had been doing this previously, but the external monitor I had before was about the same size as my laptop monitor (15″), so setting it up using dual monitors in Ubuntu was relatively easy.  But the new monitor is, well, huge (28″) and has a much higher native resolution – 1920×1200 vs. 1024×768.  I had two problems when initially trying to set up my new dual monitor system.  First, X11 wasn’t correctly detecting the possible resolutions for the monitor – it only allowed resolutions up to 1024×768.  Second, X11, when I first set up the dual monitor system, created a default virtual monitor that was 2048×768, which basically meant that I couldn’t go any larger than that.  As it turns out, solving the second problem solved the first problem for me.  Keep in mind that I’m using Ubuntu 9.04 on my laptop because of some other X11 problems that 9.10 had when I first tried it out.

Here’s how I solved this.  In a terminal, I input the command to modify the X11 configuration file:

$ sudo gedit /etc/X11/xorg.conf

Technically you should always back this up before you mess with it, but I didn’t this time around as I knew I was just going to change one thing and figured I could always change it back if there was a problem.

In the “screen” section of the xorg.conf file, it said:

Section “Screen”
Identifier    ”Default Screen”
Monitor        ”Configured Monitor”
Device        ”Configured Video Device”
SubSection “Display”
Virtual    2048 768
EndSubSection
EndSection

I changed the settings for “virtual” to: 2944 1200, which is the maximum width and height of my new monitor combined with my laptop monitor (width – 1920+1024=2944; height – 1200 encompasses 768, so I went with 1200).  So my new xorg.conf file looked like this:

Section “Screen”
Identifier    ”Default Screen”
Monitor        ”Configured Monitor”
Device        ”Configured Video Device”
SubSection “Display”
Virtual    2944 1200
EndSubSection
EndSection

Once I changed this, I logged out, then logged back in.  Then using the “Display” tool (System->Preferences->Display), I selected my 28″ monitor and found that the maximum resolutions were now available.  I chose the correct one – 1920×1200, and hit apply.  Et voila, my dual monitors are now using their maximum resolution.  I think the video card in my laptop is freaking out trying to handle this resolution, but it works!

Categories: technology Tags: ,

Ubuntu: Securely Erase Hard Drive with “shred”

January 17th, 2010 No comments
Number of Views: 268

On Windows, I used the free program Eraser to wipe hard drives when I was finished with them. I looked for a while for something similar for Ubuntu Linux but couldn’t find any programs like Eraser.  Turns out, however, that this functionality is built into the operating system, though it is command-line only.  Here’s an example of the command with an explanation following:

# shred -vfz -n 100 /dev/hda

Here’s what this does.  The # sign is the command prompt.  “shred” is the command that tells the operating system that you want to not only erase all the files on the drive but also to over-write those files with random bits.  The “f” in the “-vfz” command forces the write by changing the permissions on the drive wherever necessary.  The “z” in the “-vfz” command writes zeros to the drive.  The “-n” command is followed by a number (“100″ in the example above).  This tells the operating system how many times to write random data to the drive.  The more times you write over the data you had on the drive, the lower the odds that someone will be able to recover your files.  Writing over your data 100 times is likely overkill; 3 to 5 times is how many times I typically wrote over data using Eraser (which does the same thing).  Finally, the “/dev/hda” portion of the command tells the computer which drive to wipe.

If you are wiping your primary drive, you’ll need to boot into Ubuntu (or some other brand of Linux) using a live disc then open a terminal and type the above command.  Otherwise, the primary hard drive will be from where the operating system is running,which means you won’t be able to issue the command.  There is, apparently, a disc image you can download that makes wiping the primary drive quite easy: Darik’s Boot and Nuke or DBAN.  It’s basically like booting using the live disc, but the sole purpose of DBAN is to wipe the drive.

If you’re wiping an external drive, you just need to know the letter of the drive, and can then swap that out in the command (e.g., “/dev/hdc” or “/dev/hds”).  You can figure this out by looking in the “dev” folder or by using gparted.  Just make sure you get the right drive; you don’t want to try wiping your primary drive or any other important information.

For those reading this who don’t know why you would want to securely delete your files, here’s the rationale: just deleting files on a hard drive doesn’t mean someone can’t recover them.  I’ve recovered deleted files for students from their hard drives and from thumb drives numerous times; it just requires a little technical know-how.  This is much more difficult using EXT4, the Linux file system, but quite easy using NTFS, the default file system of Windows (or FAT32). But there are things you can do to pretty securely erase files from a hard drive.  What this program does is erase the files on the drive and overwrite that data with random data.  You would do this if you: (1) had files on your drive you deleted that you don’t want anyone else to be able to recover; or (2) you were giving away or selling your hard drive to someone else (e.g., on Ebay) and didn’t want them to have access to any of your files.  I did this to the hard drive of a laptop I recently sold on Ebay to ensure that they couldn’t recover my data.

Oh, and one more thing, the above instructions come from here.  I reposted them here with additional instructions so I’ll have it for future reference.

Categories: technology Tags: ,

Ubuntu: How to save handouts in OpenOffice Impress as PDFs

September 6th, 2009 2 comments
Number of Views: 159

I’m not a computer programmer (sometimes I wish I was), so I’m going to guess that implementing the ability to save handouts as PDFs in OpenOffice.org’s Impress (OpenOffice’s version of Powerpoint) may be a very challenging programming task.  For those who have never used OpenOffice, one of its greatest features is the built-in ability to save documents as PDFs.  You can save your slides in Impress as PDFs, but if you want to put multiple slides on one page with lines for notes for your students (which is what I do with my discussion notes), there isn’t a way to directly export those handouts as PDFs.  You can customize the handouts, which is a very nice feature, but you can’t save them to PDF.

However, there is a way to work around this limitation.  It’s actually quite simple, but it took me about 30 minutes to figure out.  So, here’s another Ubuntu how to.

First, you need to install a PDF printer in Ubuntu.  This is actually quite easy, though I recommend you do it from the command line as it is even easier this way.  So, pull up a terminal and type:

sudo apt-get install cups-pdf
mkdir ~/PDF
sudo chmod u+x,a+x,+s /usr/lib/cups/backend/cups-pdf
sudo /etc/init.d/cups restart

(I found the above here.)

What does the above do?  First, it installs the CUPS PDF printer.  Second, it makes a directory in your “home” directory called “PDF,” which is where the PDF printer will send your documents when they are printed.  Third, and this is the part that is difficult to do from anywhere other than the command line, it adds access to the CUPS PDF printer to your User.  If you don’t do that, you can’t access the printer.  The last line simply restarts the CUPS printer.

You now have done the hardest part.  The next part is simply to set up your handouts in OpenOffice Impress:

Impress PDF - 01

Once you’ve done that, go up to “File->Print”.  Choose the “PDF” printer.  Then choose “handout” in the middle of the window and how many slides you want per page:

Impress PDF - 02

When you’re ready, hit “OK”.  Now, go check the “PDF” folder in your “home” directory and you should see a PDF there with the handouts.  Voila!  You can now create PDFs of handouts in Impress.

Notes:

1) You can set the printer to print in color by clicking on the “Properties” tab.  It’s set to print in “grayscale” by default.

2) You can also set the PDF printer as the default printer in Ubuntu.  Go to “System->Administration->Printing.”  You should see the PDF printer.  Right-click it and set as default.

3) Microsoft’s Powerpoint can’t do this either.  You have to install a PDF printer in Microsoft’s Powerpoint to achieve the same effect.

4) I have received an error after doing this before.  Apparently there was a “security” issue in that the PDF printer didn’t have some rights to access files.  The error said “cups-insecure-filter.”  I fixed this using these directions:

Open a terminal and type the following:

sudo chown -hR root /usr/lib/cups/filter
sudo chown -hR root /usr/lib/cups/backend
sudo chgrp -hR root /usr/lib/cups/filter
sudo chgrp -hR root /usr/lib/cups/backend

Categories: technology Tags: ,

Ubuntu: Getting Streamzap PC Remote Control working with Ubuntu and Boxee

August 21st, 2009 No comments
Number of Views: 179

We periodically watch videos from the internet on our TV.  I found a cool piece of software that is getting a lot of attention – Boxee.  It’s pretty slick, though not without it’s bugs (it is beta software and free, though, so I can’t complain).  In the spirit of true American laziness, once I realized Boxee would work on our computer connected to our TV I decided I wanted to try a remote to control Boxee.  I found a remote that says it works with Linux – the Streamzap PC Remote.  I ordered it from Amazon.com and once it arrived I faced the next issue: getting it to work with Linux.

The Streamzap ships with software for Windows, but no software for Linux.  Like most of Linux, support for the hardware is mostly built in or provided via open-source software packages. It isn’t the easiest thing in the world to set it up, so I’ve documented here how to do it so I have a future reference and for others (based on these instructions).

First, install the “lirc” package using the Synaptic Package Manager (or “sudo apt-get install lirc” in the terminal).

lirc - 01

Once the install is complete, a window will pop up asking for the remote and some additional information.  Fill everything out, selecting the Streamzap PC Remote.

Once the install is complete, you can test to see if the remote is working by plugging it into a USB port, starting a terminal, and typing the following at the prompt:

irw

If the remote is working, when you push a button you should see an indicator in the terminal that the button was pushed.  If you see indicators, LIRC is communicating with your remote and your remote is communicating with your computer, like this:

lirc - 02

Now, you need to tell LIRC which buttons should do what in which programs.  You can use a program to help generate the requisite scripts.  Install “mythbuntu-lirc-generator” from the Synaptic Package Manager (or “sudo apt-get install mythbuntu-lirc-generator” in the terminal).

Once installed, type “mythbuntu-lirc-generator” in the terminal and it will generate LIRC files for several programs.  It puts a “.lircrc” file in “/home/USER/”.  That file indicates that the generated scripts are installed in “/home/USER/.lirc”, which is a hidden folder in your user folder.  Here’s what the files says:

#Custom lircrc generated via mythbuntu-lirc-generator
#All application specific lircrc files are within ~/.lirc
include ~/.lirc/mythtv
include ~/.lirc/mplayer
include ~/.lirc/xine
include ~/.lirc/vlc
include ~/.lirc/xmame
include ~/.lirc/xmess
include ~/.lirc/totem
include ~/.lirc/elisa

You can modify these for the Streamzap Remote Control.  I modified one, totem, to give it added functionality.  My version is included in the zip file linked to below.

If you want to use the remote in Boxee, you have to install Boxee, then find the Boxee remote file in “/home/USER/.boxee/UserData”.  The file is called “Lircmap.xml”.  You need to add the following to the file:

<remote device=”Streamzap_PC_Remote”>
<pause>PAUSE</pause>
<stop>STOP</stop>
<forward>&gt;&gt;</forward>
<reverse>&lt;&lt;</reverse>
<left>LEFT</left>
<right>RIGHT</right>
<up>UP</up>
<down>DOWN</down>
<select>OK</select>
<pageplus>CH_UP</pageplus>
<pageminus>CH_DOWN</pageminus>
<back>EXIT</back>
<menu>MENU</menu>
<title>PLAY</title>
<info>More</info>
<skipplus>&gt;&gt;|</skipplus>
<skipminus>|&lt;&lt;</skipminus>
<display>Teletext</display>
<start>Home</start>
<record>RECORD</record>
<volumeplus>VOL_UP</volumeplus>
<volumeminus>VOL_DOWN</volumeminus>
<mute>MUTE</mute>
<power>POWER</power>
<myvideo>Videos</myvideo>
<mymusic>Music</mymusic>
<mypictures>Pictures</mypictures>
<mytv>TV</mytv>
<one>1</one>
<two>2</two>
<three>3</three>
<four>4</four>
<five>5</five>
<six>6</six>
<seven>7</seven>
<eight>8</eight>
<nine>9</nine>
<zero>0</zero>
<mytv>RED</mytv>
<mymusic>GREEN</mymusic>
<mypictures>YELLOW</mypictures>
<myvideo>BLUE</myvideo>
</remote>

If you want to just use my files, here they are.

<lircmap>
<remote device=”Streamzap_PC_Remote”>
<pause>PAUSE</pause>
<stop>STOP</stop>
<forward>&gt;&gt;</forward>
<reverse>&lt;&lt;</reverse>
<left>LEFT</left>
<right>RIGHT</right>
<up>UP</up>
<down>DOWN</down>
<select>OK</select>
<pageplus>CH_UP</pageplus>
<pageminus>CH_DOWN</pageminus>
<back>EXIT</back>
<menu>MENU</menu>
<title>PLAY</title>
<info>More</info>
<skipplus>&gt;&gt;|</skipplus>
<skipminus>|&lt;&lt;</skipminus>
<display>Teletext</display>
<start>Home</start>
<record>RECORD</record>
<volumeplus>VOL_UP</volumeplus>
<volumeminus>VOL_DOWN</volumeminus>
<mute>MUTE</mute>
<power>POWER</power>
<myvideo>Videos</myvideo>
<mymusic>Music</mymusic>
<mypictures>Pictures</mypictures>
<mytv>TV</mytv>
<one>1</one>
<two>2</two>
<three>3</three>
<four>4</four>
<five>5</five>
<six>6</six>
<seven>7</seven>
<eight>8</eight>
<nine>9</nine>
<zero>0</zero>
<mytv>RED</mytv>
<mymusic>GREEN</mymusic>
<mypictures>YELLOW</mypictures>
<myvideo>BLUE</myvideo>
</remote>
Categories: technology Tags: ,