The officially official Devuan Forum!

You are not logged in.

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

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

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


Freedom is never more than one generation away from extinction. Feelings are not facts
If you wish to be humbled, try to exalt yourself long term  If you wish to be exalted, try to humble yourself long term
Favourite operating systems: Hyperbola Devuan OpenBSD
Peace Be With us All!

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: 853  

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?


Freedom is never more than one generation away from extinction. Feelings are not facts
If you wish to be humbled, try to exalt yourself long term  If you wish to be exalted, try to humble yourself long term
Favourite operating systems: Hyperbola Devuan OpenBSD
Peace Be With us All!

Offline

Board footer