You are not logged in.
So right now I have vlc to be my alarm clock in the morning, through a cron job. It plays video file I have really loud, and that wakes me up. However, I have to keep on changing which video file to use, because I find myself getting used to whatever is selected after a few days.
So what I want to do is have it randomly play a video file, with a different one each morning.
What I tried doing was running the command:
ls ~/Desktop/ | shuf | vlc -f --volume=1024 &
in my crontab (I removed the earlier parts of the line to prevent confusion), but that doesn't work. I think the issue is that vlc tries to directly play the output of shuf, and it can't, since it plays video files, not text files.
So how can I do this?
Last edited by zenten (2012-08-29 15:05:01)
Offline
What about something like this?
vlc -f "~/Videos/$(ls -U ~/Videos/ | shuf -n 1)"
| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |
Offline
What about something like this?
vlc -f "~/Videos/$(ls -U ~/Videos/ | shuf -n 1)"
OK, I tried that. It's not working. Pretty much all the file names have spaces, and it looks like somewhere in all that those are getting escaped in a way that vlc can't handle.
Offline
OK, it looks like there were two things going on. One is that it can't handle spaces (and I haven't figured out a way around that). The other is that in the first part it doesn't know how to expand the ~.
So I got the following working, but I would still like to be able to have a broader selection than just directories and filenames with no spaces:
vlc -f --volume=1024 "/home/zenten/Desktop/kidstv/My.Little.Pony/$(ls -f ~/Desktop/kidstv/My.Little.Pony/ | shuf -n 1)"
Offline
Parsing the output of ls is generally a bad idea. It may or may not be the problem here, but it's something you shouldn't get in the habit of doing in any case.
If possible, try something like:
songs=(/path/to/Videos/*)
vlc -f "$( printf "%s\n" "${songs[@]}" | shuf -n1 )"
Edit: Doh! Better yet:
vlc -f "$( find /path/to/Videos | shuf -n 1 )"
I don't have vlc installed so I can't guarantee will work there. But both worked with ristretto and gimp on images with spaces in the names.
Last edited by alphaniner (2012-08-29 15:04:15)
But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner
Offline
Parsing the output of ls is generally a bad idea. It may or may not be the problem here, but it's something you shouldn't get in the habit of doing in any case.
If possible, try something like:
songs=(/path/to/Videos/*) vlc -f "$( printf "%s\n" "${songs[@]}" | shuf -n1 )"
Edit: Doh! Better yet:
vlc -f "$( find /path/to/Videos | shuf -n 1 )"
I don't have vlc installed so I can't guarantee will work there. But both worked with ristretto and gimp on images with spaces in the names.
Thanks, that seems to work!
Offline