Category Archives: Linux

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

gurl – a curl general download wrapper

Because I don’t need another download program (and sometimes I find it not installed) I built this:


#!/usr/bin/bash
# A curl general download wrapper
# -l : redirect automatically
# -O : output filename is remote name
# -# : progress bar
# -w : (--write-out) print filename
# -A : user agent
#    : resume difficult (wget -c, better): http://tinyurl.com/7umwyl3

for u in "$@"do
  curl -l -O -# -w "%{filename_effective}\n" -A "Mozilla/4.0" "$u"
done

And it looks like this:

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

WTFM (Write the Fine Manual) with Pod2man text-converter

Todd Partridge (Gently):

Post before was a jetsam, added a bit and touched-up.

Originally posted on Linuxtidbits:

Note: This is a guide from a lightly-proficient manual writer that’s targeted for beginning users: it’s formatting method is easy and conversion method is basic. This method may also be helpful for those that use github because it has rendering support for this method. For a more traditional approach, nixCraft has an article for that.

Because it was the authors first effort to write a man page, talk was that it was good to use Pod2Man. Pod2man is an application that converts text using Plain Old Document (POD) formatting to traditional manual (man) pages. POD markup is easy to do and pod2man is conveniently pre-installed on most Linux distributions (as it is part of the Perl package).

An example

To get a good idea of what to do, here is a basic example demonstrating the formatting (of a fictitious program dr-smile):

 dr-smile - output platitudes to…

View original 467 more words

Gentoo Linux Tidbits

Todd Partridge (Gently):

Updated bash script and generally

Originally posted on Linuxtidbits:

I’ve been using Gentoo for about two years now and I took notes on managing my box. These are those notes. If you’re interested in installing Gentoo take a look at Gentoo Quick Install.

Update: bash script

This section is an addition. I’ve since created a bash script that does many of the functions and make reading the rest less necessary. The script is self-explanatory: link.

About Portage

Gentoo Linux uses a package management system called Portage. Portage offers one of the most extensible and customizable package systems available in Linux.

System Update

Update all packages on the computer. This process involves: syncing Portage, creating a text file to review updates, updating the system, merging new configuration files, remove orphaned dependencies.

Sync the portage tree

emerge --sync # or
eix-sync      # preferrable for faster searches (eix search)

Examine update before install

emerge --pretend --verbose --update --newuse --deep @world…

View original 806 more words

arpa: (Ar)ch (pa)ckages – generic package tasks wrapper script

Todd Partridge (Gently):

Arch wrapper for pacman updated, very well tuned now.

Originally posted on Linuxtidbits:

I once saw a wrapper-script for pacman in the forums that was basically a short-hand version of common pacman tasks. Over the last couple years, I’ve expanded on it. It does just about everything I need it to and its real basic. I call it arpa and here are the tasks it covers:

arpa [option] [*package] - generic package tasks wrapper script -e, --explicit - install a package as explicit -g, --get - only download package files : -G for upgrade files -i, --install - install a package : -I for deps, *.pkg.tar.* -l, --list - list files installed by a package : -L genlist inst. pkgs -n, --info - information about a package -o, --owns - owning package of a file -q, --query - query for an installed package : -Q adds description -r, --remove - remove a pkg and its deps : -R force, no param orphs -s…

View original 43 more words

bashrc

Todd Partridge (Gently):

Updated today, gotten better… redone.

Originally posted on Linuxtidbits:

The ~/.bashrc is a the bash shells’ setting file. The ~/.bashrc can also be used to specify other bash shell related items like abbreviating commands and creating shortcuts. Here is my ~/.bashrc , all bells, no whistles.

View original

Get down with getopt

What is getopt?

getopt is a command used in scripts to parse their options and add a basic error checking ability. getopt is not getopts the bash built-in that has similiar functionality. Urban Vagabond explains:

getopt and getopts are different beasts, and people seem to have a bit of misunderstanding of what they do. getopts is a built-in command to bash [that] processes command-line options in a loop and assigns each found option and value in turn to built-in variables [(so that they can be further processed)]. getopt, however, is an external utility program, and it doesn’t actually process your options for you the way that [(e.g.)] bash getopts, the Perl Getopt module, or the Python optparse/argparse modules do. All that getopt does is canonicalize the options that are passed in — (i.e. convert them to a more standard form) so that it’s easier for a shell script to process them.

For example, a use of getopt converts the following:

tmpscript -abd -ooutfile.txt

into this:

tmpscript -a -b -d -o outfile.txt

getopt can also process the long format option of --output=/tmp.... Also basic error check abilities, it has:

tmpscript -c
tmpscript: invalid option -- 'c'

or

tmpscript -o
tmpscript: option requires and argument -- 'o'

getopt gets defined by telling it the available options in short and long form (if you like). An option with a colon (:) following denotes that an argument is required for that option. If followed by two colons the argument is optional. Here is an example:

Options are generally set as variables so that they can defined how to be used after the while loop (usually, so that mainly they are processed in the right order). getopt parses in the same order as specified on the input, so a -a -d -b input would not work real well if the -d option required the -b option to run correctly.

One caveat of getopt is that each option allows either one or no arguments to follow. So in input like tmpscript -v --files file1.txt file2.txt file3.txt just isn’t possible in any type of predictable-fashion. One can however use quotes on the input:

tmpscript -v --files "file1.txt file2.txt"

or use mutiple options (-f file1.txt -f file2.txt) and append them to an array, as seen, here.

Follow

Get every new post delivered to your Inbox.

Join 52 other followers