Much ado about scripting, Linux & Eclipse: card subject to change

Showing posts with label gnome. Show all posts
Showing posts with label gnome. Show all posts

2009-01-30

Do you wanna be open source?



I've got a plan to make code free and open,
Lucky for me, for you it's a cause you can join,
The world is slowly changing,
FLOSS is so contagious

Chorus
I'm willing to code my way to the top,
I wanna be o-pen source,
I don't wanna stick with vendor lock-in,
I wanna be open source

I must confess,
Lin's got too many distros,
Been sleepin around,
Talk of the town,
My name is...

E-clipseCon will beckon,
E-veryone will listen,
Play my vimeo
Check me out on ohloh,
Browsin' through the source, yo
No one ever says no

Chorus

I'm willing to code my way to the top,
I'm a contributor
I'll submit patches, write docs, and test stuff
Make me a committer

My friends... are all... sans Windows
My friends... they all... pronounce the 'g'

I just fixed a bug!

Play my vimeo
Check me out on ohloh,
Browsin' through the source, yo
no one ever says no

Chorus

I'll collaborate my way to the top,
I'm a beta-tester
I'll report problems and suggest features
Help to make better software

Freedom... comes when... the source is free
Freedom... thanks to... community

Play my vimeo, check me out on ohloh
I'm willing to code my way to the top
Browsin' through the source, yo, no one ever says no
I wanna be o-pen source
x2

Are you willing to code your way to the top?
Do you want to be o-pen source?

Darren Hayes - Popular

2009-01-25

Capturing Screenshots Made Easy: Scripting With xfce4-screenshooter

Since moving to Fedora 10 and casting off my old ties to Kubuntu, I've been rather frustrated with the available options for capturing screenshots under Gnome.

I've tried the gnome-screenshot tool, docked as a panel applet, but it only allows me to capture the desktop or selected window. No click-and-drag region select?

When I've needed to capture only a part of my screen or overlapping windows (eg., Eclipse dialogs) I've been forced to capture the whole screen then crop it down w/ GIMP. Or, launch GIMP first and let it do the region capture - but GIMP never remembers my settings from last time, so to capture a region after a 2-second delay, it's 8 clicks every time I start GIMP. Lame.

In both cases, it's cumbersome, and I always have to select the directory where I want to save, and then name the file.

This weekend, I discovered xfce4-screenshooter, which is significantly better in that I can capture an area of the screen and auto-save to a file without needing to specify a filename each time.

It can even redirect the capture to an application or the clipboard rather than a file, and provides all the dialog options as commandline flags so it can be scripted, too.

So, now, I simply wrap that application with a bash script that runs the screenshooter then opens my snapshot folder with Thunar, so I can preview the result with Ristretto or edit it with GIMP if necessary. One click to start the process, one click-and-drag to create the image. And no unnecessary dialog configuration, file system browsing, or clicking!

Here's the scriptlet, which I've set up as a Gnome panel shortcut to run /home/nboldt/bin/snap.sh:

#!/bin/bash
/usr/bin/xfce4-screenshooter -s /home/nboldt/Screenshots/ -h -r && \
  thunar /home/nboldt/Screenshots/ &

And here's my desktop, captured with only 2 clicks:

One might argue that it's too bad that these three tools can't just be merged into one. I'd argue that it's great that if you don't like one tool, you can find two others, each incrementally better than the next. Screenshot integration in GIMP is very handy, as is automatic capture to file (with incremental file naming). And, unlike in the Windows and Mac worlds, if the best tool for the job isn't available for one window system, I can simply cherry pick from another.

Still, nothing beats the feature set and usability of HyperSnap, but that's sadly a closed-source Windows application, and far from free. Proving that in this world, ultimately, you get what you pay for -- but there are some excellent free & open source alternatives.

2008-10-16

Password management with ccrypt

Intro
Server
Client(s)
About ccrypt

For the past few years, the list of passwords I use for all the various websites, servers, and applications has been growing ever longer. Some people limit themselves to 3-4 passwords, or a handful of formulas for password generation. I used to do that, but it's insecure, and when you control the fate of numerous servers, it's irresponsible. These day, I generally create new passwords at random, and replace them every 3-4 months.

Every flavour of linux has its own system for managing passwords; for example, KDE has KWallet; Gnome has Keyring. Tuesday I started playing with Fedora for the first time in years, and discovered yet another way: System > Preferences > System > Authorizations (polkit-gnome-authorization). And, of course, even Mozilla (Firefox, Thunderbird) handles password management like this... but each application has its own repository, and each one will get out of sync in time.

So, for a password management system that doesn't care about window manager, application, or even OS (this works with under cygwin on Windows, too), I've designed my own method.

How do you remember 100s of passwords which have nothing in common? Store them in a database, encrypted by a passphrase/password, then use a simple query engine to retrieve them.

Here's how it works, and how you can set up something similar.

Home Server / CVS Server

First, define these 3 scripts.

  1. /home/user/passwds/PWget.sh
  2. #!/bin/bash
    dir=/home/user/passwds;
    mkdir -p $dir;
    echo -n "Retrieve latest? [y/N] "; read yn;
    if [[ $yn == "y" ]]; then
     scp user@home-server:$dir/passwds.cpt $dir
    fi
  3. /home/user/passwds/PWsearch.sh
  4. #!/bin/bash
    file="/home/user/passwds/passwds.cpt";
    ccrypt -c $file | grep -i "$1";
  5. /home/user/passwds/PWedit.sh
  6. #!/bin/bash
    file="/home/user/passwds/passwds";
    ccrypt -d $file.cpt; vi $file; ccrypt -e $file

Next, define 2 aliases -- one for password lookup, and one to modify the encrypted password file. I use ~/.alias, which I load as part of my ~/.bashrc file.

  1. /home/user/.alias
  2. alias PW='/home/user/passwds/PWsearch.sh $1'
    alias PWE='~/PWDs/PWedit.sh'

Now, on the home server, I can run `PW eclipse` to decrypt the file, look up any lines in the password file with "eclipse" in them, and return those entries to me. Or, I can run `PW | more` by itself to display the entire file (paged with `more`). To modify the file, I use `PWE` to decrypt, edit, and re-encrypt the file. I also periodically save this file into my CVS repository (cvs add -kb passwds.cpt; cvs ci -m "" passwds.cpt) so I can track changes.

Remote Client(s) / Other Servers

Well, you think, that's great for a single system, but I need my passwords on 3 or 4 different systems. Plus, my home server may or may not always be accessible (eg., only when I'm on my home network).

So, once again, we start with the same three bash scripts.

Next, define a different version of the `PW` alias:

  1. /home/user/.alias
  2. alias PW='/home/user/passwds/PWget.sh;/home/user/passwds/PWsearch.sh $1'

Now, on any other server which can reach the home server over ssh, `PW eclipse` can be used to (optionally) retrieve the latest version of the password file, then search it as in the example above. Can't reach the home server? That's fine, we keep a local cache of the encrypted password file -- good enough until the next synch.

Voila! Centralized encrypted password management for Windows & Linux clients!

About ccrypt

So, what handles the encryption, and how secure is it?

ccrypt is based on the Rijndael block cipher, which was also chosen by the U.S. government as the Advanced Encryption Standard (AES, see http://www.nist.gov/aes/). This cipher is believed to provide very strong cryptographic security.

 

If your linux or cygwin distro doesn't include ccrypt in its repositories, here are a couple places you can find it: