The officially official Devuan Forum!

You are not logged in.

#1 2022-02-13 03:02:06

zapper
Member
Registered: 2017-05-29
Posts: 606  

Script for starting application and picking random folder to do it in

Basically, its like this thread:

https://dev1galaxy.org/viewtopic.php?id=4380

Except, I want it to be able to function with more than just playing a random audio or video file.

Same conditions mostly apply, its for Hyperbola mostly. 

But if it works with Devuan too, cool!

smile


Black Lives Matter!  I am white, but I prefer equality over hatred.
Haughtiness comes before a fall, pride before destruction.
Peace be with you!
No one can serve two masters. Either you will hate the one and love the other, or you will be devoted to the one and despise the other. You cannot serve both God and mammon!

Offline

#2 2022-02-13 10:58:32

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: Script for starting application and picking random folder to do it in

zapper wrote:

I want it to be able to function with more than just playing a random audio or video file

That's a little vague, can you explain more? See also http://www.catb.org/~esr/faqs/smart-questions.html & https://xyproblem.info/

dice's script could be generalised a little:

#!/bin/sh
find /path -type f -name "*.$1" | shuf -n 1 | xargs -d "\n" "$2"

Replace /path with the actual path under which you want the search to be performed and run the script with the first argument being the desired suffix of the files and the second argument being the application to be run.

So if the script was saved to /usr/local/bin/random-run and you wanted to open a random PNG file you would run

random-run png feh

Does that help?

EDIT: or use xargs -d "\n" xdg-open, which should use the file MIME type to determine the appropriate application, and then just pass the desired file suffix to the random-run script.

Last edited by Head_on_a_Stick (2022-02-13 13:57:59)


Brianna Ghey — Rest In Power

Offline

#3 2022-02-14 03:56:43

zapper
Member
Registered: 2017-05-29
Posts: 606  

Re: Script for starting application and picking random folder to do it in

In particular, there are two interests, loading certain .txt files via something like focuswriter or l3afpad

That's what I was thinking of at this time, though in the future idk?


Black Lives Matter!  I am white, but I prefer equality over hatred.
Haughtiness comes before a fall, pride before destruction.
Peace be with you!
No one can serve two masters. Either you will hate the one and love the other, or you will be devoted to the one and despise the other. You cannot serve both God and mammon!

Offline

Board footer