From f809a7b32133d612e0bdacabe308c9de04ce2619 Mon Sep 17 00:00:00 2001 From: kake26 Date: Wed, 30 Apr 2025 17:32:52 -0500 Subject: [PATCH] Add Run pshell menu item with terminal auto-detection --- kpadgtk3.pl | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/kpadgtk3.pl b/kpadgtk3.pl index 9f4537c..58d952b 100644 --- a/kpadgtk3.pl +++ b/kpadgtk3.pl @@ -168,6 +168,19 @@ my $which_line_item = Gtk3::MenuItem->new_with_label('Which Line?'); $which_line_item->signal_connect(activate => \&which_line_dialog); $tools_menu->append($which_line_item); +my $run_pshell = Gtk3::MenuItem->new_with_label('Run pshell'); +$run_pshell->signal_connect(activate => sub { + my $pshell_path = "$basedir/pshell"; + my $terminal = find_terminal(); + if (-x $pshell_path) { + system("$terminal -e $pshell_path &"); + $statusbar->push(0, "Launched pshell in $terminal"); + } else { + $statusbar->push(0, "Error: pshell not found at $pshell_path"); + } +}); +$tools_menu->append($run_pshell); + # HTML menu my $html_menu = Gtk3::Menu->new; my $html_item = Gtk3::MenuItem->new_with_label('HTML'); @@ -280,6 +293,15 @@ while (<*.kpd>) { } my $nop = grep { $_ ne 'auto' } @n; +# Find available terminal +sub find_terminal { + my @terminals = qw(gnome-terminal konsole xterm); + for my $term (@terminals) { + return $term if `which $term 2>/dev/null` =~ /\S/; + } + return 'xterm'; # Fallback +} + # File handling sub open_file { my $dialog = Gtk3::FileChooserDialog->new(