#!/usr/bin/perl use warnings; use strict; use File::Slurp; use Data::Dumper; use v5.10; use POSIX qw(strftime); my $launcher = $ARGV[0]; my $launcher_dir = "$ENV{HOME}/.config/xfce4/panel/launcher-$launcher"; my @desktop_files = glob("$launcher_dir/*.desktop"); mkdir "$ENV{HOME}/log/"; mkdir "$ENV{HOME}/log/xfce-xterm-launcher/"; open my $log, ">>", "$ENV{HOME}/log/xfce-xterm-launcher/" . strftime("%Y-%m", localtime); my @dirs = ("$ENV{HOME}/bin/hosts", grep -d, glob("$ENV{HOME}/bin/hosts/*")); my $i = 0; for (@desktop_files) { my $content = read_file($_); my ($exec) = $content =~ m/^Exec=xterm -e (.*)/m; next unless defined $exec; my $age = age($exec); say $log join("\t", $^T, ++$i, $exec, $age); } sub age { my ($exec) = @_; if ($exec =~ m{^/}) { return -A $exec; } for my $d (@dirs) { my $age = -A "$d/$exec"; return $age if defined $age; } return; }