Allow bin/hosts to have subdirectories
This commit is contained in:
parent
bcab6770c3
commit
357d10f4af
|
@ -16,11 +16,26 @@ mkdir "$ENV{HOME}/log/";
|
||||||
mkdir "$ENV{HOME}/log/xfce-xterm-launcher/";
|
mkdir "$ENV{HOME}/log/xfce-xterm-launcher/";
|
||||||
open my $log, ">>", "$ENV{HOME}/log/xfce-xterm-launcher/" . strftime("%Y-%m", localtime);
|
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;
|
my $i = 0;
|
||||||
for (@desktop_files) {
|
for (@desktop_files) {
|
||||||
my $content = read_file($_);
|
my $content = read_file($_);
|
||||||
my ($exec) = $content =~ m/^Exec=xterm -e (.*)/m;
|
my ($exec) = $content =~ m/^Exec=xterm -e (.*)/m;
|
||||||
next unless defined $exec;
|
next unless defined $exec;
|
||||||
my $age = -A "$ENV{HOME}/bin/hosts/$exec";
|
my $age = age($exec);
|
||||||
say $log join("\t", $^T, ++$i, $exec, $age);
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -6,8 +6,6 @@ use strict;
|
||||||
use File::Slurp;
|
use File::Slurp;
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
|
|
||||||
use experimental qw(autoderef);
|
|
||||||
|
|
||||||
my $launcher = $ARGV[0];
|
my $launcher = $ARGV[0];
|
||||||
my $verbose = 0;
|
my $verbose = 0;
|
||||||
|
|
||||||
|
@ -22,7 +20,9 @@ for (@desktop_files) {
|
||||||
$desktop_files{$name} = { name => $name, filename => $_, content => $content }
|
$desktop_files{$name} = { name => $name, filename => $_, content => $content }
|
||||||
}
|
}
|
||||||
|
|
||||||
my @xterm_scripts = glob("$ENV{HOME}/bin/hosts/*");
|
my @xterm_scripts = grep !-d,
|
||||||
|
(glob("$ENV{HOME}/bin/hosts/*"),
|
||||||
|
glob("$ENV{HOME}/bin/hosts/*/*"));
|
||||||
@xterm_scripts = sort { -A $a <=> -A $b } @xterm_scripts;
|
@xterm_scripts = sort { -A $a <=> -A $b } @xterm_scripts;
|
||||||
@xterm_scripts = @xterm_scripts[0..31] if @xterm_scripts > 32;
|
@xterm_scripts = @xterm_scripts[0..31] if @xterm_scripts > 32;
|
||||||
for my $xterm_script (@xterm_scripts) {
|
for my $xterm_script (@xterm_scripts) {
|
||||||
|
|
Loading…
Reference in New Issue