2

I would like to create a file that when double clicked launches a website in the default web browser. I have found that .desktop files can do this, but apparently they no longer work in Ubuntu 22.04.

How can this be done?

user171780
  • 426
  • 1
  • 5
  • 21
  • The instructions given in this answer still work in Ubuntu 22.04. – balage Sep 27 '23 at 09:57
  • I tried it and it does not work for me. I made the .desktop file executable. Do I have to do something extra for it to open the website on double click? – user171780 Sep 27 '23 at 14:29
  • 1
    I double checked and the results are disappointing. Turns out this approach only works from Nemo file manager. From Nautilus it opens the text file (right click + run as program does nothing). In Thunar nothing happens. If I place it on the desktop, it says "broken desktop file". Wow. – balage Sep 28 '23 at 10:22

1 Answers1

2

You can use an html file that launches in the default browser and immediately redirects to your target website with the http-equiv=refresh attribute on the <meta> element. The target website address goes to the content attribute which must be a non-negative integer followed by the string ';url=', and your URL. The integer is the number of seconds until the page should redirect - in this case 0 is a convenient value.

If you have a link to your website on a page in Firefox, you can actually drag the link and drop it on the desktop to create such a file (this is how I accidentally found this solution while playing around with links and desktop launcher files). Or, create the file manually.

For example the following file will open and redirect to askubuntu.com:

<html>
  <head>
    <meta http-equiv="refresh" content="0; url=https://askubuntu.com" />
  </head>
<body></body>
</html>

balage
  • 106