“Poner como fondo de pantalla” en GNOME

jueves, 8 de febrero de 2007
Escrito por Neodian a las 10:10
Sin comentarios

Una de las cosas que permite hacer windows y no encontraba en linux era una opcion en el menu contextual, el del boton derecho del raton, para poder poner la imagen que has seleccionado como fondo de pantalla. Pues bien he encontrado un script, de nuevo, que permite hacer esto, y ademas al incluirlo como nautilus-script aparecera en el menu contextual.

Antes de nada aseguraros de tener instalado Gtk2-Perl para que el script funcione correctamente, despues copiais el script y los pegais en ~/.gnome2/nautilus-scripts donde “~” quiere decir vuestro directorio home, en mi caso /home/neodian/.gnome2/nautilus-scripts y deberies darle permisos de ejecucion. El script es el siquiente:

#!/usr/bin/perl
use Gtk2 -init;
use File::Basename qw(basename);
use strict;

my $gconf_path = ‘/desktop/gnome/background’;
my $file = (split(/\n/, $ENV{NAUTILUS_SCRIPT_SELECTED_FILE_PATHS}))[0];
chomp(my $current = `gconftool-2 -g $gconf_path/picture_options`);

my %options = (
‘Tiled’ => ‘wallpaper’,
‘Centered’ => ‘centered’,
‘Scaled’ => ’scaled’,
‘Stretched’ => ’stretched’
);

unless (-e $file) {
my $dialog = Gtk2::MessageDialog->new(undef, ‘modal’, ‘error’,
‘ok’, ‘Error: file not found’);
$dialog->signal_connect(’response’, sub { exit });
$dialog->run;
} else {
my $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file($file);
my $x0 = $pixbuf->get_width;
my $y0 = $pixbuf->get_height;
my $scale_factor;
if ($x0 < $y0) {
$scale_factor = 90 / $y0; # portrait
} else {
$scale_factor = 120 / $x0; # landscape
}
my $preview = Gtk2::Image->new_from_pixbuf($pixbuf->scale_simple(
int($x0 * $scale_factor),
int($y0 * $scale_factor),
‘bilinear’,
));

my $label = Gtk2::Label->new(’Set Background:’);
$label->set_alignment(0, 0);

my $control = Gtk2::OptionMenu->new;
my $menu = Gtk2::Menu->new;
$control->set_menu($menu);

my $i = 0;
foreach my $option (sort keys %options) {
my $item = Gtk2::MenuItem->new($option);
$item->signal_connect(’activate’, sub {
$current = $_[0]->child->get_text
});
$menu->append($item);
$control->set_history($i)
if ($options{$option} eq $current);
$i++;
}

my $dialog = Gtk2::Dialog->new;
$dialog->set_title(’Set Background’);
$dialog->signal_connect(’response’, \&response);
$dialog->set_border_width(8);
$dialog->vbox->set_spacing(8);
$dialog->add_buttons(’gtk-cancel’ => 1, ‘gtk-ok’ => 0);

$dialog->vbox->add($preview);
$dialog->vbox->add(Gtk2::Label->new(basename($file)));
$dialog->vbox->add($label);
$dialog->vbox->add($control);

$dialog->show_all;
$dialog->run;
}

exit;

sub response {
exit if ($_[1] != 0);
system(sprintf(
‘gconftool-2 -t string -s %s/picture_options %s &’,
$gconf_path,
$options{$current},
));
system(sprintf(
‘gconftool-2 -t string -s %s/picture_filename %s &’,
$gconf_path,
quotemeta($file)
));
exit;
}

Sacado de: http://gnome-hacks.web.com/hacks.html?id=15

Pertenece a la seccion Manuales





Comments are closed.