0

I'm using a raspberry pi for a digital art project by displaying images in a ascii form on a monitor but I would like it to rotate through random images in the folder every hour. I have a bash script set up to just run the basic command down below.

ascii-image-converter Pictures/IMAGE HERE.png -c -C --color-bg -f -m " .-=+!@#$%&*()"

How would I add a random function to this command and time the bash script to run at certain intervals?

frippe
  • 1,329
  • 1
  • 8
  • 15
  • 3
    You're asking two different questions, both of which have already been answered on stackoverflow, so check them out: picking random file/folder) https://stackoverflow.com/questions/414164/how-can-i-select-random-files-from-a-directory-in-bash, scheduling) https://stackoverflow.com/questions/16543715/how-to-schedule-an-action-in-python. In addition to `cron`, there's also `systemd-timers` (and other packages), but `cron` is quicker and easier to get started with. – frippe Mar 04 '22 at 06:23
  • For randomness, see the bash variable `RANDOM` and the device `/dev/urandom`. – user1934428 Mar 04 '22 at 06:44
  • BTW, before I closed it as a duplicate, this question was on a route towards being closed as too broad to be on topic. Only one specific, narrow technical problem to a single Stack Overflow question -- if you have two technical problems, ask two separate questions, after searching for existing questions answering each of those smaller problems! – Charles Duffy Mar 04 '22 at 14:34
  • I really do recommend using systemd timers if your operating system uses systemd. Not only do they have more features than vixie cron, but they work without needing cron installed so you don't need an extra daemon, and the same tools you use for checking status and logs of other services work for scheduled jobs. – Charles Duffy Mar 04 '22 at 14:56

0 Answers0