#!/usr/bin/perl -w
# Very basic program launcher, [email protected]

use strict;
use Tk;
use Tk::PNG;

my $main = MainWindow->new(-title => 'Launcher');
$main->geometry(($main->maxsize())[0] .'x'.($main->maxsize())[1]);
$main->bind('<Key-Escape>', sub { $main->destroy; });

open my $cfgfile, $ENV{"HOME"}."/.deskpad" or die "Could not open config file: $!\n";

while(my $line = <$cfgfile>)  {
       if (chomp($line) ne "") {
               my @iconData = split(":",$line);
               $main->Button(
                       -borderwidth => '0',
                       -command => sub { exec($iconData[1]) },
                       -image => $main->Photo('-format' => 'png', -file => $iconData[0]),
               )->pack->place(-x=>$iconData[2],-y=>$iconData[3]);
       }
}

close $cfgfile;
MainLoop;