NAME

parctl - parental control for parents

SYNOPSIS

parctl [--config file] [--help] [--man]

DESCRIPTION

parctl monitors and limits computer usage ("tube time"). Programs like this are typically used to prevent children from spending too much time over their digital gadgets. The same paradigm has, however, proved to be effective with adult specimen as well, particularly middle-aged computer scientists.

The modus operandi is as follows. The user is given a time quota called slack for every 24 hours. Whenever the user is interacting with the machine, parctl decreases the slack by the corresponding wall clock time. For example, if the user interacts with the machine for 30 minutes, parctl removes 30 minutes from the slack. "Interaction" is defined as "typing on the keyboard or using the mouse".

parctl resets the slack at a certain reset time each day. If the slack gets used up before that, parctl unconditionally suspends the machine. After that, the machine will be practically unusable until the reset time: wake-ups from the suspend will soon cause a re-suspension.

If the user does not interact with the machine for a certain period of time, parctl goes to idle mode and stops consuming the slack. During idle mode, parctl assumes that the user is away from the machine. When the user starts interacting with the machine again, parctl ends idle mode and resumes slack consumption.

parctl displays the remaining slack continuously in a simple window, and warns the user if they are running out of slack. Note that parctl is an X11 application and hence requires a running X session: true terminal junkies are considered hopeless and unsalvageable.

The author acknowledges certain special cases which call for exceptions, such as intense emacs(1) hacking or other "critical system upgrades", when the system simply cannot be suspended. In such dire circumstances, the user can selectively disable the slack consumption by switching to grace mode. Of course, the real need for such a blunt measure should be sagaciously evaluated each and every time.

The author also acknowledges certain use cases where the user mostly sits around the machine, gazing and immersing whatever audiovisual or other electromagnetic energy is being emitted by the device. Such activity is called consuming, and parctl can be told when consuming is in progress. During consuming, parctl decreases the slack unconditionally, regardless of any physical interaction with the machine. In other words, parctl does not go into idle mode at all.

Slack Modes

parctl has two different modes for slack:

In deadline mode parctl does not go into idle mode at all, and consuming mode is not available. However, grace mode is available: it effectively extends the deadline by the amount of time spent in grace mode.

The slack mode and slack, reset and deadline times are all configurable.

User Interface

At startup parctl opens a single window that continuously displays the remaining slack with one second precision. Window background color depends on the current mode:

The aforementioned colors and the corresponding slack limits are configurable.

Grace mode can be toggled by clicking on the window with mouse button 2.

Consuming can be toggled by clicking the window with mouse button 3. If parctl is consuming, the remaining slack is displayed in boldface font.

When the mouse cursor is hovering over the slack label, a tooltip shows the time of system suspension, or an indication of grace mode when it is on.

In addition to slack, parctl can also display the current date and time, time of sunrise and sunset, and the age of the user in days. These features are only visible if configured so.

CONFIGURATION

Most parctl parameters can be configured in a configuration file. In startup, parctl reads two configuration files: its default configuration file $PERLLIB/ParCtl/config.ini and the user configuration file $HOME/.parctl.ini, if it exists. (Here, $PERLLIB refers to the Perl library directory where ParCtl is installed.)

A different user configuration file can be specified with command line argument --config. Any settings given in the user configuration file override the corresponding default settings.

Configuration files are plain text files in INI-format, as understood by Config::Tiny(3) module:

The default configuration file $PERLLIB/ParCtl/config.ini is a useful template for a new user configuration file.

In general, parctl should not require any user configuration unless you are not satisfied with the defaults. Suspend command (see System Suspend below) may require tweaking if you are not on a Linux-based system.

The following sections are recognized when reading configuration files. Examples below show the default values (note that sections may be commented out by default).

Features

[features]
parctl=true
datetime=false

Settings in features section control which parctl features are visible:

Slack

[slack]
mode=fixed
initial=02:00:00
deadline=22:00:00
reset=04:00:00
utc=false

These settings control slack allocation and tracking (see Slack Modes above):

All times must be given in HH:MM:SS format.

Time Limits

[limits]
vulnerable=00:15:00
endangered=00:10:00
critical=00:02:00
idleness=00:01:00

These are time limits for different slack modes. See Slack Modes above for details.

idleness is the required amount of inactivity after which parctl goes to idle mode.

All times must be given in HH:MM:SS format.

System Suspend

[suspend]
command=systemctl suspend

command is the command executed to suspend the system when slack goes to zero. Note that parctl must be run with enough privileges to execute this command.

Date and Time Formats

[formats]
date=%x
time=%X
slack_hm=%H:%M
slack_ms=%M:%S

These are expected to be strftime(3) compatible format strings. parctl uses them to construct various date and time strings:

Fonts

; [fonts]
; font_family=Serif
; font_size=16
; tooltip_font_family=Serif
; tooltip_font_size=10

These settings configure fonts for labels and tooltips. If they are not given, Tk(3pm) defaults will be used.

Geographical Location

; [location]
; latitude=60.1666
; longitude=24.9435

This is the geographical location (latitude and longitude) of the user in decimal format. When a location is configured, parctl calculates the time of sunrise and sunset, time of day, and the duration of daylight or darkness. This information is displayed in time tooltip. Hence, datetime feature must be also enabled.

Date of Birth

; [date_of_birth]
; day=1
; month=1
; year=1970

These settings specify the date of birth of the user. If configured, parctl calculates the age of the user in days and displays that in date tooltip. Hence, datetime feature must be also enabled.

Colors

[colors]
idle=green
vulnerable=yellow
endangered=red
grace=deepskyblue
; background=gray
; foreground=black
; tooltip_background=yellow
; tooltip_foreground=black

These define background colors for slack modes (see Slack Modes above). Least concern mode uses the given background color. If unspecified, parctl uses Tk(3pm) defaults.

OPTIONS

--config=file

Read configuration from file instead of $HOME/.parctl.ini.

--help

Display short command line help and exit.

--man

Display parctl manual page and exit.

SIGNALS

SIGINT and SIGTERM cause immediate program termination. SIGUSR1 causes parctl to reload configuration files and reset the state as it would do in startup.

RESTRICTIONS

The user must be allowed to run suspend command without separate authentication.

Geographical location cannot be acquired from GPS receiver or other geolocation device.

Configuration settings are not validated. For example, it is possible to specify a nonsensical geographical location, or a date of birth that is in the future. Consider yourself being warned.

BUGS

Yes.

COPYRIGHT AND LICENSE

Copyright 2017, 2021-2023 Petteri Hintsanen <petterih@iki.fi>

This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

sudo(8), pm-suspend(8), systemctl(1), zzz(8)