POL_Function_SetNativeExtension

Informations

Creator Message
petch

Information

This installer has been approved by the team.

Informations

Platforms:
Downloads: 797198
Wine: System

Feedbacks

Description

Associate the files of the given filename extension to their default application in the native (host) environment.
Extension can be provided with or without the leading period.
Examples:

POL_Call POL_Function_SetNativeExtension "pdf"
POL_Call POL_Function_SetNativeExtension ".txt"

Source code

#!/bin/bash
#Creator: petch

# Remove starting dot, if any
FILEXT="${1#.}"
# Lowercase
FILEXT="${FILEXT,,*}"

if [ -z "$FILEXT" ]; then
    POL_Debug_Warning "$(eval_gettext 'No filename extension specified, skipping association to native application.')" "$TITLE"
    return
fi

MIMETYPE=""
[ "$FILEXT" = "pdf" ] && MIMETYPE="application/pdf"
[ "$FILEXT" = "txt" ] && MIMETYPE="text/plain"
[ "$FILEXT" = "rtf" ] && MIMETYPE="application/rtf"

# Associate an extension with native app
# http://wiki.winehq.org/FAQ#head-91bf3f0a8ccbfab8dee96f82fae2f1a489e0d243

cat <<_EOF_ > "$REPERTOIRE/tmp/nativeext.reg"
REGEDIT4

[HKEY_CLASSES_ROOT\\.${FILEXT}]
@="${FILEXT}file"
"Content Type"="${MIMETYPE}"

[HKEY_CLASSES_ROOT\\${FILEXT}file\\Shell\\Open\\command]
@="winebrowser \\"%1\\""
_EOF_

POL_Wine regedit "$REPERTOIRE/tmp/nativeext.reg"
rm "$REPERTOIRE/tmp/nativeext.reg"

Contributions

Filters:

Contribute
Member Message

This site allows content generated by members, and we promptly remove any content that infringes copyright according to our Terms of Service. To report copyright infringement, please send a notice to dmca-notice@playonlinux.com