Parental controls

28 Aug 2020

I haven’t put too much thought on parental controls, and I’m not sure I fully agree with it. Either way, recently I began giving my 2-year-old one small dose of 30 flexible minutes of screen time using mpv and a few handmade Bash and Lua scripts.

The first step was to assemble playlist files and place them in a “playlists” folder. Then I use a shell script for prompting the user to pick one. When selected, the tracks are played randomly in fullscreen with a clock and stopwatch on the top left corner of the window.

To do this, I created both a Lua script file called track-time.lua in ~/.config/mpv/scripts with the following lines:

local opts = {
   show_time = "no",

local options = require 'mp.options'

if opts.show_time == "yes" then
   local secs = 0
   timer = mp.add_periodic_timer(1, function()
                                    local time =" %H:%M ")
                                    local elapsed ='!%T', secs)
                                    secs = secs + 1 end)
   function pause_timer(name, value)
      mp.add_timeout(0.1, function()
                        if value == true then
                           timer:stop() else timer:resume()
   mp.observe_property("pause", "bool", pause_timer)

And an executable file called “playlist” with the following lines:


cd ~/playlists || exit

select file in $(find -- *); do
    mpv --script-opts=track_time-show_time=yes --shuffle --fs --playlist="$file"

I’m actually using something more graphical for the sake of others who are also using the program, but you get the idea. In any case, you can open the playlist from the terminal or create a desktop application for it.

Of course, playing outside and eating mud is still a better choice, but if you need to introduce some screen time for your little one, and assuming you know your way around Linux/UNIX, the solution presented here may be a good place to start.

Other posts