Screen time management

Hi everyone,

I’m the proud father of 2 teenagers, and I’d like to know if it’s possible to set screen time limits according to the user (e.g.: login only allowed between 7am and 8pm, with a limit of 1 hour/day on weekdays and 2 hours on weekends).

Thank you for your help.

You might use pam_time module to allow access only on certain days/hours to certain users.

In order to limit usage time, mh, I don’t know.

1 Like

You could also take a look to parental control integrated in GNOME (malcontent), although it doesn’t allow to manage allowed time spent on computer.

Eventually there is this application that looks interesting

https://mjasnik.gitlab.io/timekpr-next/

But it is not packaged in the Fedora repository. There is a COPR.

Or you can make something handmade. DIY

mkdir /home/childuser/.config/autostart

Create a .desktop file /home/childuser/.config/autostart/timer.desktop containing

[Desktop Entry]
Type=Application
Name=Scripts
Exec=/usr/local/bin/timer.sh
Terminal=false
StartupNotify=false
Categories=Application;
X-GNOME-Autostart-enabled=true

And the script doing the work /usr/local/bin/timer.sh

#!/bin/bash

# Session duration 600 cycles (seconds)
MAX=600
TIMER=$MAX
# Show a warning when 10 cycles (seconds) remaining
WARNING=10
COUNT=0
# Show a notification every 60 cycles (seconds)
NOTIFICATIONINTERVAL=60

zenity --warning --text="The session will last $TIMER seconds" --timeout=5 &

while [ $TIMER -gt 0 ]
do
 let TIMER=$TIMER-1
 let COUNT=$COUNT+1
 if [ $COUNT -eq $NOTIFICATIONINTERVAL ]
 then
  if [ $TIMER -eq $WARNING ]
  then
   zenity --warning --text="Only $TIMER seconds left" --timeout=10 &
  else
   zenity --notification --text="$TIMER seconds left"
  fi
  COUNT=0
 fi
 sleep 1
done

gnome-session-quit --logout --force --no-prompt

The script forces the logout after 5 minutes, it displays a notification every 60 seconds, and a dialog when there are 10 seconds left (and an initial dialog which warns how long the session will last).

In order to avoid unwanted modifications, sudo chown youruser:youruser /usr/local/bin/timer.sh /home/childuser/.config/autostart/timer.desktop

Ok, I’m not very well-versed in math :confounded: neither in bash scripting, but this could be a good start if you will not find something better and more solid. :slight_smile:

1 Like