Thursday, 21 February 2008

Nautilus scripts

Here's a nautilus script that I find very useful! If you find yourself zipping or tarring a lot of files, this will save you lots of time!

I miss the right-click zipfile functionality that I used to get in Windows from the winzip add-on. With Nautilus, you can make up your own scripts and drop them in the scripts directory. They appear on the right-click context menu under "Scripts". You won't see this menu if you have no scripts yet.

It's easy to use:
  1. Copy the following text into ~/.gnome2/nautilus-scripts/tar-bzip2-here
  2. make it executable: `chmod u+x ~/.gnome2/nautilus-scripts/tar-bzip2-here`
  3. right click a file / folder that you want to archive, or select multiple files and right click on one
  4. select "Scripts > tar-bzip2-here"
  5. If you've selected multiple files, you will be prompted for an archive name. Otherwise, the file name will be selected automatically.
  6. A message appears saying "The archive should now be ready". You will find it in the same folder that your original files were in.
Easy and time saving! No more terminals just to tar -cf blah; bzip blah blah!

Here's the code. Copy it exactly (use cut-n-paste):
version 0.2, updated on March 7, 2008

#!/usr/bin/perl -w

#
# tar-bzip-here version 0.2
#
# This program is free for whatever use you want. You break it you get to keep
# the pieces! I would appreciate fixes / improvements being sent back to me.
#
# Changlog:
# 0.2: quote filenames so that certain characters don't confuse bash, such as
# "(". Some more error messages.
# 0.1: initial release
#
use strict;

#my $logfile = '~/tar-bzip2-here.log';
# my @NAUTILUS_SCRIPT_CURRENT_URI = split /\s/, $ENV{'NAUTILUS_SCRIPT_CURRENT_URI'};
my @NAUTILUS_SCRIPT_SELECTED_URIS;
if (defined $ENV{'NAUTILUS_SCRIPT_SELECTED_URIS'}) {
@NAUTILUS_SCRIPT_SELECTED_URIS = split /\s/, $ENV{'NAUTILUS_SCRIPT_SELECTED_URIS'};
}
else {
`zenity --error --text "Run this from nautilus!"`;
die "Run this from nautilus!\n";
}


#`echo > $logfile`;

my @files = ();
foreach my $file (@NAUTILUS_SCRIPT_SELECTED_URIS) {
next unless defined $file;
chomp $file;
if ($file !~ s|^file://||) {
`zenity --error --text "I don't know how to handle the URI '$file'"`;
#`echo 'skipped $file' >>$logfile`;
next;
}

$file =~ s/(%..)/&unq($1)/ge;
# `echo 'ok: $file >> $logfile`;
push @files, "\"$file\"";
}


my $numfiles = $#files + 1;
my $fname;

#`echo 'files are @files'>>$logfile`;
# if mixed files and dir, then ask for archive name
if ($numfiles > 1) {
$fname = `date +%Y%m%d`; chomp $fname; $fname .= '.tar.bz2';
$fname = `zenity --file-selection --save --confirm-overwrite --filename=$fname --title="Select a name for the archive"`;
chomp $fname;
&end ("Cancelled by user") unless ($fname ne '');
}

# if single file or directory, then compress to dirname.tar.bz2
elsif ($numfiles == 1) {
$fname = "$files[0].tar.bz2";
}

else {
&end ("You need to select some files in nautilus to use this script");
}

# now tar a bzip2!
`tar -c @files | bzip2 > "$fname"`;
#`echo 'tar -c @files | bzip2 > "$fname"'>>$logfile`;

# done!
`zenity --info --text "The archive '$fname' should now be ready"`;

# functions
sub unq {
my ($percent) = @_;

if ($percent eq '%20') { return ' '; }
elsif ($percent eq '%20') { return ' '; }
else {
&end ("Don't know how to handle '$percent'");
}
}

sub end {
my ($err) = @_;
`zenity --error --text "$err"`;
die "$err";
}

Friday, 25 January 2008

Gentoo 2008.0

So it's no secret that I use Gentoo. If you've been following the rumours lately you would think that Gentoo is in strife. Daniel Robbins made lots of people believe that there were project, legal, developer, and direction issues. Most of his facts appear to be correct, however I cannot agree with his conclusions.

The State of New Mexico NFP status is not a big deal - sure it's a little embarrassing, but papers got lost, people got preoccupied, and now the papers have been re-filed[1]. Sure the council has had a few resignations, but a new council will be instated, followed by elections, followed by a better process for ensuring it doesn't happen again.

Sure there wasn't a release in 2007 - but there were various security concerns and a breakdown in communication. What you may not realise is that Gentoo doesn't need regular releases, because the entire system of packages goes through a constant upgrade cycle anyway. For example, when I used to install Redhat and then Fedora, major releases would usually introduce a new major Gnome or KDE version. Without the new release CD, you wouldn't be able to get a lot of new packages. Even with the new release CD, Fedora would often blow away my filesystem anyway. With Gentoo, KDE 4.0 is currently in the tree, and people are successfully installing and using it.

Nevertheless, a new release is on the way[2]. Pencilled in for final release in mid-march, there are a lot of new features and processes. Including linux kernel 2.6.24[3], if testing goes well. A new security discussion has been set up, so that Release Engineering knows what the issues are directly.

The final issue, IMHO is the communication between devs and users. They will never completely agree on everything, but that's a fundamental difference that shouldn't be changed. At the least there should be some communication - and the releng looks to be addressing that too. There is a new mailing lists to help new developers (gentoo-dev-help), a user survey planned, and a call for comment on the new release[4].

So Gentoo is not perfect, nor is any distribution. At least from what I've seen over the last few days is they continue to learn from mistakes, which means the will continue to improve and grow.

[1] http://archives.gentoo.org/gentoo-nfp/msg_01347.xml
[2] http://www.gentoo.org/news/20080123_releng_beta.xml
[3] http://www.gentoo.org/news/20080125-2.6.24-kernel.xml
[4] http://www.gentoo.org/news/20080124_releng-feature-request.xml

Tuesday, 18 December 2007

A new office

Along the lines of my other workplace stories:

I work for a software, electrical and mechanical style company. My part has always been software related, so where I work is not always important. With the exception of the occasional PLC to program, or switchboard to test, I can work from home, work, plane etc. We've suggested before that the software "arm" of 3 - 4 people move closer to the city, freeing up some space for other employees that need to be near our workshop. This has always been knocked back straight away though.

Recently things have been looking up for the company in general, which is good news. However, I hear rumblings that the MD / GM type people want to open a new office close to the city - coincidentally in the same suburb that these people live... I wonder if there will be enough room for me, but then do I want to work there (given who will be in the same office...)?!

Dear Mum

Here's a poem that I wrote (I think - I found it on my computer) for Mother's Day last year. One of the problems of having a bad memory is that I can't even remember my own blunderings... Anyway, I'll retain copyright on it until someone finds the original. I seem to recall putting it in a Mother's Day card. Feel free to use it (for non-commercial use :)

Dear Mum,
Today's a special day for you,
A day we tell you how much we care
For all the things you've done for use
From clean clothes to brushed hair!

So today let us look out for you
We'll clean up, wash up, smile
But it's not just Mother's Day that counts,
We'll do this every while!

Wednesday, 21 November 2007

Geek Code

It's been around for a long time, but is it dead?  Well, maybe.  Anyway here's mine updated:

-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/MU d? s++: a- C+(++++) UL++++ P+++>+++++$ L+++$ E+ W++ N !w t@ tv++ b++
DI++++ G h r+++ y++++
------END GEEK CODE BLOCK------

 
Copyright 2009 Another Blog. Powered by Blogger Blogger Templates create by Deluxe Templates. WP by Masterplan