I have been running Linux in my businesses and at home for over 8 years now.
One of the issues I have ran into is trying to limit the time my kids spend on the computer.
I wanted to be able to configure something to limit the sessiontime to 30 mins per day. My version of parental control. Yeah! Take that Kids!!
I have 3 kids (ages 12,11 & 7), each with separate username / passwords on a machinerunning Fedora Core 8 with KDE desktop.
Actually the machine had both Gnome and KDE installed on it, since that is FC default when installing.
This presented some additional issues after I initially got the first version of the script working.
My kids quickly figured out if they logged into the GNOME desktop the script didn't kick them off after 30 mins.
So I had to figure out a way to remove the GNOME session option from the KDM login manager.
Please see information below.
I started looking for a solution but I never found exactly what I was looking for,so I pieced some information together to come up with this solution.
Please let me know if this solution is helpful or if you have suggestions or comments.
| 1. | #!/bin/bash |
| 2. | dia=`date +"%d"`< |
| 3. | ultimo=`cat ~/.kde/sessao` |
| 4. | if [ "${dia}" == "${ultimo}" ] ; |
| 5. | then |
| 6. | kdialog --title "TIME LIMIT EXCEEDED" --error "You already use your time today!!!" & |
| 7. | sleep 10 |
| 8. | ps -p $! 2>&1 > /dev/null |
| 9. | #Grab the status of the ps command< |
| 10. | status=$? |
| 11. | #A value of 0 means that it was found running |
| 12. | if [ "$status" == "0" ] |
| 13. | then |
| 14. | kill $! |
| 15. | fi |
| 16. | dcop ksmserver ksmserver logout 0 0 0 |
| 17. | exit 1 |
| 18. | fi |
| 19. | echo ${dia} > ~/.kde/sessao |
| 20. | # Initial time delay (less 2 mins) |
| 21. | sleep 28m |
| 22. | kdialog --title "WARNING TIME EXPIRED!!!" --error "Time to log off - You have 2 mins to log off" & |
| 23. | sleep 1m |
| 24. | ps -p $! 2>&1 > /dev/null |
| 25. | #Grab the status of the ps command |
| 26. | status=$? |
| 27. | if [ "$status" == "0" ] |
| 28. | then |
| 29. | kill $! |
| 30. | fi |
| 31. | kdialog --title "WARNING TIME EXPIRED!!!" --error "Time to log off - You have 1 min to log off" & |
| 32. | sleep 1m |
| 33. | ps -p $! 2>&1 > /dev/null |
| 34. | #Grab the status of the ps command |
| 35. | status=$? |
| 36. | #A value of 0 means that it was found running |
| 37. | if [ "$status" == "0" ] |
| 38. | then |
| 39. | kill $! |
| 40. | fi |
| 41. | # Force log off |
| 42. | dcop ksmserver ksmserver logout 0 0 0 |