Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[Solved] GnomeShellExtension desc. with correct layout

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
Allain
Posts: 20
Joined: 2016-12-06 13:55

[Solved] GnomeShellExtension desc. with correct layout

#1 Post by Allain »

Hello everyone

I am creating a script to install gnome shell extensions
I get an issue to get the description from the info page
ie this one :
https://extensions.gnome.org/extension- ... rsion=3.14

if i use "| grep description" after a "wget" i get only the first line of the description
Some gnome shell extensions have a description on one line only, some not

Using the above url i get a result but i loose the layout of the description. i see only \n instead of new lines :

Code: Select all

cat gnome_shell_extensions/extn | grep -v "\"version" | grep -v "\"screenshot" | grep -v "\"creator" | grep -v "\"name" | grep -v "\"link" | grep -v "\"download" | grep -v "\"icon" | grep -v "\"uuid" | grep -v "\"pk" | sed 's/" /"/g' | sed 's/"description": //g' | sed 's/"//g'
Result :
A Gnome shell interface for todo.txt. \n\nTodo.txt is a future-proof syntax for tasks (not made by me)
for more info: http://todotxt.com/\n\nSome examples:\nTask: Basic task\n(A) Task: High priority task\nTask @project +context: Task is part of project and has a certain context\nx 2013-08-22 Task: Task was completed on the 22nd of August\n\nFor more info about the syntax: https://github.com/ginatrapani/todo.txt ... t\n\nQuick start:\nWhen you first enable the extension
chances are high you'll see a [X] in your top panel. If you click the [X]
you will be able to choose between creating the necessary files automatically or selecting your own existing files to be used with the extension.\n\nPlease use the issue tracker on the homepage to report bugs and/or file feature requests
this makes tracking easier for me. Thanks!\n\nSee the included CHANGELOG.md for info about changes between different versions
or see it online: https://bitbucket.org/bartl/todo.txt-ba ... ANGELOG.md
using

Code: Select all

sed 's/\n/\n/g' does nothing
Who knows a better way to get the complete description with a correct layout ?
Last edited by Allain on 2017-06-04 16:48, edited 1 time in total.

Dai_trying
Posts: 1100
Joined: 2016-01-07 12:25
Has thanked: 5 times
Been thanked: 16 times

Re: get a gnome shell extension description with correct lay

#2 Post by Dai_trying »

You could install jq (it's in the repo) and then something like

Code: Select all

curl -s 'https://extensions.gnome.org/extension-info/?pk=570&shell_version=3.14' | jq -r '.description'
I'm using curl here but I'm sure you can just use this as an example and modify it accordingly.

Allain
Posts: 20
Joined: 2016-12-06 13:55

[Solved] get GnomeShellExtension description with correct la

#3 Post by Allain »

Hooo that is magic Dai_trying !

Anyway you give the first answer to all my questions on Debian User Forums
I have the habit to find the answer myself since nobody is answering.

A big thank you to you
It solved my problem

Dai_trying
Posts: 1100
Joined: 2016-01-07 12:25
Has thanked: 5 times
Been thanked: 16 times

Re: [Solved] GnomeShellExtension desc. with correct layout

#4 Post by Dai_trying »

You are welcome :)

Allain
Posts: 20
Joined: 2016-12-06 13:55

Re: [Solved] GnomeShellExtension desc. with correct layout

#5 Post by Allain »

Anyway...

Can't sed or tr do this ?

Dai_trying
Posts: 1100
Joined: 2016-01-07 12:25
Has thanked: 5 times
Been thanked: 16 times

Re: [Solved] GnomeShellExtension desc. with correct layout

#6 Post by Dai_trying »

Quite possibly, but as this looks to me like json it seemed a good idea to use a parsing tool to separate the information.

User avatar
dasein
Posts: 7680
Joined: 2011-03-04 01:06
Location: Terra Incantationum

Re: [Solved] GnomeShellExtension desc. with correct layout

#7 Post by dasein »

Allain wrote:Anyway...

Can't sed or tr do this ?
Yes and no (respectively). In particular, tr is meant to work on single characters, not multiples. Some versions of tr are said to be able to process multiple characters, and for all I know those claims may be true. I'm just not prepared to devote brain cells to remembering which version(s) of tr claim to do which thing(s).

OTOH, sed would do the job nicely, without the need for unnecessary package installation.

Code: Select all

sed 's/\\n/\n/g'
To process a file in place:

Code: Select all

sed -i 's/\\n/\n/g' input_filename
Notice that your hunch on sed syntax was very close to right.

Allain
Posts: 20
Joined: 2016-12-06 13:55

Re: [Solved] GnomeShellExtension desc. with correct layout

#8 Post by Allain »

Code: Select all

sed -i 's/\\n/\n/g' input_filename
is fine
i just missed a \

but i get only the first line of the description
some descriptions have multiple lines
and i must use all the grep -v you saw above

the only solution for now is using jq to get the complete description
and checking if the jq package exists

thank you correcting my mistake with sed

Post Reply