cross-posted from: !linux@lemmy.eco.br | https://lemmy.eco.br/post/1969330
I’ve been using Gnome for about 10 months and it always bothered me that my city (with more than a million inhabitants) was not found in the Weather program.
I looked for solutions several times and never found them, until I found this thread yesterday. That the user Julian made a script that solves this problem. you just have to run and enter the name of your city and then confirm.
script
#!/bin/bash
if [[ ! -z "$(which gnome-weather)" ]]; then
system=1
fi
if [[ ! -z "$(flatpak list | grep org.gnome.Weather)" ]]; then
flatpak=1
fi
if [[ ! $system == 1 && ! $flatpak == 1 ]]; then
echo "GNOME Weather isn't installed"
exit
fi
if [[ ! -z "$*" ]]; then
query="$*"
else
read -p "Type the name of the location you want to add to GNOME Weather: " query
fi
query="$(echo $query | sed 's/ /+/g')"
request=$(curl "https://nominatim.openstreetmap.org/search?q=$query&format=json&limit=1" -s)
if [[ $request == "[]" ]]; then
echo "No locations found, consider removing some search terms"
exit
fi
read -p "If this is not the location you wanted, consider adding search terms
Are you sure you want to add $(echo $request | sed 's/.*"display_name":"//' | sed 's/".*//')? [y/n] : " answer
if [[ ! $answer == "y" ]]; then
echo "Not adding location"
exit
else
echo "Adding location"
fi
id=$(echo $request | sed 's/.*"place_id"://' | sed 's/,.*//')
name=$(curl "https://nominatim.openstreetmap.org/details.php?place_id=$id&format=json" -s | sed 's/.*"name": "//' | sed 's/".*//')
lat=$(echo $request | sed 's/.*"lat":"//' | sed 's/".*//')
lat=$(echo "$lat / (180 / 3.141592654)" | bc -l)
lon=$(echo $request | sed 's/.*"lon":"//' | sed 's/".*//')
lon=$(echo "$lon / (180 / 3.141592654)" | bc -l)
if [[ $system == 1 ]]; then
locations=$(gsettings get org.gnome.Weather locations)
fi
if [[ $flatpak == 1 ]]; then
locations=$(flatpak run --command=gsettings org.gnome.Weather get org.gnome.Weather locations)
fi
location="<(uint32 2, <('$name', '', false, [($lat, $lon)], @a(dd) [])>)>"
if [[ $system == 1 ]]; then
if [[ ! $(gsettings get org.gnome.Weather locations) == "@av []" ]]; then
gsettings set org.gnome.Weather locations "$(echo $locations | sed "s|>]|>, $location]|")"
else
gsettings set org.gnome.Weather locations "[$location]"
fi
fi
if [[ $flatpak == 1 ]]; then
if [[ ! $(flatpak run --command=gsettings org.gnome.Weather get org.gnome.Weather locations) == "@av []" ]]; then
flatpak run --command=gsettings org.gnome.Weather set org.gnome.Weather locations "$(echo $locations | sed "s|>]|>, $location]|")"
else
flatpak run --command=gsettings org.gnome.Weather set org.gnome.Weather locations "[$location]"
fi
fi
It occurred to me that some people might not know how to run scripts, so here’s a brief tutorial:
How to run scripts in Linux
- Save the script to a text file and save with the
.sh
extension - Provide execute permission:
chmod u+x script.sh
- run the script by double clicking or
./script.sh
Damn, how very user friendly.
This is amazing! I’m not using Gnome, but moments like this are the reason why I love Linux so much.
As a gnome user and huge Linux enthusiast, this should not have to exist. Gnome weather is just badly designed
Yeah, it’s a terrible thing that you have to do this to get your city into the weather app, but I simply love the fact that you can do that, whereas on some proprietary system, you might wait months for the fix.
Actually GNOME devs can not fix it for several years! Now they say our app is good and the problem is some library is bad (why use it than?) and people do not contribute submitting their cities either (they added some cities years ago, and than just ignored all submitted cities further). Open software is about ‘make a commit to fix it yourself!’… Yep that’s how it is.
My happiness is ruined :(
KDE is very receptive to community help! I can only think of one specific example in KDE history where a developer dragged their feet in the mud about a change the community wanted/submitted pull requests for, and thats the vertical HTML indicator bar in kmail.
Gnome on the other hand…
I tried this script before and while it adds city, the weather itself was wrong. Does it shows you correct temperature?
For me it does, the creator said he adjusted it, maybe you tried when it was still wrong?
I have checked my temp. Against the source (norway service) and it was right.
I am on my phone now but i can print the page later.
Thanks, I tried it again, it gived me some error, but the city was set and the weather is correct now. Awesome!
Afaik the problem is solved within the code. I remember having compiled the app myself. It’s just a matter of time that it’s solved.
BUT it’s weird that this is so low priority to all gnome devs. It seems like noone cares about the correct weather. The source of weather is also not really perfect.
They have their cities in the list, so it works for them… The list itself is more than 1mb now, so they said we can not add small cities, less than 500k citizens we won’t add, unless the country do not have bigger cities at all. Holy shit… The script just uses internet to find a city, the whole concept of cities list is dumb. But yeah I love GNOME anyway lol.