Home directory regenesis

When some unexpected event occurs on my computer, I may begin by troubleshooting in the home directory. Lately, I was having several program loadings that were taking a good deal of time that explanation thereof was baffling—a resolution I was unfortunately not able to find an answer for. The realistic solution for me was to create a new user and copy the trusted files over to a new home folder. It turned out to be a fairly easy thing to do.

The quick and the darned

In the past methodically I would clean out my home directory. I did this every year or twice a year. I did this because usually a quirk developed here or there but also because I’m a type A personality. Why quirks occur can be of one of several reasons but it might be related to a program’s configuration files: like with the addition of a new feature to a program, or with an older setting interfering with a new feature, databases getting too large…

I have much respect for my configurations and I do my best to keep them. The methodology I have learned of how to interact with my programs I respect and try to keep around and develop. However, at times, configuration renewal may become necessary. I do this only when I have to.

All work and no play is OK

Business if more important when I come down to it. Going through all the files, is no doubt, a laborious process, however, the result is worth it when everything is again running correctly.

First, I create a new user:

# useradd --gid users --groups games,wheel --shell "/bin/bash" USERNAME 
# install --directory --owner=USERNAME --group=users --mode=700 /home/USERNAME
# passwd USERNAME

I then put all the directories and trusted configurations in a list:

.local/share/applications/
.local/share/gedit/styles/autumnal.xml
Audio
Desktop
Development
Documents
Downloads
Pictures
Public
Videos

Then transfer them using rsync:

rsync --archive --files-from=include.txt --exclude-from=exclude.txt /home/USERNAME-OLD/ /home/USERNAME-NEW/

Since both users are in the same initial group (users), I just need to change user ownership from the old own to the new and then I’m done:

find /home/USERNAME-NEW/ -user USERNAME-OLD -exec chown USERNAME-NEW {} \;

This process took me about an hour.

Vim colorscheme customization

Any installed Vim colorscheme has the ability to be customized. They can be tested temporarily or saved to a configuration file that will leave the original colorscheme file intact.

Testing

To customize a colorscheme value, Vim has on-the-fly colorscheme alteration support to be able to test them. To get an overview of what all the values look like:

:highlight

To see a specific value (tip: have wildmenu enabled for tab-completion support):

:highlight CursorLine

02_vim-cs-cursorline

To customized a value:

:highlight CursorLine ctermbg=255

Tips:

  • hi = highlight
  • If working from the terminal, it is useful to know what colors are available. A number of scripts can be found; I created one called termcolors.
  • A test can highlight the current syntax groups: :so $VIMRUNTIME/syntax/hitest.vim

Save to file

Customized colorscheme values can be saved in the Vim configuration file or in the after directory with a plug-in.

It may be a good idea to begin customizing a colorscheme by reading the colorscheme author’s notes. Authors will sometimes explain their design philosophy in the colorscheme file. These files are located system-wide in /usr/share/vim/vimfiles/colors/ or locally in ~/.vim/colors.

Configuration file

A good number of users may prefer using the AfterColors plug-in as it simplifies the process and helps keep the configuration file neat. I prefer using the configuration file because of a glitch I encountered once.

Because it is possible that I may use multiple colorschemes, I’ve put detection of the colorscheme in my configuration so customizations apply per colorscheme. Values entered into the configuration match that done while testing:

if g:colors_name == "desert"
  highlight IncSearch  ctermfg=197 ctermbg=none
  highlight Search...
endif

AfterColors plug-in

Vim uses the system directory $VIMRUNTIME/after/ and the local directory $HOME/after/ to supplement or overrule to the default settings. For editing colorschemes there will need to be a sub-directory called colors. To install it locally:

mkdir -p $HOME/.vim/after/colors

For neither, however, does Vim yet support colorscheme customizations and a plug-in will need to be installed: AfterColors. I would recommend using a plug-in manager like Vundle or Pathogen to install it.

Customization values are put in a file that matches the colorscheme’s file name:

touch ~/.vim/after/colors/desert.vim

The values placed in the files are the same as done while testing:

" Vim colorscheme customizations: desert
highlight IncSearch  ctermfg=197 ctermbg=none
highlight Search     ctermfg=126 ctermbg=none  
highlight CursorLine ctermbg=255
highlight Visual     ctermbg=45

Save the file and reload the colorscheme to see the edits:

:colorscheme desert

… or type colo for the abbreviated version.

gurl—a general downloader

I like to keep things basic. Because a command-line, download program is already a part of the base package installation, it is all I need. Once I learned curl I liked it quite a bit. As always I need help remembering the options so I wrote a general wrapper script and it seems to be all I need. It features redirect following, progress bar, and resume support. It looks like this:

# gurl http://.../archlinux-2014.09.03-dual.iso
###############################                                           43.4%

gurl can be found in my general scripts repository.

LG IPS224V-PN monitor overview

LCD Monitor

I decided to get a new monitor the LG IPS224V-PN and I like it quite a bit.

First impressions

My first thought :) was that the stand could be a more rigid. It is OK, but on a desk that moves a bit, a wobble is noticeable. After I got it plugged in, the second thing I noticed, was that the color was real yellow, or rather the light was. Older LEDs can emit this din and I was a bit worried at first. Fortunately I was able to adjust it satisfactorily. A few of its specifications:

Details Value
Contrast ratio 5,000,000:1
Resolution 1920×1080
Response time 14ms
Input D-Sub, DVI, HDMI
Output Headphone

Setup

Setup was easy and monitor calibration was real straightforward and quick too. I adjusted the hardware settings as thus:

Setting Default New
Brightness 100
Contrast 50 76
Color Temp Custom Cool

I use the color temperature of cool to help balance the yellow din of the LED bulb. I did try it the normal temperature that did good with pictures if not too much white was in them:

Setting Default Alt.
Brightness 100
Contrast 50 67
Color Temp Custom
Red 50 46
Green 50 46
Blue 50 59

Ultimately I choose the cool temperature.

Other impressions

The power buttons is a large half-circle with a bright, refracting light. It is very noticeable and flashes when the monitor is in power-saving mode. It is real nice but if it is in the bedroom, like mine is, I ended up having to cover it up.

The monitor has IPS and it really does help improve the viewing angle and accurate color reproduction. I got this display for reading and it is good with that. It also is good with pictures at least as far as my mostly-professional eye is able to see. The 14ms response time, I think, is a bit on the high end for video watching. Videos will show a bit of “ghosting” but is good enough for me.

bckfile—backup a file with sequential numbering

I have discovered over the years that protecting a file, its content, and developing in a controlled, deliberate method is usually something good to keep in mind. I have learned that if I feel an document, project… is important, then to backup the data and then do the edit is the methodology I need to learn.

When I decide to backup a file, first thing I do is to see if there is a _vault directory. In any location where I had to backup previously, I created this directory. After the first time I did this I realized I was going to have to number these file backups. I reasoned out that filename_[0-9][0-9] would be a format that would be sufficient, if there was an extension it would be filename_[0-9][0-9].ext.

As I could see that file backups were something that I would regularly do, I decided to create a script that would automate this task. It tests the destination directory if the file exists. For the first backup, the script prepends 00 to the file, after that its prepend the sequential number.

The usage is basic: I define the source file and optionally the destination directory. The current directory is assumed if only the source file is specified.

An example:

$ bckfile file.txt _vault
‘file.txt’ -> ‘_vault/file_01.txt’

The script does have one limitation: the filename can only contain one period and it must be for the extension. This is necessary as determination for an otherwise intention would take a lot of work 😊.

bckfile can be found in my general scripts repository.

gt—create a gedit scratchpad

geditmp—a-script-to-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 geditmp.md) the name will be appended to the time.

geditmp-example

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

#!/usr/bin/bash
# (g)edit (t)emp. file — create gedit scratchpad

tmp_dir=~/.local/share/Trash/files
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
fi

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

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

=head1 SYNOPSIS

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

=head1 DESCRIPTION

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)>.

=back

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:

Bold:

  • program names
  • options
  • other manuals

Italic:

  • 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

NAME
  The name of the command followed by a one-line description of what it does.
SYNOPSIS
  A command's invocation with its listed options, or a functions parameter listings with its header file.
DESCRIPTION
  An in-depth explanation of the command or function.
OPTIONS
  A explanation(s) of what an option does these are sometimes put in the DESCRIPTION.
EXAMPLES
  Some examples of common usage.
FILES
  Files related to the command or function.
BUGS
  List of known bugs.
SEE ALSO
  A list of referenced or related commands.
AUTHOR, HISTORY, COPYRIGHT, LICENSE
  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.

screenshot-manpage

Resources