Google Chrome on OSX will not open .desktop files created in Ubuntu I have recently collected &amp; saved a large volume of internet links on my Ubuntu 14.04 machine that I wish to share with my other computer that runs OSX, but have come to realize that Google Chrome will not open these files on OSX as it does in Ubuntu.
The files are.desktopfiles. An example of the file's contents is as follows:

[Desktop Entry]
Encoding=UTF-8
Name=Link to Lifehacker Pack for Chrome: Our List of the Essential Extensions
Type=Link
URL=http://lifehacker.com/
Icon=text-html


OSX does not know natively what to do with this file type, and prompts me to choose which application to use to open the files. If I choose to use Google Chrome it will simply display the contents of the file in a tab, but will not navigate to the url in the file. Opening the file with Firefox loads the URL fine in a new tab.

How can I get Google Chrome to open these files normally?
My primary OS is OS X, however I do have a Linux Mint system I use and run into similar situations in which I want to do the same thing on both systems, and when it's not directly supported I have to find another way. In a case such as this, if there wasn't a Browser Extension for .desktop files, like in your other question about .url files, here is what I'd do.

I'd convert the .desktop files to .webloc files and or .url files and use the Default Apps Preference Pane, RCDefaultApp by Rubicode, to change which application opens any given file extension.

Here's a bash script, that I modified from a similar script I wrote years ago, which will create .webloc files and or .url files from .desktop files that have URLs in them.


In a Terminal cd to the directory containing the .desktop files.
Issues the following commands:

touch d2wu
open d2wu
Copy and paste the code below into the opened d2wu file.




#!/bin/bash

clear
echo
echo " Create .webloc/.url files from .desktop files."
echo " ----------------------------------------------"
echo "              Choose File Type(s):" 
echo
echo " [1] Create .webloc &amp; .url files."
echo " [2] Create only .webloc files."
echo " [3] Create only .url files."
echo " [Q] Quit."
echo
echo " Press 1 to 3 or Q then press Enter..."

Create_WEBLOC () {
    for f in *.desktop; do
        if [[ ! -f  ${f%.*}.webloc ]]; then
            url="$(awk -F '=' '/^URL=/{print $2}' "$f")"
            if [[ ! -z $url ]]; then
cat &lt;&lt;EOF &gt;"${f%.*}.webloc"
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
&lt;dict&gt;
    &lt;key&gt;URL&lt;/key&gt;
    &lt;string&gt;$url&lt;/string&gt;
&lt;/dict&gt;
&lt;/plist&gt;
EOF
            else
                echo "  No URL found in $f file."
            fi
        fi
    done
 }

Create_URL () {
    for f in *.desktop; do
        if [[ ! -f  ${f%.*}.url ]]; then
            url="$(grep -e '^URL=' "$f")"
            if [[ ! -z $url ]]; then
                printf "[InternetShortcut]\n${url}\n" &gt; "${f%.*}.url"
            else
                echo "  No URL found in $f file."
            fi
        fi
    done
 }

read  keypress
echo

case "$keypress" in
    "1")
        echo "  Creating .webloc &amp; .url files."
        Create_WEBLOC
        Create_URL
    ;;
    "2")
        echo "  Creating .webloc files."
        Create_WEBLOC
    ;;
    "3")
        echo "  Creating .url files."
        Create_URL
    ;;
    "q" | "Q")
        echo "  No files were created."
    ;;
    *)
        echo "  Pressing \"$keypress\" is not a valid choice... Try again!"
        echo
        read -p " Press Enter to continue..."
        "$0"        # Run the Script again.
    ;;
esac
echo





Save and close the d2wu file.
Make d2wu executable:

chmod u+x d2wu
Execute d2wu:

./d2wu




Example script output:

Create .webloc/.url files from .desktop files.
----------------------------------------------
             Choose File Type(s):

[1] Create .webloc &amp; .url files.
[2] Create only .webloc files.
[3] Create only .url files.
[Q] Quit.

Press 1 to 3 or Q then press Enter...
[]




Note: You can use the Default Apps Preference Pane, RCDefaultApp by Rubicode, to change which application opens a given file extension.

Also, if you need modify other default methods of file types, Apps, URLs, UTIs, etc. the the Default Apps Preference Pane is a great utility for it.







Note: As coded it will not overwrite existing .webloc files and or .url files even thought when selecting 1, 2 or 3, it reports "Creating ... files.".  This was done to both not step on existing files and minimize output to the screen while only outputting which .desktop files do not contain a URL=... line, as can be the case depending on what type of .desktop file it is.