12.13
I use a linux desktop at work nowdays, and I’m very happy with it for the most part. There are some caveats to using Linux in a predominantly Windows based environment though. For instance, I have to log into our Windows servers to do my daily work. This isn’t that big of a deal since the Linux world has long had software like rdesktop that will let you RDP into a Windows box. I really like rdesktop because it’s so lightweight. It doesn’t have all of the bulk that the KDE remote app does.
But the big drawback to it, is that you have to launch it from the command line every time if you want to log into a different box. It has no X based interface to ask what server you want to connect to. It’s just that sort of redundancy that slowly drives me nuts as I do it over and over. So I set out in search of a solution. It seems that other people want this, but nobody bothered to code up a solution for it. So I did it myself. I ended up using the perl GTK libraries to make a simple X launcher for rdesktop. Here is the source code:
#!/usr/bin/perl -w
use strict;
use Gtk2 ’-init’;
use constant TRUE => 1;
use constant FALSE => 2;
##: Globals
my $defserver = "serverX";
##: Create main window
my $window = Gtk2::Window->new;
$window->set_title("Remote Desktop Launcher");
$window->set_position(’center’);
##: Main window signals
$window->signal_connect (destroy => sub { Gtk2->main_quit; });
##: Create a vbox layout
my $vbox = Gtk2::VBox->new(FALSE, 6);
$window->add($vbox);
##: Create the text entry box for typing in the server name
my $entry = Gtk2::Entry->new();
$entry->set_text($defserver);
$vbox->pack_start ($entry, TRUE, TRUE, 0);
##: Entry signals
$entry->signal_connect( activate => \&button_callback);
##: Create a launch button and stick it in the window
my $button = Gtk2::Button->new (’Launch’);
$vbox->pack_start ($button, TRUE, TRUE, 0);
##: Button signals
$button->signal_connect (clicked => \&button_callback);
##: Display everything we just made
$window->show_all;
##: Set initial focus
$entry->grab_focus();
##: Enter the event loop
Gtk2->main;
##: Button callbacks
sub button_callback
{
my $servername = $entry->get_text();
my $pid = fork();
if ($pid == 0) {
exec("/usr/bin/rdesktop -0 -g1440x900 ".$servername);
}
Gtk2->main_quit;
1;
}
Ok, first copy and paste this code into a file called “rdl.pl” and mark it executable with chmod 0755 rdl.pl. Then make sure you have the Gtk2 libraries for perl installed. Just run a sudo perl -MCPAN -e shell and do a install Gtk2 to get the libraries. Lastly, change the value of $defserver to the server name you want it to always populate in the text box by default. I log into one particular server about 80% of the time so this saves me some typing. Now just make a launcher for the script on your desktop or launch bar or wherever and you’re good to go. Enjoy!








No Comment.
Add Your Comment