Author Archives: Todd Partridge

About Todd Partridge

Society first.

gt—create a gedit scratchpad


I am really lazy with my editors. I have aliases in my shell configuration for gedit and vim to open them as quickly as possible:

alias v="vim -p"
alias sv="sudo vim -p"
alias g="bgcmd gedit"
alias sg="bgcmd gksudo geany"

This is very nice for me because I use my editors quite a bit. One thing I needed though was a command that would create and open a temporary file in gedit. The main reason for this is that, there are times, I don’t know how to name or place the file properly yet. At other times, the reason is, I like to have a scratchpad that would save information that I might forget if it was just a new file and I forgot about it or a crash happened.

The bash script

Running gt will create and open a file named with the current time (MMDDhhmm) and will be saved in the trash folder. If gt is followed by a name (e.g. gt the name will be appended to the time.


The name is helpful if wanting to dig the file out of the trash folder at a later time.

# (g)edit (t)emp. file — create gedit scratchpad

tme_day=$(date +%m%d%H%M)

[ ! -d "$tmp_dir" ] && mkdir -pv "$tmp_dir"

# gedit existence test
hash gedit 2>&- || { echo "Requires program \"gedit\"."; exit 1; }

# Usage
if [ "$1" = -h -o "$1" = --help ]; then
  echo "${0##*/} [name1] [name2*] — create a gedit scratchpad"
  exit 2

if [ "$1" ]; then
  for name in "$@"; do
    nohup gedit "$tmp_dir"/"$tme_day"-"$name" &> /dev/null &
  nohup gedit "$tmp_dir"/"$tme_day" &> /dev/null &

Write The Fine Manual with pod2man

Disclaimer: This is a guide for basic manual writing. It uses a simple markup language and converter to create a manual. It is good for beginners. For a good general overview of man pages read this, for more common approaches to writing manuals read this post.

An example

To get a good idea of how to write a manual seeing the markup of a POD (Perl’s Plain Old Document) works well. This is a POD for a fictitious program called dr-smile:

=encoding UTF8

=head1 NAME

dr-smile — output platitudes to help to improve one's mood


dr-smile [B<--happy>] [B<--joke>=F<type>]


B<dr-smile> outputs jokes and happy thoughts designed to make one feel F<--better>. It has the ability to output pleasant thoughts, jokes, good memories, optimistic fortunes, or just give you a big hub. B<dr-smile> is for I<entertainment> and for light mood change requirements. Please use responsibly and with greater change requirements please see an appropriate professional. Additional options are available in the configuration file F</etc/dr-smile.conf>.

=over 4

=item B<-h>B<--happy>

A general happy thought will be output (e.g. C<dr-smile --happy>).

=item B<-j> F<type>B<--joke>=F<type>

A good-sense joke will be told.  The types are: F<knock> and F<oddball>.  Read more in B<jokes(1)>.


Text formatting

Man pages are mainly created with these types of formatting:

Format Markup
bold B<text>
italic I<text>
link L<http://address.domain >
file name F<file-name>
email E<name@address.domain>

Note: E<> is technically for escapes, however, I have seen it used before in another pod2man document—whether intentional or not I am not sure. Read the manual perlpod for markup information.

From a general observation over the years, bold and italic formatting get used in these situations:


  • program names
  • options
  • other manuals


  • keywords
  • emphasis
  • arguments
  • occasionally manuals

Category formatting

Manual page categories are generally formatted with a certain order. The order of categories vary a bit per man page but the first four are usually present. Here is the general structure and their purpose

  The name of the command followed by a one-line description of what it does.
  A command's invocation with its listed options, or a functions parameter listings with its header file.
  An in-depth explanation of the command or function.
  A explanation(s) of what an option does these are sometimes put in the DESCRIPTION.
  Some examples of common usage.
  Files related to the command or function.
  List of known bugs.
  A list of referenced or related commands.
  Information about the author...

For how to create the categorical entries, I only know the basic formatting. Look at the above example to see how it is done.

  • Category begin is defined with the head1 tag.
  • Indenting is done with the over 4 tag.\
  • Category item is defined with the =item tag.
  • Category end to define a new category is done with the =back tag.

Document to manual conversion

pod2man usage is basic. First look at manual section definitions here to know what section it should belong to. For my miscellaneous, fictitious program:

pod2man dr-smile.pod > dr-smile.7

Additional information may be wanted to add to the manual along with compression:

pod2man --section=7 --center="General Commands Manual" --release="1.0" \
dr-smile.pod | gzip > dr-smile.7.gz

To view the man page use man -l dr-smile.7.gz.



xuserrun—run a command as the currently active server user

xuserrun is a bash script to detect the first server environmental values, these values are then used to transmit a command to it. The script is primarily useful from another environment: a different user, from the tty console, from cron, a boot script…. xuserrun requires systemd.

Running it is basic:

xuserrun xclock -digital

Another example:

xuserrun notify-send "Remember to get bread."

I have put it in its own repository.

Audio file encode to a video file

I wanted to convert an MP3 file to a video file to be able to use it on my PS3. The PS3 has an audio player but it doesn’t remember the position. It was an audiobook so it was best for me to convert it to a video file.

# Create video file from audio file.

# Required programs.
if ! hash ffmpeg 2>&- ; then
  echo "Requires program: ffmpeg"; exit 1; fi

# Usage.
if [ $# != 2 ] ; then
    echo "${0##*/} <image> <audio> - create video file from an audio file."
    exit 1; fi

# Files existent test.
if [ ! -f "$1" ] ; then
    echo "non-existent image: "$1""
    exit 1; fi
if [ ! -f "$2" ] ; then
    echo "non-existant audio: "$2""
    exit 1; fi

ffmpeg -f image2 -loop 1 -i "$1" -i "$2" -c:v libx264 -tune stillimage 
  -c:a copy -strict experimental -shortest "$vid_nme"

#ffmpeg -f image2 -loop 1 -i "$1" -i "$2" -c:v libx264 -tune stillimage 
#  -c:a aac -strict experimental -b:a 192k -shortest "$3".mp4

Monitor Hardware Calibration


A calibrated monitor will help images feel more natural and will help ease eye strain with tasks like reading. It may be preferable to some that when a new monitor is acquired to have it calibrated. This is a guide to show how to do such.

My Experience

I read documents on my computer all the time and occasionally do graphic design work. I appreciate having a calibrated monitor. I have a background in developing color photography which has helped my eye to recognize correct image reproduction. I have also worked for computer laboratories that has allowed me to calibrate a good number of varying monitors. Others will know more than me, however, this should be a good layman’s approach.

Monitor Setup Knowledge

  • the monitor should be left on ten+ minutes to let the bulb warm up to its standard operating color
  • the monitor’s angle at which it is viewed is important, for older or less expensive monitors a non-direct view of a few degrees can effect the display image… angle the monitor so that it is perpendicular to the eyes
  • hardware calibration should come before any software calibration, and software calibration only when necessary… hardware calibration would be helped if software calibration were disable beforehand
  • some monitor controls are extracurricular, eg better flesh tone or crushing black levels… for initial setup these controls should be turned off
  • some images are scalable so they can be view accurately at full screen, I would recommend doing so to help with one’s attention

Gamma Correction

Gamma Correction is an adjustment of the mid-luminosity level of the bulb to correct for a light source that is unique (ie not the sun) that the natural eye adjusts to non-linearly. A monitor that needs Gamma Correction the display will look light and glowy; excessive Gamma Correction will look dark and over-saturated. Most monitors today use the 2.2 sRGB Gamma Correction standard.

The test image displays four channels for setting Gamma Correction: a composite, red, green, and black. This image will need to be viewed in its original size, ie 100%, for it to work correctly.

Some monitors have Gamma Correction controls; for others it may be tied to the RGB controls… and some monitors will require to have it set with a software program. Adjust the controls up and down and match the circle luminosity to the surrounding area.


If changing the RGB controls do not effect gamma, I would recommend a software calibrator; proper gamma correction is essential to proper monitor output. For Linux xgamma can be used, and Windows has its own calibration tool. (As a side note: this test works because the brain averages the black and light lines of the background to an aggregate luminosity; the circle is a 73% luminosity.


Contrast, sometimes called Picture or White Level, defines the luminance range of a monitor. A contrast that is high would have lightness-values extended to black or white; a contrast that is low would lightness-values toward middle grays.

The test image displays columns of circles with increasing lightness toward the center of the image. The center circle has a lightness of 254/255; the background is a pure white of 255.

Begin the test by turning down the contrast to zero, then turn it up until circles begin disappearing; turn down the contrast again until the most inner-most circle that is capable of being displayed is displayed. This defines the maximum contrast. The monitor might only be able to display some of these upper contrasts, an acceptable amount I am told is the 245 of 255 range (the third outer-most circle). For certain monitors high contrasts values may alter the temperature of the bulb.



Brightness refers to the power level of the bulb, its physical brightness. Black level refers to black reproduction, or more elaborately the accuracy of displaying the lowest shades of black. The brightness setting may have an effect on both.

The test image displays columns of circles with decreasing lightness toward the center of the image. The center circle has a lightness of 1/255; the background lacks lightness of 0/255.

Begin the test by turn up the brightness to 100, then turn it down until circles begin disappearing; turn up the brightness again until the inner-most circle that is capable of being displayed is displayed. This defines the minimum brightness.

For brightness, I like to recommend reading light level. A good light to read a book with is a good light to read from the screen. What feels comfortable to the eye is usually better.


Black should be black and the shades near it are nice if visible too. A lower value acceptable for this is probably 10/255 again. If turning the brightness down has no effect on the black level visibility, leave it at the top or what is comfortable to the eye.

Color Balance


Fine tuning color balance can take years of practice to develop a trained eye–reds can look purple, cyan can look green…

The test image displays a variety of grays. If the images lacks the feel of being gray, adjust the RGB controls from 100 down to fix. Play with the controls up and down and get a feel for the color. Our eyes naturally adjust to the conditions they are in so this test can take time to learn how to do well. Periodic breaks can help reset the eyes. To fine tune the color, more can done later with the overall image, also the Gamma Correction test image can be of help adjusting color.


Fine Tuning

neutral chroma-free gray scale. This is the most critical component of monitoring and is accomplished through a White Balance Adjustment–Bennet Cain

After all the controls have been set I recommend going back and fine tuning them if necessary. I have been told that flat-panel monitors controls function independently. This means that one controls adjustments effect only that control—for CRT monitors control settings were dependent meaning that other controls could be effected by another control. To be sure of one’s settings though it is good to go back and check that all the control settings feel right.

Below is the skin tone test which works well for an additionally test to determine color balance. Skin tone is a good test for image reproduction.


Software Calibration

Fine-tooth calibration of a monitor through software calibration can help a monitor display more accurately. Otherwise, software calibration should be avoided–it is a second level adjustment and inaccurate at that. Software calibration, for example, can look like it is bringing in those blacks that the monitor originally could not display, but what it is doing making a two black in to a ten black. Software calibration also is a dependent control; for example, adjusting brightness with a software calibrator will effect contrast. The only acceptable software calibration to me is Gamma Correction and EDID.

EDID information is supplied in the monitor’s ROM. It contains information representing how accurately the monitor is able to produce color and lightness. EDID information is meant to be grabbed by the Operating System and used as an ICC profile to better render the display and share color information with other devices.

Software Video Players and the Plunging PLUGE Line

CRT monitors, generally for television, if setup deliberately for video production, used PLUGE controls to “black-crush” the bottom 7.5 IRE (7.5% visible luminance spectrum). This could have been done originally because early CRT monitors had difficulty displaying this value or possibly it was done for dramatic effect; I have yet to learn why. Some DVD players are able to produce an IRE below 7.5. It may be necessary to calibrate a “black-crush” on the software video player to render videos correctly.

To Do

  • Use an ffmpeg Command to Create Video from Images

See Also

Architectural Intent – a Wallpaper Tile

I tend to use my desktop as my workspace so I like wallpapers that act as more of a background decoration rather than elaborate artwork. So I created this. This is based on a wallpaper I found on the net (sorry, can’t remember where) and I re-did it. The original was in jpeg format and it had a bit of dithering to it.

It’s real basic, just 140×140, but I tile it and it comes out real nice:

It’s a vector image so it’s able to be resized real easy if need be.

Disk and Memory Usage Scripts

At times I like to check my levels of disk and memory usage and it’s more available for me at times for me to do it from the command line. Therefore, I created two scripts for them:

$ devtop 
Filesystem  Size  Used  Avail  Use%  Mounted
/dev/sda1   291G  101G  187G   36%   /
/dev/sda2   166G   38G  121G   24%   /home

$ memtop
PROGRAM          %MEM  #MEM
firefox          14.0  1049.7 MiB
gnome-shell      2.2   165.84 MiB
thunderbird      1.9   143.773 MiB
gedit            0.8   63.8555 MiB
nautilus         0.6   44.9961 MiB
Xorg             0.5   38.5039 MiB
gnome-terminal-  0.3   28.8164 MiB
keepassx         0.3   27.6406 MiB
tracker-extract  0.2   21.1992 MiB

Both script are part of my genscripts-git that is in the Arch Linux User Repository.