xfce-xterm-launcher-update/xfce-xterm-launcher-log-age

42 lines
969 B
Plaintext
Raw Normal View History

2014-11-12 12:00:37 +01:00
#!/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");
2017-06-16 08:55:59 +02:00
mkdir "$ENV{HOME}/log/";
2014-11-12 12:00:37 +01:00
mkdir "$ENV{HOME}/log/xfce-xterm-launcher/";
open my $log, ">>", "$ENV{HOME}/log/xfce-xterm-launcher/" . strftime("%Y-%m", localtime);
2022-10-16 09:10:02 +02:00
my @dirs = ("$ENV{HOME}/bin/hosts",
grep -d, glob("$ENV{HOME}/bin/hosts/*"));
2014-11-12 12:00:37 +01:00
my $i = 0;
for (@desktop_files) {
my $content = read_file($_);
2022-10-16 09:10:55 +02:00
my ($exec) = $content =~ m/^Exec=(?:xterm|xfce4-terminal) -e (.*)/m;
2014-11-12 12:00:37 +01:00
next unless defined $exec;
2022-10-16 09:10:02 +02:00
my $age = age($exec);
2014-11-12 12:00:37 +01:00
say $log join("\t", $^T, ++$i, $exec, $age);
}
2022-10-16 09:10:02 +02:00
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;
}