chiark / gitweb /
Fix completion checking in Killer Solo.
[sgt-puzzles.git] / desktop.pl
1 #!/usr/bin/perl
2
3 # Make .desktop files for the puzzles.
4 #
5 # At present, this script is intended for developer usage: if you're
6 # working on the puzzles and want to play your bleeding-edge locally
7 # modified and compiled versions, run this script and it will create a
8 # collection of desktop files in ~/.local/share/applications where
9 # XFCE can pick them up and add them to its main menu. (Be sure to run
10 # 'xfdesktop --reload' after running this.)
11 #
12 # (If you don't use XFCE, patches to support other desktop
13 # environments are welcome :-)
14
15 use strict;
16 use warnings;
17 use Cwd 'abs_path';
18
19 die "usage: desktop.pl [<outdir> [<bindir> <icondir>]]\n"
20     unless @ARGV == 0 or @ARGV == 1 or @ARGV == 3;
21
22 my ($outdir, $bindir, $icondir) = @ARGV;
23 $outdir = $ENV{'HOME'}."/.local/share/applications" unless defined $outdir;
24 $bindir = "." unless defined $bindir;
25 $icondir = "./icons" unless defined $icondir;
26 $bindir = abs_path($bindir);
27 $icondir = abs_path($icondir);
28
29 open my $desc, "<", "gamedesc.txt"
30     or die "gamedesc.txt: open: $!\n";
31
32 while (<$desc>) {
33     chomp;
34     my ($id, $win, $displayname, $description, $summary) = split /:/, $_;
35
36     open my $desktop, ">", "$outdir/$id.desktop"
37         or die "$outdir/$id.desktop: open: $!\n";
38
39     print $desktop "[Desktop Entry]\n";
40     print $desktop "Version=1.0\n";
41     print $desktop "Type=Application\n";
42     print $desktop "Name=$displayname\n";
43     print $desktop "Comment=$description\n";
44     print $desktop "Exec=$bindir/$id\n";
45     print $desktop "Icon=$icondir/$id-48d24.png\n";
46     print $desktop "StartupNotify=false\n";
47     print $desktop "Categories=Game;\n";
48     print $desktop "Terminal=false\n";
49
50     close $desktop
51         or die "$outdir/$id.desktop: close: $!\n";
52 }