From deddc8bd49f9affa2e7be5a49e6100994923612a Mon Sep 17 00:00:00 2001 From: Gerhard Gonter <ggonter@gmail.com> Date: Sun, 24 Aug 2014 15:10:56 +0200 Subject: [PATCH] allow passing of parameter to start_tb(), e.g. the path of the notes directory --- perl/Gnome-Tomboy/lib/Tomboy.pm | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/perl/Gnome-Tomboy/lib/Tomboy.pm b/perl/Gnome-Tomboy/lib/Tomboy.pm index 6b1aec4..68b51d3 100644 --- a/perl/Gnome-Tomboy/lib/Tomboy.pm +++ b/perl/Gnome-Tomboy/lib/Tomboy.pm @@ -1,3 +1,4 @@ +#!/usr/bin/perl =head1 NAME @@ -25,6 +26,8 @@ use strict; use UUID; use POSIX; +my %options_passed= map { $_ => 1 } qw(--note-path); # used by start_tb() function + sub link { my $s= shift; @@ -62,18 +65,29 @@ sub get_uuid sub start_tb { - my $what= shift; - my $par= shift; + my %par= @_; - if ($what eq 'uuid') + my @cmd= ('tomboy'); + foreach my $what (keys %par) { - my @cmd= ('tomboy', '--open-note', 'note://tomboy/'. $par); - print ">>> ", join (' ', @cmd), "\n"; - - my $pid= fork(); - if ($pid == 0) { exec @cmd; } - print "started pid=[$pid]\n"; + my $par= $par{$what}; + + if ($what eq 'uuid') + { + push (@cmd, '--open-note', 'note://tomboy/'. $par); + } + elsif (exists ($options_passed{$what})) + { + push (@cmd, $what, $par); + } } + + print ">>> ", join (' ', @cmd), "\n"; + my $pid= fork(); + if ($pid == 0) { exec @cmd; } + print "started pid=[$pid]\n"; + + $pid; } 1; -- GitLab