Announcement

Collapse
No announcement yet.

Open .url files with firefox.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Open .url files with firefox.

    Previously, in my Kubuntu 18.04 I could open the .url files in Firefox without problems by simply clicking on them, and Firefox would open and load the address of the web page contained in said .url file. But now since I have Kubuntu 24.04 I have no longer been able to do this. If I open a .url with Firefox, Firefox simply gives me the option to download said file (something absurd), and the same thing happens if I open the .url with Chrome or any other browser.

    So I would like to be able to have this functionality again that I previously had in Kubuntu 18.04. I have to say that both before in Kubuntu 18.04 and now in Kubuntu 24.04 I have Wine installed. I say this because as I understand it, it is precisely Wine that provides this functionality of being able to open .url files with browsers. But for some reason now in Kubuntu 24.04 this is not working, which I find annoying because I am forced to open the .url files with Kate and copy the address of the contained page and paste it into the browser to access it.
    Greetings...









    #2
    .url files are a Microsoft thing, sort of like a Windows shortcut, for IE, and I imagine that browsers no longer support them. But if you have to work with software that generates them, saying "don't use .url files" isn't helpful.

    Do yours have a line like:
    Code:
    URL=https://kubuntuforums.net/
    If they do, you could associate them with a script that extracts the URL and gives it to firefox. Say, do-url.sh:
    Code:
    #!/bin/bash
    url=$(awk '/^URL/ { sub(/^URL=/, "");print}' $1)
    firefox "$url"
    Put that in your $PATH, (say, ~.local/bin), and make it executable. Then go into system settings, applications, file associations, type .url in the search box, expand the "application" category, click on x-mswinurl, then "Add", click the folder icon, find your script. ok, then make sure it's at the top of the application preference order, click apply. I had to fiddle a bit for the order to stick. Then opening the file in dolphin should open the URL in firefox. In a script or on the command line you could use
    xdg-open whatever.url.
    Regards, John Little

    Comment


      #3
      Hello.
      Thank you very much for your quick response.

      Unfortunately I must say that it has not worked. I mean, Firefox actually opens when you click on the .url files (which actually all contain a line URL=https://kubuntuforums.net/), the problem is that Firefox does not open with the URL of the page contained in the .url file but rather it opens with a strange page in which there is a list with links to all the files contained in the folder where the .url file that was clicked was.
      Greetings...
      Attached Files

      Comment


        #4
        I worked from a .url file example I found on-line, maybe yours are different.

        I suggest posting here the content of a .url file, surrounded by code tags (you can paste it into the reply, select it, and click the # button above).

        Also, in the script, let's find out what is happening by adding this line before the firefox one:
        Code:
        echo $url >> ~/do-url.log
        Then, please show us what is in that log.
        Regards, John Little

        Comment


          #5
          Practically no two .url files are the same, but they all have one line in common, which is always:

          [InternetShortcut]

          And another line in which its url is specified, such as:

          URL=https://www.xxxxx.xxx


          I'm pasting the contents of 3 .url files here so you can see them for yourself. Although most are like the first of these 3 samples:

          Code:
          [InternetShortcut]
          URL=https://fonts.google.com/
          Code:
          [DEFAULT]
          BASEURL=http://iss.astroviewer.net/
          [InternetShortcut]
          URL=http://iss.astroviewer.net/
          Code:
          [InternetShortcut]
          URL=https://www.asus.com/es/Optical-Drives-Storage/BW16D1HT/
          IconIndex=0
          HotKey=0
          IDList=
          IconFile=D:\Mis documentos\Imágenes\Iconos\Mis iconos\Asus.ico
          [InternetShortcut.A]
          IconFile=D:\Mis documentos\Imágenes\Iconos\Mis iconos\Asus.ico
          [InternetShortcut.W]
          IconFile=D:+AFw-Mis documentos+AFw-Im+AOE-genes+AFw-Iconos+AFw-Mis iconos+AFw-Asus.ico
          As for the new script he gave me...

          Code:
          #!/bin/bash
          url=$(awk '/^URL/ { sub(/^URL=/, "");print}' $1)
          echo $url >> ~/do-url.log
          firefox "$url"
          It hasn't worked at all, when adding the new line nothing simply happens, that is, Firefox doesn't launch or create any log anywhere.
          Greetings...

          Comment


            #6
            If no do-url.log file has been created in your home directory, then I think the script hasn't run. Please check the file association, for me the system settings screen would move the script down from the top spot sometimes.

            Another thing to check is to test the script in a konsole. In a konsole, type the full path to do-url.sh with the full path to the .url file:
            Code:
            $HOME/bin/do-url.sh $HOME/posts/astro.url
            (those are my examples, yours will be different.) Running in a konsole lets us see errors that may have occurred.
            Regards, John Little

            Comment


              #7
              The script is first listed in the file association. In fact, to make sure, I eliminated the other options so that when I ran it, only the script was the only option.

              But you are right in the sense that I have just verified that the script is not really executed for some strange reason that I don't know about.
              If you look at the attached images you will see that the script is in the path indicated by you, and that it also has the correct permissions.
              You will also be able to see how when you execute the command in the console the output it gives is that "No such file or directory" even though in the same image you can see how the file is there in that folder.
              I even ran the script "do-url.sh" directly from dolphin and as you can also see in the screenshot, an error occurs that also says that "No such file or directory."
              Therefore, I do not understand what the script has that is not detected and of course is not executed.
              Greetings...
              Attached Files

              Comment


                #8
                The konsole session has a period that shouldn't be there. Try
                Code:
                /home/julio-cesar/.local/bin/do-url.sh
                (That was hard to see. To run an executable in the current directory one has to use ./foo , but if giving the whole path it shouldn't be there.

                The dolphin window is saying there's an error on the shebang line, the first line of the file. It should be
                Code:
                #!/bin/bash
                or conceivably you don't have a /bin, which should be a symlink to /usr/bin; then use the line #!/usr/bin/bash.
                Regards, John Little

                Comment


                  #9
                  The content of the "do-url.sh" file is:

                  Code:
                  #!/usr/bin/bash
                  url=$(awk '/^URL/ { sub(/^URL=/, "");print}' $1)
                  echo $url >> ~/do-url.log
                  firefox "$url"
                  And repeating all the tests the result is IDENTICAL to the one I gave in my previous message.
                  Greetings...







                  Last edited by Supersayano; Jun 10, 2024, 05:51 AM.

                  Comment


                    #10
                    Supersayano Is something other than bash set as your default shell?
                    Windows no longer obstructs my view.
                    Using Kubuntu Linux since March 23, 2007.
                    "It is a capital mistake to theorize before one has data." - Sherlock Holmes

                    Comment


                      #11
                      I do not know what he's talking about.
                      Greetings...

                      Comment


                        #12
                        Supersayano In a konsole, type: echo $SHELL and press Enter. The shell that is set as default will be shown. By default, in Ubuntu/Kubuntu it is: /usr/bash
                        Windows no longer obstructs my view.
                        Using Kubuntu Linux since March 23, 2007.
                        "It is a capital mistake to theorize before one has data." - Sherlock Holmes

                        Comment


                          #13
                          Code:
                          julio-cesar@mi-equipo:~$ echo $SHELL
                          /bin/bash
                          julio-cesar@mi-equipo:~$
                          Greetings...

                          Comment


                            #14
                            Good. At least we know that what ever is causing the shell script not to function as jlittle says it should isn't due to the shell not being bash. Something else is afoot.
                            Windows no longer obstructs my view.
                            Using Kubuntu Linux since March 23, 2007.
                            "It is a capital mistake to theorize before one has data." - Sherlock Holmes

                            Comment


                              #15
                              It's strange because the other scripts are working without problems.
                              Greetings...

                              Comment

                              Working...
                              X