In this post I will show how to control time access to the Linux desktop. This was needed for my son as a kind of parental control for his Fedora Core 16. Good news is that nothing should be installed because all tools and mechanisms already exist on system. With a little configuration across few files, Linux desktop will be locked for GUI login in defined period of time.
I tested this procedure on Fedora Core 16 and Fedora Core 17. The main idea is to lock PC after 10:00PM. PC should be turned off and Marko should go to the bed . Shutting down PC is simple with root crontab scheduler. "su" to the root and open crontab:
$ su # crontab -e
After root crontab is opened, write the following lines and save:
# turn off PC at 10:00PM 0 22 * * * /sbin/poweroff
I also want to be nice dad and send few warnings to the boy before PC will be turned off. So I "su" to Marko's account and write jobs to his crontab:
$ su # su - mbunic $ crontab -e
Here are "zenity" lines placed in his crontab (this will show popup windows 10 and 5 minutes before shutdown):
# warnings before shutdown 55 21 * * * /usr/bin/zenity --warning --text "Dear Marko, 5 more minutes" --display=:0.0 50 21 * * * /usr/bin/zenity --warning --text "Dear Marko, 10 more minutes" --display=:0.0
Now is needed to include PAM time module in /etc/pam.d/gdm-password file (not gdm but gdm-password). Open gdm-password and instead of "pam_nologin.so" add "pam_time.so" line:
#account required pam_nologin.so account required pam_time.so
PAM stands for Pluggable Authentication Modules and you can find a lot of documents for other modules as well. Finally, add the line to the /etc/security/time.conf file. This will define access time from 9:00AM to 10:00PM:
With this configuration, mbunic user (Marko) will not be able to login after 10:00PM. Fedora will display two nice warnings and shutdown at exactly 10:00PM. If Marko will try to turn on PC after 10:00PM, PC will boot but he will not be able to log in ...