Category Archives: Linux

Keyboard outlines for key mapping

At times I mess with a program and like it enough that I write down the key mappings so I may refer to them later. I had done this enough that I just decided I might as well make a keyboard outline for key mapping. I created the four US-English model basic layouts. For those that would like to like to use them, they are under the Creative Commons Share Alike license. An example of what can be done with them can be seen on the post Knowledgeable Urban Terror setup.

Full layout:

Compact layout:

Laptop layout:

Mini layout:

Root directory residuals

root-directory-residualsThe only directory in my file system that I’d like to keep track of is my home directory. Here I keep my personal files and the a number of configurations that I love. I write notes of any configuration edits I make and record them here. However, besides the system configurations that I have edited, I also have a few more root directory configurations that I created. I wanted a way to keep track of them.

Getting down with the O C D

Previously I choose to reinstall about every six to twelve months. This allowed me to examine the install process to see if there were any new details about the operating system that I needed to learn. However, doing this procedure caused me to lose some good details I had put in the configurations. After I did this a few times, I began to do backups of them.

To keep the system running as expected, I learned I had to keep track of my configurations. The system configurations that I had edited originally I could keep track of by package updates (where I have to regularly merge the new versions to the old). However for the system configurations I created, I pretty much forgot them. These files occasionally I would rediscover when I had to do some troubleshooting. I came to the conclusion that if I wanted to track them, the best way to do so was to put them in a package`.

(I choose now to avoid installs when I can. These days, researching the install guide is enough to keep me up-to-date of operating system changes.)

Hunter and gatherer

I wasn’t always good at recording what configurations I created — I would test something out, or get excited when an experiment worked… Therefore, I had to search through the file system to re-track these files. This involved me making a list of all the files in the file system and comparing that to a list of files of the packages themselves. This sounds like a laborious process but isn’t terribly difficult and can be trimmed down greatly.

Because configurations are generally only in several directories less searching is required.

A file list of all packages, can be created with:

for p in $(pacman -Qq); do pacman -Qql $p; done | sed 's#/$##g' | sort -u -o pkgs-filelist.txt

A file list of the root directory, can be created with:

find / -not -path "/dev/*" -not -path "/home/*" -not -path "/media/*" -not -path "/mnt/*" -not -path "/proc/*" -not -path "/root/*" -not -path "/run/*" -not -path "/srv/*" -not -path "/sys/*" -not -path "/tmp/*" -not -path "/var/cache/*"  -not -path "/var/lib/pacman/*" -not -path "/var/lib/systemd/*" -not -path "/var/log/journal/*" -not -path "/var/tmp/*" | sed 's#/$##g' | sort -u -o root-filelist.txt

The differences can be viewed with:

vimdiff pkgs-filelist.txt root-filelist.txt

Alternately, the package lostfiles can be used.

The package please… emmhh!

Creating a configuration package is the same as creating any other package. I put the configurations in the PKGBUILD directory and in it directed where to install them. In the future if an edit is required, I edit them there and rebuild it.

pkgbuild

Command line dictionary

command-line-dictionary

As a person who likes to write, it has always been helpful for me to have a dictionary nearby. As a regular command line user, it would be nice if there was a dictionary program that I could access from there. I hadn’t predicted this would be much of a task, however I found it a bit of an uphill battle.

Requisites

I needed a dictionary that had:

  1. a basic description that is accurate
  2. offline access capability
  3. formatting that is logically ordered and easy to read

Availability

In my original attempt, I didn’t find any. I looked at and tried a number of programs but most were inadequate in one way or another. It took me a while to whittle them out. I was baffled… and I almost gave up looking. I did eventually find one, but before that the two most promising progrms looked to be dictd and sdcv.

Dictd

Dictd is a protocol/software-framework for a networking dictionary; it contains both a server and a client. The idea is to have a server where numerous clients can connect to it. This would be useful for local network use, or for something like an online dictionary group. However, it seems that the development has been quiet, and I had trouble installing several of its dictionaries… I could never get it to work.

The basic setup steps that are required to make it function are:

  1. Install package and a dictionary for it.
  2. Start the dictd daemon (requires very little overhead) and check if the dictionaries are available:
    dict -I
    
  3. Look up a word definition using a particular dictionary:
    dict --database gcide 
    

sdcv

I used to use this program (_S_tar_D_ict _C_onsole _V_ersion) — for years. It provided a basic, easy-to-use, unambiguous, definition. These days, however, the parent program StarDict is no longer in development. Additionaly, there were formatting problems that broke reading flow, and made it difficult to read.

Forest through the trees

I may not always get what I want, but sometimes when I pay attention, I get more than I need. I discovered a program that while not a full-blown dictionary does pretty good. It techinically might not even be a dictionary. From the man page:

wn – command line interface to [the] WordNet lexical database[…] [it outputs] synsets and relations to be displayed as formatted text.

In more human-speak, it details relationships between words. Its use as a thesaurus would be of a more direct comparasion. However it can work for a dictionary as it does provide definitions and some contextual examples. The definitions are basic but to the point. Word pronunciations, however, are not available.

    wn lexical -over
    ...
    The adj lexical has 2 senses (first 1 from tagged texts)
    ...
    1. (2) lexical -- (of or relating to words; "lexical decision task")
    2. lexical -- (of or relating to dictionaries)

Making good enough alone

The output of wn can be difficult to read — it jumbles a lot of information together and only roughly organizes it. (FYI, in the above example I’ve filtered out a couple lines.) To help the reading of it in a smooth natural way I’ve created a couple scripts to format the output. One script is called dict and the other is called thes. I’ve put them in the AUR.

dict

Fine DAE scripts

fine-dae-scripts

Anybody that knows my command line habits, or me in general, knows that my memory is terrible. It can be good when I need it to be — if I don’t have to though, I don’t. This leads me to writing a lot of things down. This is why I built my DAE scripts. (DAE, pronounced day, is an acronym for Digital Audio Extraction, and is more commonly known as “ripping” audio CDs). The scripts encapsulate a command that has only a few options, yet I have no way to memorizing the command that I may not use again for quite some time. Hence, I created the basic scripts, they are extremely straightforward scripts, just to cover the essentials. So now, after all this, I’m free to think.

How they look

There are two scripts. They are demonstrated here in use, as it is the best way to describe them.

daeme (pronounced like lame) is for MP3s:

daefe

daefe is for MP4s:

daefe

After these steps, RipIt does a CDDB query from the Internet (if available), followed by tag editing if desired.

Settings

I bypassed adding a few settings in the script and rather put them in the configuration file as their values won’t change:

faacopt=-s
dirtemplate="${artist} — ${album}"
playlist=0
eject=1

Audiobooks

The daefe script can also be used for audiobooks. The procedure encodes an entire CD to a file and writes a track/chapter index to another file. The chapter index file can be merged into the audiobook for an integrated audiobook, read Arch Linux Wiki:Audiobook for more details.

Package available

(These scripts are only basic wrappers, most of the work is done by the RipIT developer(s)… I thank them very much for their effort.)

Both scripts have error checking, so they should be reliable. I have put them in the AUR.

What audio I do?

posticonWhen I looked at my audio files recently I realized that they weren’t organized in a consistent way: naming standards varied, some tags were missing, different encoding types were used… I decided I was gonna Feng Shui my way out of it.

The reorganization department of the reorganization department

I decided there should be consistent naming and it should be condensed as much as possible… while still being, understandable.

For the directory format I use $artist — $album. Normally, the format is $artist/$album. However, I came to terms, that I would have to have about 100 CDs in my collection before the list would get too long.

I decided also to do “one directory per album“. Before I had directory names like Fleetwood Mac — The Very Best of Fleetwood Mac (disc 1). But I discovered it was much tidier to use just Fleetwood Mac — The Very Best of Fleetwood Mac. So, rather, I prepended the disc number to the audio files:

ls Fleetwood Mac — The Very Best of Fleetwood Mac/
...
1-15 Songbird.m4a
1-16 Big Love (Live, 1997).m4a
1-17 Storms.m4a
2-01 The Chain.m4a
2-02 Don't Stop.m4a
2-03 What Makes You Think You're the One.m4a
...

There are other programs that organize multiple CDs in the fashion and I like the thought behind it.

Just the FAACs

I had been using high-quality MP3s (256kbps) and just accidentally stumbled into trying MP4s — and was delighted by the difference. Similar bitrates of audio sounded fractionally, but for me, appreciatively better. So I encoded all CDs to .m4a (MPEG-4 audio extension). (I will probably go to loss-free audio format in the future if the gods favor.)

By the way, I think (clearly subjectively`) that FAAC (Free Advanced Audio Coding encoder) is great. It mentions in the manual that “it is not up to par with the currently best AAC encoders” but from my semi-proficient audio setup its pretty good.

I tested encoding with a FAAC at a setting of 320 (~256kbps) versus the iTunes setting of 256kbps. I did find iTunes better. Audiophiles looking for every detail my have stage, but for me it was marginal enough to dismiss it.

Here is a partially non-scientific (but should be fairly representative) graph of FAAC’s quality settings compared to kilobytes per second:

I can verify for the first and fourth values as I have tested a number of times. The second and third values I got from hydrogen audio. The fifth value is a projected value based from the other values.

A FAAC setting of 150 has been recommended for “casual, non-critical listening”; however, I use FAAC 320 for my tunes and 55 for voice. (Though similiar bitrates to iTunes created a quality that was a bit less, the file size reflected too: iTunes 8.4MB, FAAC 7.6MB.)

Plailer trash

Software audio players that I have used tended to put a good amount of junk in my audio folders. I’ve seen album cover art put here, lyrics, some useless metadata, and hidden folders. I did myself a favor and cleared it out. Nothing should be here but the audio files. If an audio player insists on putting stuff here, I would recommend to someone to either file a bug or get a new audio player. Some may argue that album playlists should be put here but I find a lot of that relates to the audio players setup and I delete them as well.

Book ‘em Dano

I discovered a nice feature call the audiobook format. Instead of 100 tracks littering a directory or directories from a audiobook CD, I can reduce this to a reasonable amount (say, one file per disc or whatever I choose). These book formats can also contain chapter indexes so navigating a file is just like navigating a disc. The process isn’t incredibly difficult and I documented it here. Additionally, my audio player supports them.

Organizing my home directory.

organizing-my-home-directory

Being type A, I’ve probably thought more about this more than many, I have a certain organization and formatting to how I store my files.

How its laid out

I keep all my home directories about the same as everyone:

# cd ~; ls -1p
Audio/
Desktop/
Development/
Documents/
Downloads/
Pictures/
Public/
Videos/

Audio

One exception to the above is the "Audio" directory which I use for multiple audio types:

# tree -L 1 -d Audio/
Audio/
├── Audiobooks
├── Music
├── Other
└── Podcasts

The other exceptions is I also hide the Templates directory (.Templates) as I don’t use it often.

Desktop

Even though I use GNOME I’ve enabled the Desktop. This is my workspace — if I can see them, I can remember them.

# ls -1 Desktop/ | head -n 3
arch-install.md
arch-linux-wiki-css-box_00.svg
command-line-dictionary.md
...

Development

I’ve come to be a big fan of VCSs. If I build something that others can use on their computer, I’ll create a VCS for it. I’ve put all of these VCS directories in their own directory:

# tree -L 1 -F -i --dirsfirst Development/
/home/akau/Development/
_TLP/
_mkinitcpio/
_vault/
alrd-buildimg/
alrd-setup/
ar-utils/
archpkgs/
armrr/
arpa/
genscripts/
gently-bashrc/
gently-vim/
gepa/
mkinitcpio-unsquashtmpfs/
power-backlight/
rback/
systemd-timer-pacman-optimize-git/
touchpad-state/
wordnet-lookup/
xuserrun/
autunmal
pdoc_md-wp

Documents

I put all the Documents in one directory whether I wrote them or obtained them:

# ls -1p Documents/
Blog/
Guides/
Receipts/
_vault/
car-maintenance-schedule.ods
recipes.md
wish-list.md
work-schedule-weekly-two-person.xls

Pictures

I do the same with Pictures as I do my Documents; whether I designed, photographed, or obtained them, I put them here:

# ls -1p Pictures/ | head -n 7
Camera/
Designs/
Nostalgia/
_vault/
aqua pr09studios.png
arch-pseudo3d_PJ.svg
architectural-intent.svg

As far as naming goes…

For folders, I use single words with the first letter uppercase, following the default Home directories formatting, whenever possible. For files I try to keep to the traditional UNIX method of naming my files as lowercase. For spaces in files, I generally use a hyphen (-) which I see used a lot these days though I think an underscore was originally used. Underscores I will use if there is a category I would like separated in the name (portrait-of-bach_etching.svg).

Audio files

Read What audio I do to learn how I do my audio files.

Vaults

When I come across I file that I won’t use anymore… is outdated… a misdirection… I create a folder called _vault that I place them in. I rarely ever go back to them but at times find that is is necessary.

Setup GNOME on Arch Linux 3.14

Introduction

arch-and-gnome

This is a basic install/re-install and configuration guide to an Arch Linux, GNOME 3 desktop.

Sorry, in a few locations, wordpress is doing an odd thing and converting “angle brackets” to > (their HTML entities).

Reinstall preparation

Arpa is used occasionally here in place of pacman. arpa is a pacman wrapper script.

Update system and configuration files (i.e. .pacnew files).

arpa -u
pacdiff

Package list create:

arpa -L

Partitions record:

lsblk >>                              ~/Desktop/arch-prev-notes.txt
df -h | grep -e '^File' -e '^/dev' >> ~/Desktop/arch-prev-notes.txt
blkid -s LABEL >>                     ~/Desktop/arch-prev-notes.txt

Group list record:

id >> ~/Desktop/arch-prev-notes.txt

Free disk space.

baobab   # empty trash, ...

Trash old packages in cache:

pacman -Sc

Backup:

rback --repo linxconf -xecute backup
rback --repo linxfull -xecute backup

Install

Reboot to a LiveCD, set hostname:

hostnamectl set-hostname aspr

Split the screen

tmux splits the screen so that one side can have install notes while the other is used to do the commands. Ctrl + b command mode, % to split vertically, ; to switch panes.

pacman -S tmux

Setup storage device

Partition device:

diskspace=$(( $(grep sda$ /proc/partitions | awk '{print $3}') * 2 / 2048 - 1 ))
swapspace=$(( $(head -n1 /proc/meminfo | awk '{print $2}') / 1024 + 2 ))
rootspace=$(( $diskspace - $swapspace ))
sgdisk --clear --new 1:0:+${rootspace}MiB --new 2:0:+${swapspace}MiB --typecode 2:8200 --new 3:0:+1MiB --typecode 3:8300 --pretend --print /dev/sda

gdisk /dev/sda
r  # recovery/transformation menu
h  # make hybrid mbr
3  # add partition 3 to hybrid mbr
Place EFI GPT (0xEE) partition first in MBR (good for GRUB)? (Y/N): N
Enter an MBR hex code (default 83): [enter]
Set the bootable flag? (Y/N): Y
Unused partition space(s) found. Use one to protect more partitions? (Y/N): N
w  # write table to disk and exit

Format and mount:

mkfs.btrfs /dev/sda1 --label Linux
mkswap     /dev/sda2 --label Swap
mount      /dev/sda1 /mnt

Install base(ish) packages

mkdir -p       /mnt/var/{cache/pacman/pkg,lib/pacman} /mnt/dev
mkdir -m 555   /mnt/{proc,sys}
mount --bind   /dev     /mnt/dev
mount --bind   /dev/pts /mnt/dev/pts
mount -t proc  proc     /mnt/proc
mount -t sysfs sys      /mnt/sys

Install base and other low-level packages:

pacman --root /mnt -Sy base base-devel  abs alsa-utils dkms dnsmasq ethtool grub iw linux-headers msmtp-mta ntp smartmontools syslinux tlp vim
umount --recursive /mnt/{dev,proc,sys}

systemd-nspawn -bD /mnt  # should be enought to boot, otherwise:
systemd-nspawn --capability=CAP_MKNOD --register=no -M "${HOSTNAME}-chroot" -D /mnt

Configure base (basic)

No fstab, handled by GPT autodiscover (done by udisks/systemd?!).

locale-gen  # First, uncomment en_US.UTF-8 UTF-8 in /etc/locale.gen 
echo -e "LANG=en_US.UTF-8\nLC_COLLATE=C" > /etc/locale.conf
source /etc/profile.d/locale.sh
ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime
echo aspr > /etc/hostname

Configure package manager

  • Check log (/var/log/pacman.log) that base and base-devel were setup right.
  • Setup authorization keys pacman-key --init; pacman-key --populate archlinux.
  • Repository mirrors setup with script:

curl -L http://tinyurl.com/mkjvdnq -o armrr
chmod +x armrr
armrr US
pacman -Syy

Add user

passwd
useradd -g users -G \
  adm,audio,games,optical,power,scanner,storage,video,wheel todd
passwd todd

Block insecure packages

# block in pacman.conf: flashplugin pywebkitgtk qtwebkit 
#                       webkitgtk webkit2gtk
#                       doom3 doom3-data etqw etqw-data
# Uncomment multilib
mkdir {webkitgtk-dummy,webkit2gtk-dummy}
curl -L http://tinyurl.com/kcype3f -o webkitgtk-dummy/PKGBUILD
curl -L http://git.io/5L7-Jg       -o webkit2gtk-dummy/PKGBUILD

Install display server

pacman -S xorg-server xorg-server-utils xorg-xinit \
  xf86-input-synaptics mesa-demos
pacman -S xf86-video-ati
pacman -S firefox firefox-adblock-plus hunspell-en

Install desktop environment

pacman -S gnome gnome-extra
  • gnome ^but : epiphany mousetweaks vino yelp
  • gnome-extra: brasero cheese devhelp file-roller gedit gnome-color-manager gnome-devel-docs gnome-getting-started-docs gnome-logs gnome-maps gnome-nettool gnome-photos gnome-weather nautilus-sendto polari rygel seahorse
  • Application descriptions.

Configure base

Bootloader:

grub-install --target=i386-pc --recheck /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg

syslinux-install_update -i -a -m

Initial RAM filesystem add suspend support:

sed -i '/^HOOKS/ s/block/block resume/' /etc/mkinitcpio.conf
mkinitcpio -p linux

Kernel parameters:

echo -e "# Magic sysreq key enable\nkernel.sysrq=1\n\n# Swapiness priority (def: 60)\nvm.swappiness=10" | tee -a /etc/sysctl.d/99-sysctl.conf

Elevated privledges:

visudo
Defaults editor=/usr/bin/vim:
% wheel... allow members in group wheel to execute...
todd  ALL = (root) NOPASSWD: /usr/bin/systemctl

NumLock enable on boot:

mkdir /etc/systemd/system/getty@.service.d
echo -e "[Service]\nExecStartPre=/bin/sh -c 'setleds +num  _Shortcuts_: (uses[pwr](/2012/02/24/power-management-from-the-command-line/) script):
Action Path/Command Key
Show desktop Navigation > Hide all… Ctrl + Alt + _D
Suspend Custom Shortcuts > +pwr -b Ctrl + Alt + B
Suspend Custom Shortcuts > +pwr -s Ctrl + Alt + S

Mouse and Touchpad

Mouse scroll speed (default: acceleration 20; sensitivity 10):

gset_tpad_path=org.gnome.settings-daemon.peripherals.touchpad
gsettings set $gset_tpad_path disable-while-typing true
gsettings set $gset_tpad_path horiz-scroll-enabled false
gsettings set $gset_tpad_path scroll-method disabled
gsettings set $gset_tpad_path tap-to-click false

Power

gset_powr_path=org.gnome.settings-daemon.plugins.power
gsettings set $gset_powr_path button-power                   hibernate
gsettings set $gset_powr_path sleep-inactive-ac-timeout      3600
gsettings set $gset_powr_path sleep-inactive-ac-type         hibernate
gsettings set $gset_powr_path sleep-inactive-battery-timeout 1800
gsettings set $gset_powr_path sleep-inactive-battery-type    hibernate
gsettings set org.gnome.desktop.lockdown disable-lock-screen false

Date & Time

Time Format AM/PM:

gsettings set org.gnome.desktop.interface clock-format 12h

Details

Default Applications:

Type Program
Web Firefox
Mail Gnome Gmail
Calendar Evolution
Music Videos
Videos VLC
Photos Image Viewer

Removable Media:

Media Action
CD Audio Ask what to do
DVD video VLC
Music player Ask what to do
Photos Ask what to do
Software Run Software

Users

Avatar.

System settings (other)

Other settings that may be of importance.

Tweak Tool

Tab Option Setting
Appearance Global Dark Theme: On
Window, GTK+, Cursor, Shell defaults
Icon: faience-icon-theme
Desktop Icons on Desktop On
Home, Trash, Mounted Volumes Unselect
Extensions Places status indicator On
Removable drive menu On
Systemmonitor On
Windows list On
Insensitive message tray On
Lock keys On
No topleft hot corner On
Fonts Window Titles Cantarell Bold, 11
Interface Cantarell, 11
Documents Sans, 11
Monospace Monospace, 10
Hinting Slight
Antialiasing Rgba

Disks

From the GNOME disk utility:

  • Enable write cache (since have battery):

    Settings > Drive Settings > Write Cache > On.

  • Mount options handled automatically ([erases fstab entries]):

    Partition Settings > Edit Mount Options > Automatic Mount Options > On.

  • Reboot and re-enable swap.

Menu

Select Main Menu from menu to and remove unused apps.

Login sound

~/.local/share/sounds/desktop-login.wav

GNOME Program Settings

Various program setups.

gedit

Trailing newline eliminate:

gsettings set org.gnome.gedit.preferences.editor ensure-trailing-newline false
Tab Option Setting
View Display right margin at column: Check, 80
Highlight current line Check
Editor Tab width: 2
Insert space instead of tabs Check
Autosave file every X minutes Check
Font & Colors Color Scheme Oblivion
Plugin Color Scheme Editor Check

Nautilus

Tab Option Setting
Views View new folders using: List View
Sort folders before files check
Behavior Include Delete command… check

Passwords and Keys

Create a key to encrypt files (takes about 10 minutes):

File > New > PGP Key > Name > Email > Defaults > Passphrase.

Terminal

Tab Option Setting
General Show menubar by default on new uncheck
Use dark theme variant check
Open new terminals in: Tab
Profile > Edit sub-menu
General Terminal bell uncheck

Terminal inset to match gedit width:

echo -e "TerminalScreen {\n  -VtrTerminal-inner-border: 0px 2px 2px 0px;\n}" > ~/.config/gtk-3.0/gtk.css

Screenshot

Default save directory:

gsettings set org.gnome.gnome-screenshot auto-save-directory file:///home/todd/Desktop

Program Settings

Other program setups.

Bluefish

Some setting changes require an application-restart.

Tab Option Setting
Initial document settings Mime-type text/css
Show line numbers uncheck
Wrap lines check
Tab width: 2
Insert spaces instead of tabs check
Editor settings Wrap lines on right margin ind. check
Editor settings: Fonts & Highlight cursor position check
Cursor highlight color Green1
Current line color DarkGrey2
Editor settings: Text sty. searchresult #BF75D0
blockmatch fg:LghtGray2
bg:Purple3
function Purple1
value
string-no-spell-check #7E7103
string #C5B000
attribute Blue1
Files Strip trailing spaces on save check
User interface Sidebar position right
User interface: Fonts and Document tab error color #681B1B
Document tab loading color
Document tab modified color Blue1

Burp

mkdir ~/.config/burp
echo -e "User=Gently\nCookies=~/.config/burp/cookies" > \
  ~/.config/burp/burp.conf

Firefox

Games

Gmail as default

Run “Gnome Gmail” from menu.

KeepPassX

lnk /usr/share/applications/keepassx.desktop ~/.config/autostart/
# xorg not a serviceyet #echo -e "[Unit]\nDescription=Password Manager\n\n[Service]\nExecStart=/usr/bin/keepassx\nEnvironment=DISPLAY=:0\n\n[Install]\nWantedBy=????" > ~/.config/systemd/user/keepassx.service

MPD

mkdir ~/.config/mpd/
vimdiff /usr/share/doc/mpd/mpdconf.example ~/.config/mpd/mpd.conf
ln -s /usr/lib/systemd/user/mpd.service ~/.config/systemd/user/
systemctl --user start  mpd
systemctl --user enable mpd

Rygel

cp /etc/rygel.conf ~/.config/
rygel-preferences
curl -L http://tinyurl.com/pbm8mt5 -o ~/.config/systemd/user/rygel.service
systemctl --user enable rygel
systemctl --user start  rygel

VirtualBox

sudo modprobe vboxdrv
echo "vboxdrv" | sudo tee /etc/modules-load.d/virtualbox.conf
sudo gpasswd -a $USER vboxusers
mkdir -p  ~/.config/VirtualBox/vm # keep everything together
chattr +C ~/.config/VirtualBox/vm # no COW btrfs
  • File > Preferences (VirtualBox GUI preferences):
  • General > Default Machine Folder: ~/.config/VirtualBox/vm
  • Update > Check for Updates: uncheck

Resources

Home directory renewing.

Every now and then something goes wrong in the home directory. I was having the problem that something or possibly of number of things causing:

  • Longish load times of gedit and Firefox and possibly a couple others.
  • A hang of one X.org session (and lose of tracker data).

How I fixed these problems previously

About every six months, I find myself cleaning out my home directory. This has always been because of bugs. Usually what happens is developers add new features, they cause incompatibilties with old configurations or how files get accessed… its necessary to do about this often.

Cleaning the home directory is a long and laborious process of going through all the files. A bit more throughly, the last couple times I would rename my home directory (mv /home/user /home/user-old) and mv the files I trusted over. I would keep the old directory around a bit if I needed to grab an old configuration.

The forest through the trees method

These days I just create a new user :).

useradd -g users -G \
  adm,audio,games,optical,power,scanner,storage,video,wheel alias
  install -d --owner=alias --group=users /home/alias
passwd alias    

To be able to transfer the files over, I use my backup utility and backup all home files and dependable configurations:

rback --repo linxhome --include "/home/oldname/.config/fontconfig/fonts.conf /home/oldname/.config/geany/geany.conf /home/oldname/.config/gtk-3.0/gtk.css ..."

And restore them:

rsync -axS .../backup-folder/home/oldname/* /home/alias/

Fix permissions:

find /home/alias/ -user oldname -exec chown alias {} \;

Vim: Customize Installed Colorschemes

Disclaimer: This is a guide of how to override an already installed colorscheme’s highlighting. Though I’m not an expert on creating Vim colorschemes, I do know a few things. These are a few tips that can help.

Reasoning

If wanting to try an alteration to a Vim colorscheme it’s usually nice to work with the author of that colorscheme to improve it. But if wanting to try it first and road test it, this is a good way to do it. First:

Get the plugin

For this to work a plugin is needed. Arch Linux users can install it from the Arch User Repository: vim-plugin-aftercolors. This plugin enables the vim/after/colors directory where edits can be put that override an installed colorscheme values. The directory to do this in is located at ~/.vim/after/colors by default; create it if it doesn’t exist.

Editing

Overrides for the colorscheme resemble that which are in the colorscheme file itself. It is usually useful to read the actual colorscheme file to get ideas of what to do: authors sometimes leave notes and one can see all the settings. To try a new setting, put it in a file here that matches the colorscheme name (e.g. ~/.vim/after/colors/desert.vim). To learn more about how to set and test them in an easier manner, read the next section. When an edit is saved here, the colorscheme can be reloaded (if say in another terminal) by doing:

    :colorscheme desert

Screenshot from 2014-10-13 13:26:19

On-the-fly testing

Screenshot from 2014-10-13 18:36:22

To try new settings immediately, Vim has got built-in, on-the-fly, colorscheme alteration support (using the highlight command). List all the colorscheme settings with:

    :highlight

Screenshot from 2014-10-13 18:46:22

Or to see a specific setting (tip: have wildmenu enabled to see tab-completions):

    :highlight CursorLine

Screenshot from 2014-10-13 18:50:39

To temporarily change a setting, enter the value:

    :highlight Cursorline ctermbg=4

To know what color to use, the terminal color number will need to be obtained. Here’s a couple links with script and desciptions: link1, link2; alternately, my own script is available (it prints to terminal the color and number, though is meagerly tested): termcolor.

Partition base number order restoration (sda2 > sda1)

I decided to remove Windows. It was at the beginning of my hard drive, so I deleted the first partition, then I extended the second partition down to the beginning of the hard drive. I assumed that doing this operation (the second partition becomming the first, and it being moved the beginning of the drive) that it would inherit the base partition number (i.e. the kernel device name of sda1). However I’ve learned that disk utilites are generally uninterested in doing this, and instead preserve partition numbers. I believe the likely reason for this is because the designers know that some configurations define partitions (fstab and bootloader configs, for example) and are thence hesitant to alter a bootable configuration. I, however, like order. And thankfully, the order can be re-based.

The easy way

First thing to do is add a partition, afterward the partition table can be re-based.

Adding a partition

Disk utilities generally follow the pattern that when they create a partition they begin with the first available number; hence, a new partition should be named sda1. Here’s what my partitions looked like originally:

01-sda2-&-sda3

Since it’s quicker to create a partition at the end of the drive… add a partition to the end… and get sda1:

02-sda_2-3-1

Fixing the partition order

The only disk utilites I know that have this available operation are fdisk and gdisk. They have an option to re-order partition numbers (i.e. the first partition is one…). Boot from a install CD or rescue disk and run fdisk:

# fdisk /dev/sda
...
Command (m for help): p  # prints partition table
...
Device     Boot     Start       End   Sectors   Size Id Type
/dev/sda1       625133568 625141759      8192     4M 83 Linux
/dev/sda2  *         2048 608364543 608362496 290.1G 83 Linux
/dev/sda3       608364544 625133567  16769024     8G 82 Linux swap / Solaris

Partition table entries are not in disk order.

Notice that sda1 Starts and Ends after the other partitions. From here enter the expert menu:

Command (m for help): x

And fix the partition order:

Expert command (m for help): f
Done.

Expert command (m for help): r
Command (m for help): p
...
Device     Boot     Start       End   Sectors   Size Id Type
/dev/sda1  *         2048 608364543 608362496 290.1G 83 Linux
/dev/sda2       608364544 625133567  16769024     8G 82 Linux swap / Solaris
/dev/sda3       625133568 625141759      8192     4M 83 Linux

The easy but hold-on-tight way

I’ve heard of someone doing this but haven’t tried it myself. What is done is that the partition table values is written down, the partition table wiped, then the partition table values are re-entered. Since you’re creating a new partition table from scratch the correct partition order will be created. This actually is perfectly safe to do.. if the values are gotten right. The partition table is written on the first sectors of the disk so the partition contents are perfectly safe. I’ve known this to be done before; however, I have not tried it so please use at your own risk. To learn more about this read: Fix MSDOS partition manually.

Configurations with partition definitions

Afterward, be sure to adjust the partition definitions in any configurations that have them. Also some bootloaders may store this value in the header region of the drive requiring a re-install of the bootloader.

Resources

rback – a generic, local, rsync-based, backup and restore script

rback

rback is a generic backup and restore script. rback wraps common functions of rsync to aggregate backup necessities. rback defines:

  1. The copy options.
  2. The source and destination directories.
  3. The files, folders… to include or exclude.

rback is repository-based to allow for multiple backup types (like full system backups, configurations…). It is only for local backups (i.e. the same computer that it resides on). Additionally, rback includes a diff method for working with text files.

Usage

rback - a generic, local, rsync-based, backup and restore script
  -r, --repo    - repository select                     : -R repository new
  -i, --include - include list add files, folders...    : -I include list edit
  -e, --exclude - exclude list add files, folders...    : -E exclude list edit
  -x, --xecute  - execute a: restore, backup, or diff
  = overrides  =
  -c, --confdir - configuration dir. from livecd, e.g.  : -C configuration edit
  -s, --srcdir  - source directory,  alternate specify
  -d, --dstdir  - destination dir.,  alternate specify
  -j, --justdo  - no confirm

For more information, RTFW (read the fun manual). :)

Follow

Get every new post delivered to your Inbox.

Join 53 other followers