Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sql-sith/1610f8d51854f36a6281d6651e198c82 to your computer and use it in GitHub Desktop.
Save sql-sith/1610f8d51854f36a6281d6651e198c82 to your computer and use it in GitHub Desktop.
Enable OpenWeather Extension on Ubuntu 20.04

Enabling the OpenWeather Extension on Ubuntu 20.04

The problem

The OpenWeather extension is a Gnome Shell extension that places a basic summary of current weather conditions in the top panel. This expands to show more detailed weather information if you click it.

Screenshot of OpenWeather Gnome Shell extension The OpenWeather Gnome Shell extension in action on my laptop.

The Internet has several stories of people having trouble enabling this extension in Ubuntu 20.04. Here are the suggestions I found on just one page from AskUbuntu:

  • Rename a certificate and then update ca-certificates. Multiple ways to do this are explained. Unfortunately, this certificate is already excluded in Ubuntu 20.04.3 by the entry !mozilla/AddTrust_External_Root.crt in /etc/ca-certificates.com, so this did not help me.
  • Edit the file openweather-extension@jenslody.de/extension.js to shut off ssl_strict mode. This solution has several problems. One is that it will not survive an extension update. Implied by this is that people might find this answer on AskUbuntu and not be able to use it if they have a different version of the extension. But the biggest problem? Probably enabling unencrypted connections. Yeah, there's that.
  • Uninstall and reinstall the extension.

That last suggestion seemed unlikely to succeed because in the Extensions app, the OpenWeather extension was not just disabled but also Built-In and grayed out.

Built-In OpenWeather extension is disabled! The Extensions app originally listed the OpenWeather extension as Built-In and as grayed out.

However, I learned that this just means that the extension was installed from Ubuntu's official repositories. It can be uninstalled using apt just like any other package.

sql-sith $ sudo apt uninstall gnome-shell-extension-weather
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  gnome-shell-extension-weather*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 582 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 247432 files and directories currently installed.)
Removing gnome-shell-extension-weather (0~20170402.git34506a6-2) ...
Processing triggers for libglib2.0-0:amd64 (2.64.6-1~ubuntu20.04.4) ...

After uninstalling the apt-based extension, I went to the OpenWeather home page and found instructions for installing it manually. You can download a .zip file from this site that contains the OpenWeather extension, but you need to know your version of Gnome Shell first.

To find this information, you can either open Settings | About and look for the version amidst the information on the right-hand side, or you can run a short terminal command.

sql-sith $ gnome-shell --version
GNOME Shell 3.36.9

Once you know the version of your Gnome Shell, the choose the version of the OpenWeather extension you want to download from the extension homepage. In general, you can choose the largest version number that is listed for your version of Gnome Shell.

Choose the largest version of the OpenWeather extension for your version of Gnome Shell This is what the download screen currently looks like on the OpenWeather extension's homepage. I am choosing the largest version number (105) that matches my Gnome Shell version of 3.36.9.

After you have this .zip file downloaded, it must be installed. There are many good articles on how to do this, and the code snippet below will show you how to install this one. If you want a full explanation of the process, you can read this article from itsfoss.com.

One comment about the code snippet below. You will notice that it copies the files from the .zip into a very specific directory. That directory name is not arbitrary, and must follow the format ~/.local/share/gnome-shell/extensions/<extension-uuid>.

In this case, you can use the directory name in the code snippet for the OpenWeather extension. However, if you need to find the uuid for another extension, you can unzip the files to a temporary location and you will find the uuid is listed in a file called metadata.json. You can also extract the uuid by running the following one-liner from the terminal (it is all one line of commands - any wrapping is due to the length of the line):

unzip -c ./openweather-extensionjenslody.de.v105.shell-extension.zip metadata.json | grep uuid | cut -f4 -d'"'

Finally, before running this snippet, I have downloaded the OpenWeather .zip file to /tmp and renamed it to /tmp/openweather.zip. Your file name will be longer, and it will probably be in ~/Downloads or someplace similar. Using /tmp/openweather.zip lets this script be version-agnostic for future readers. Also, putting downloads into /tmp is one way to make sure they get deleted before too long!

Having said all that, this is all you need to do after downloading the extension's .zip file:

# Set up a couple of variables. if you install Gnome 
# Shell extensions repeatedly, this will let you easily
# reuse this script by only modifying the first two variables.
extension_zip_file=/tmp/openweather.zip
apt_package_name=gnome-shell-extension-weather

# extract the uuid. this is the same code as the
# one-liner discussed earlier, but it is broken 
# into two parts for legibility. $metadata will 
# not be used for anything after we determine 
# the value of $uuid.
extension_metadata=$(unzip -c "$zip_file" metadata.json)
extension_uuid=$(echo "extension_$metadata" | grep uuid | cut -f4 -d'"')

# determine the location of the extension directory:
extension_directory=$(realpath ~/.local/share/gnome-shell/extensions/${extension_uuid})

# update apt package information and remove OpenWeather
# Gnome Shell extension if it is installed:
sudo apt update
sudo apt remove gnome-shell-extension-weather

# unzip the extension to the proper directory. create 
# the directory first if it doesn't exist:
unzip $extension_zip_file $extension_directory

Once you have run the above script, you only need to restart the Gnome Shell. The easiest way to do this if you are using X11 (the default) is to type Alt-F2 to access the Run a Command dialog box. Simply enter the single letter r and press enter to restart the Gnome Shell and load the OpenWeather shell extension. If you are using Wayland instead of X11, you will need to log out and log in to restart the Gnome Shell.

Whether you are using X11 or Wayland, after the Gnome Shell restarts, you should see the OpenWeather icon loaded on your top panel. And if you open the Extensions app now, you should see that the OpenWeather extension is enabled, and has moved from the Built-In section to the Manually Installed section. Success!

When all is said and done, everything looks much better. _After following these instructions, OpenWeather is enabled, and has moved from the Built-In section of the Extensions app to the Manually Installed section.

There may be other ways to enable the OpenWeather extension in Ubuntu 20.04, but even though this gist is long, the approach is pretty simple and rock-solid:

  1. Remove the extension that is managed by apt.
  2. Download a .zip file from the extension's homepage that is an appropriate version for your version of the Gnome Shell.
  3. Configure the extension contained in that .zip file properly.
  4. Profit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment