Keep disk awake for VLC playing - v. 3
VLC hanging during play?
The scenario is quite common:
- A Mac running Ventura (or earlier) Mac OS
- An external disk (let’s say USB) connected
- VLC playing a movie stored on such disk
In this case it could happen that disk goes to sleep (this normally happens after 10 seconds without access) and the movie freezes a few seconds while the disk respins for buffering.
- A first solution is “copy the file on your HD and play it from there".
But I wanted to play my files on their disk, without copies.
- Another solution could be caffeine app
But in this case the Mac would stay awake forever, while want to keep my Mac (and my disk) awake if and only if VLC is playing, and only for the involved disk, without any further action.
My solution (v. 3)
The solution is a simple script that will run indefinitely:
- checking every 5 seconds if VLC is running and is playing a movie
- else checking every 30 seconds for VLC playing:
- checks if VLC is running, if true…
- checks if VLC in playing, if true…
- Asks VLC for movie path and sets refresh time to 5 seconds
- in case VLC is playing (every 5 seconds) performs a read access to movie’s disk root to keep it awake
You can download the script, unzip it, go to its folder with Terminal and run the command:
The script is copied in
/usr/local/bin/keepDiskAwakeForVlcPlaying and added to Login Items.
When first VLC playing event occurs while the script is running you’ll be asked to give “perl” the permission to interact with VLC.
Of course say yes.
Here follow both the script (compressed) and its source, if you want to do it on your own.
In case you decide to create the script from source, don’t forget to make it executable.
The script includes the installer.