aboutsummaryrefslogtreecommitdiff
path: root/desktop.pl
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2013-06-08 16:50:28 +0000
committerSimon Tatham <anakin@pobox.com>2013-06-08 16:50:28 +0000
commit122800cce146d27469732425b2775572d9fc2e68 (patch)
tree2863e1c72e41a42cd098c482d233e280550f3364 /desktop.pl
parent5dda5cf1d039767c632fe5e58ed7b95f5a615c0f (diff)
downloadpuzzles-122800cce146d27469732425b2775572d9fc2e68.zip
puzzles-122800cce146d27469732425b2775572d9fc2e68.tar.gz
puzzles-122800cce146d27469732425b2775572d9fc2e68.tar.bz2
puzzles-122800cce146d27469732425b2775572d9fc2e68.tar.xz
Script to read the new gamedesc.txt and create .desktop files. My
immediate intention is to run this locally so that my XFCE main menu acquires shortcuts for my locally compiled puzzle binaries, but I expect the script could probably be adapted for systemwide distribution use if any distribution hasn't already done this job in their own way by now. [originally from svn r9859]
Diffstat (limited to 'desktop.pl')
-rwxr-xr-xdesktop.pl51
1 files changed, 51 insertions, 0 deletions
diff --git a/desktop.pl b/desktop.pl
new file mode 100755
index 0000000..18b68ee
--- /dev/null
+++ b/desktop.pl
@@ -0,0 +1,51 @@
+#!/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.
+#
+# (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) = split /:/, $_;
+
+ open my $desktop, ">", "$outdir/$id.desktop"
+ or die "$outdir/$id.desktop: open: $!\n";
+
+ 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=$bindir/$id\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";
+}