#!/usr/bin/perl -w

=head1 NAME

dh_desktop - Register .desktop files at package install time

=cut

use strict;
use Debian::Debhelper::Dh_Lib;

=head1 SYNOPSIS

B<dh_desktop> [S<I<debhelper options>>] [B<-p<package>>]

=head1 DESCRIPTION

dh_desktop is a debhelper program that registers .desktop files at install time,
by calling F<update-desktop-database>.

=cut

# Get the debhelper init groove going.
init();

foreach my $package (@{$dh{DOPACKAGES}}) {
  my $tmp=tmpdir($package);

  # Only run if there are .desktop files installed
  if (-d "$tmp/usr/share/applications") {
    # Get a list of the desktop files
    my $desktop_files = `find debian/$package/ -type f -name \*.desktop -printf '%p\n'`;
    # If there actually were some schemas...
    if ($desktop_files && ! $dh{NOSCRIPTS}) {
      # Don't add a dependency on desktop-file-utils as it may not be needed
      autoscript($package,"postinst","postinst-desktop");
      autoscript($package,"postrm","postrm-desktop");
    }
  }
}

=head1 SEE ALSO

L<debhelper(1)>

This program uses debhelper, and should appear to be part of
debhelper.

=head1 AUTHOR

Ross Burton <ross@burtonini.com>

=cut
