-
Notifications
You must be signed in to change notification settings - Fork 1
/
desktop.pl
executable file
·56 lines (46 loc) · 1.8 KB
/
desktop.pl
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
52
53
54
55
56
#!/usr/bin/perl
# Make .desktop files for the puzzles.
#
# At present, this script is intended for developer usage: if you're
# working on the puzzles and want to play your bleeding-edge locally
# modified and compiled versions, run this script and it will create a
# collection of desktop files in ~/.local/share/applications where
# XFCE can pick them up and add them to its main menu. (Be sure to run
# 'xfdesktop --reload' after running this.)
#
# (If you don't use XFCE, patches to support other desktop
# environments are welcome :-)
use strict;
use warnings;
use Cwd 'abs_path';
die "usage: desktop.pl [<outdir> [<bindir> <icondir>]]\n"
unless @ARGV == 0 or @ARGV == 1 or @ARGV == 3;
my ($outdir, $bindir, $icondir) = @ARGV;
$outdir = $ENV{'HOME'}."/.local/share/applications" unless defined $outdir;
$bindir = "." unless defined $bindir;
$icondir = "./icons" unless defined $icondir;
$bindir = abs_path($bindir);
$icondir = abs_path($icondir);
open my $desc, "<", "gamedesc.txt"
or die "gamedesc.txt: open: $!\n";
while (<$desc>) {
chomp;
my ($id, $win, $displayname, $description, $summary) = split /:/, $_;
open my $desktop, ">", "$outdir/$id.desktop"
or die "$outdir/$id.desktop: open: $!\n";
my $path = "$bindir/$id";
my $upath = "$bindir/unfinished/$id";
$path = $upath if ! -f $path && -f $upath;
print $desktop "[Desktop Entry]\n";
print $desktop "Version=1.0\n";
print $desktop "Type=Application\n";
print $desktop "Name=$displayname\n";
print $desktop "Comment=$description\n";
print $desktop "Exec=$path\n";
print $desktop "Icon=$icondir/$id-48d24.png\n";
print $desktop "StartupNotify=false\n";
print $desktop "Categories=Game;\n";
print $desktop "Terminal=false\n";
close $desktop
or die "$outdir/$id.desktop: close: $!\n";
}