Skip to content

Instantly share code, notes, and snippets.

@benad
Last active August 21, 2018 18:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benad/f864e339c9b1c148f0f8 to your computer and use it in GitHub Desktop.
Save benad/f864e339c9b1c148f0f8 to your computer and use it in GitHub Desktop.
Run opendesktop.org-style *.desktop files (usually located under ~/.local/share/applications) from the command-line. This is only a bare-bones omplementation. Useful on a Mac. See http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-1.0.html .
#!/usr/bin/perl
use strict;
my $cmd;
my $path;
while (<>) {
if (/^Exec=(.*)/) {
$cmd = $1;
$cmd =~ s{\\\\}{\\}g;
$cmd =~ s{\\`}{`}g;
$cmd =~ s{\\\$}{\$}g;
}
if (/^Path=(.*)/) {
$path = $1;
}
}
if ($cmd) {
if ($path) {
chdir($path);
}
system($cmd);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment