#!/usr/bin/perl -w
#
# Fullscreen program launcher, [email protected]
# (slightly more minimal version)

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

my $main = MainWindow->new(-title => 'DeskPad Launcher',-background => 'black');
$main->overrideredirect (1);
$main->MoveToplevelWindow (0,0);
$main->geometry(join('x',$main->screenwidth,$main->screenheight));
$main->after(12000, sub { $main->destroy; });
$main->bind('<ButtonRelease-1>', sub { $main->destroy; });

# Load buttons from config file
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(
                       -background => 'black',
                       -activebackground => 'black',
                       -highlightthickness => '0',
                       -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;