aboutsummaryrefslogtreecommitdiff
path: root/scripts/menu.pl
blob: 8177dc15a5822e191a75144923ba9bc8fcc2a28b (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
#!/usr/bin/env perl 
use strict;
use warnings;
use 5.016;
use Linux::DesktopFiles;
use List::Util 'first';
use Data::Printer;
 
my $d = Linux::DesktopFiles->new(
    #with_icons => 1, 
    abs_icon_paths => 1,
    skip_svg_icons => 1,
    icon_dirs_last => ['/usr/share/icons/gnome'],
);
 
my $f = $d->parse_desktop_files();
 
for my $cat (keys %$f) {
    my @apps=@{$f->{$cat}};
    my $menu_name='/Applications/'.ucfirst(lc($cat)).'Panel';
    say "DestroyMenu $menu_name";
    say "AddToMenu $menu_name";
    for my $app (@apps) {
        next unless $app->{Icon};
        printf qq{+ "%%%s%%\$[gt.%s]" Exec exec "%s"\n},
            $app->{Icon},$app->{Name},$app->{Exec};
    }
    say '';
}
 
my $buttons=0;
for my $cat (keys %$f) {
    my @apps=@{$f->{$cat}};
    my $app=first { $_->{Icon} } @apps;
    next unless $app;
    ++$buttons;
 
    my $menu_name='/Applications/'.ucfirst(lc($cat)).'Panel';
    printf qq{*ApplicationPanel: (1x1, Size 22 22, Icon "%s", \\\n},$app->{Icon};
    printf qq{Action (Mouse 1) Exec exec "%s", \\\n},$app->{Exec};
    printf qq{Action (Mouse 3) Menu %s \$[MenuPosition_S] )\n},$menu_name;
}
 
say "SetEnv ApplicationPanelLength $buttons";