this post was submitted on 29 Nov 2023
1 points (60.0% liked)

The (unofficial) GNOME Community on Lemmy

243 readers
1 users here now

The GNOME Project is a free and open source desktop and computing platform for open platforms like Linux that strives to be an easy and elegant way to use your computer. GNOME software is developed openly and ethically by both individual contributors and corporate partners, and is distributed under the GNU General Public License.

This Lemmy community is not affiliated with the GNOME project.

Rules:


1. Trolling, flamewars, or poor discussion

We ask all users to follow the GNOME Code of Conduct. Top violations of this rule are trolling, starting a flamewar, "shitposting", or not "remembering the human" aka being hostile or incredibly impolite.

2. No memes, image macros, or rage comics

Meme posts are not allowed. Feel free to post over at !linuxhumor instead.

3. Relevance to GNOME community

Posts should follow what the community likes: GNOME, GNOME development, GNOME applications, the GNOME foundation, GTK+, Flatpak or Flathub, and more. Take some time to get the feel of the community if you're not sure!

4. Post and dash

Posting content is welcome (duh), but we do ask that you contribute more than just your content to the subreddit. We as well require you stick around and interact with the comments of your submission. If you post something and abandon it, it may be treated as spam.

5. No misdirected links, paywalls, or URL shorteners

In short: if your link doesn't go right to the content it will be removed. Sites that require a login to view the content are not allowed. Example: A private Facebook post or a news organization that doesn't have free article views. URL shorteners and links that misdirect users to ads/jokes are also banned.

6. NSFW

No NSFW links or content.

7. No rage posts

We do not shy away from criticism, in fact, we encourage it! However, criticisms of GNOME must be accompanied with valid, well reasoned arguments. Posts that contain no original content and are meant to just spread hatred and anger will not be tolerated.

8. Spam

For obvious reasons, spam is not tolerated. Spam content will be removed, and spam accounts will be banned. This also applies to bot accounts.

The above description and rules were adapted from The GNOME Community on Reddit.

founded 2 years ago
MODERATORS
 

cross-posted from: [email protected] | 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

  1. Save the script to a text file and save with the .sh extension
  2. Provide execute permission: chmod u+x script.sh
  3. run the script by double clicking or ./script.sh
no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here