blob: 6eefa8f276c5a7878c2ed77131491fb13f5f5ff4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#! /usr/bin/env raku
use v6.d;
#| Start a slideshow of the given directories using feh.
sub MAIN(
#| The directories to include for the slideshow.
*@dirs,
#| Show the command to be executed, and exit. Useful for debugging purposes.
Bool:D :$dry-run = False,
#| The timeout or delay between pictures. Defaults to 5.
Int:D :$timeout = 5,
) {
my $aliases-file = $*HOME.add('.local/etc/slideshow/aliases').IO;
my $cmd = "feh -zsZ.D $timeout";
my @cmd-args;
my %aliases;
# Use aliases if such a configuration is found.
if ($aliases-file.f) {
$aliases-file
.lines
.map({
my ($key, $value) = $_.words;
my $resolved-value = $value
.subst('$HOME', $*HOME.absolute)
;
%aliases{$key}.append: $resolved-value;
})
}
for @dirs {
# Transform aliases as needed
if (%aliases{$_}:exists) {
@cmd-args.append(%aliases{$_});
next;
}
@cmd-args.append: $_;
}
if ($dry-run) {
say "$cmd {@cmd-args}";
exit 0;
}
run « $cmd {@cmd-args} »;
}
|