You are not logged in.
Hello,
I am developing a GUI application that retrieves applications' information from arch repository interface as json format, now i want to show some random packages to user when he scrolls, but i found no option to do it,
please any idea ?
Last edited by mamograg17 (2022-08-27 13:07:27)
Offline
pkgname=$(pacman -Ssq | shuf | sed 1q)
Or, without more context, perhaps something like this would suffice.
Last edited by Trilby (2022-08-27 12:59:54)
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
pkgname=$(pacman -Ssq | shuf | sed 1q)
Or, without more context, perhaps something like this would suffice.
That's it!
Thank you, i'll put the packages' output in a string and get it information and show it.
Offline
Okay ... I'm glad that helped ... kinda'
I doubt you are writing this application in bash. So this was rather more to clarify the question. I find it unlikely that you'd be using a programming language without knowing how to select a random element from a list in that language. So I'm not sure how showing it being done in bash (which is a poor way of doing it) could be all that useful.
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
Okay ... I'm glad that helped ... kinda'
I doubt you are writing this application in bash. So this was rather more to clarify the question. I find it unlikely that you'd be using a programming language without knowing how to select a random element from a list in that language. So I'm not sure how showing it being done in bash (which is a poor way of doing it) could be all that useful.
Actually no, I am not writing in bash, I use C++ to make a GUI package manager.
Actually I know how to get a random thing in C++ but it wasn't helpful in my situation, cause I want a correct name to display.
Offline
pkgname=$(pacman -Ssq | shuf | sed 1q)
Hello again, the command works perfectly but I have a little problem, how can I get popular only packages because this command gives me some unpopular tools, please any idea.
Offline
Actually I know how to get a random thing in C++ but it wasn't helpful in my situation, cause I want a correct name to display.
And if you select a random item from the list in C++, you'll have a correct name to display. I'm just not sure how a bash example of selecting a random item from a list helps with a C++ project.
how can I get popular only packages because this command gives me some unpopular tools, please any idea.
What do you mean by popular? The repo databases and web interface has no "popularity" data. But in any case, once you define what popular is, it's still the same situation that you just need to select a random item from a list which in a shell could be done by piping to shuf and sed (or head) but that's completely irrelevant for C++ code.
Last edited by Trilby (2022-10-01 20:00:07)
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
how can I get popular only packages because this command gives me some unpopular tools, please any idea.
What do you mean by popular? The repo databases and web interface has no "popularity" data. But in any case, once you define what popular is, it's still the same situation that you just need to select a random item from a list which in a shell could be done by piping to shuf and sed (or head) but that's completely irrelevant for C++ code.
getting the name that the command outputs is easy, by popular i mean applications like chrome, brave, telegram, steam... you can say most downloaded.
but you said that there is no poplarity data.
Offline
by popular i mean applications like chrome, brave, telegram, steam...
Eh, okay, if you really want to define it that way:
printf "%s\n" chrome brave telegram steam | shuf | sed 1q
you can say most downloaded.
I can say a lot of things. You need to decide what you want. Pkgstats has a json API and provides a "popularity" metric, but it is not based (directly) on the most downloaded.
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
I can say a lot of things. You need to decide what you want. Pkgstats has a json API and provides a "popularity" metric, but it is not based (directly) on the most downloaded.
i think that's what i need, how can i use it please?
Offline
Offline