Skip to content

Instantly share code, notes, and snippets.

@cannorin
Last active December 10, 2015 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cannorin/e3fab37af3a56073bda4 to your computer and use it in GitHub Desktop.
Save cannorin/e3fab37af3a56073bda4 to your computer and use it in GitHub Desktop.
exe file handler for linux
#!/bin/bash
[ $# -eq 0 ] &&
{
echo "Usage: exehandler filename"
exit 0
}
[ -f $1 ] ||
{
echo exehandler: $1 not found
exit 1
}
EXEPATH="$(realpath $1)"
checkdn="
try
{
System.Reflection.AssemblyName.GetAssemblyName(\"$EXEPATH\");
Console.WriteLine(\"$EXEPATH is a .NET assembly.\");
Environment.Exit(0);
}
catch(Exception e)
{
Console.WriteLine(e);
Console.WriteLine(\"$EXEPATH is not a .NET assembly.\");
Environment.Exit(1);
}"
echo $checkdn | csharp
if [ $? -ne 0 ]; then
shift;
wine $EXEPATH $*
else
shift;
mono $EXEPATH $*
fi
# cp this to .local/share/applications/
[Desktop Entry]
Type=Application
Name=EXE Handler
Exec=/usr/local/bin/exehandler %f
Categories=Other;
NoDisplay=true
MimeType=application/x-ms-dos-executable
Terminal=false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment