The Smell of Molten Projects in the Morning

Ed Nisley's Blog: Shop notes, electronics, firmware, machinery, 3D printing, laser cuttery, and curiosities. Contents: 100% human thinking, 0% AI slop.

Category: PC Tweakage

Remembering which tweaks worked

  • Xubuntu Install Tweaks: Fonts

    Even a lean distro like Xubuntu has a bunch of fonts you’ll never use. Which ones you won’t need depends on who you are and where you live, but for my purposes the Asian and Arabic fonts just clutter up the font selection menus.

    They’re all in /usr/share/fonts/truetype/, neatly stashed in separate directories. Figure out which ones you don’t need (perhaps browsing with Thunar will help), then:

    cd /usr/share/fonts/truetype
    sudo rm -rf arphic kochi thai
    

    And so forth and so on, until you’re left with the ones you’ll actually use.

    I also have a bunch of fonts I actually paid money for. While this is a single-user box, it’s easy enough to install ’em in the default system locations (rather than a user directory), with a pair of directories to organize them:

    cd /usr/local/share/fonts
    sudo mkdir truetype
    sudo mkdir type1
    

    Then copy the store-bought fonts into the appropriate locations. After doing this a few times, I organized the original fonts under a few directories, so this need not degenerate into a search-and-copy operation every time.

    Worst case: when you’re done, just copy those two directories back to your font dump and copy them back for the next installation.

    The final step is updating all the font caches, which point to directories & fonts that no longer exist:

    sudo fc-cache -f -v

    You may need the -r option to forcibly delete existing caches and re-scan from scratch.

    More details there.

    The details differ, often wildly, among distros, so perhaps this manual command-line fiddling will grossly confuse whatever automated GUI routines you’re supposed to use.

  • Xubuntu Install Tweaks: Kmail

    Oddly, Kmail seems to not have a configuration option for its main email directory, using ~/.kde/share/apps/kmail/mail if it has its way.

    If you already have a ~/Mail directory, it’ll use that instead.

    I stash my mail on the file server in the basement and NFS-mount the directory locally, so I set up a symlink:

    ln -s /path/to/nfs/mount/Mail ~/Mail

    That works fine, somewhat to my surprise, if you do it before starting Kmail for the first time.

    Other files that must tag along to preserve the Kmail setup:

    • ~/.kde/share/config/kmailrc — main config file with accounts & filters
    • ~/.kde/share/config/emaildefaults — my name & address
    • ~/.kde/share/config/emailidentities — account info
    • ~/.kde/share/apps/kabc/std.vcf — contact list

    The std.vcf thing has your entire contact list. Which, I’m sure, doesn’t integrate well into whatever Xubuntu uses for a contact list, but that’s a second-order problem.

    Admittedly, this violates my meta-rule to not migrate the configurations, but the prospect of regenerating all those email filter rules and re-typing all the contacts is, um, daunting, even if most of them are cruft. I could hand-edit the new kmailrc file and insert the old filters, but …

    Memo to Self: do this before starting Kmail the first time!

  • Linux Install Tweaks: xorg.conf

    My desktop system has accreted a bunch of input devices over the years and the automagic X configuration system just doesn’t handle everything. Hence, some manual fiddling is in order every time I set up a new Linux installation.

    Recall that I’m using Xubuntu because KDE4 Just Doesn’t Work with dual monitors.

    Portrait-mode Monitor

    You must use the nVidia restricted driver, so install that if you didn’t pick it during installation. I have no experience with ATI, other than reading many despairing posts saying ATI boards contribute great suckage to the Overall Linux Experience.

    Use the Nvidia X Server Settings program to set up separate X sessions on each monitor. This is different from TwinView and Xinerama, which spread a single desktop over both screens, because it lets you independently switch between desktops on each screen. I want to edit my columns on the right-hand portrait screen while switching between PDF doc, simulations, schematics, and ahem email on the left screen, so separate X sessions are the way to go.

    I save successive xorg.conf files in a directory in my home directory, then manually copy them into /etc/X11 as needed. That way, if (when!) an update clobbers the X setup, I can recover easily.

    Save the file, copy it to /etc/X11/xorg.conf, log out, restart the X server (Ctrl-Alt-Backspace at the login screen will suffice), log back in again, make sure you have two monitor and separate X sessions, both in landscape mode. If not, fiddle around until you do.

    Edit that xorg.conf file and add one line to the right-hand monitor’s Section “Screen”

    Section "Screen"
        Identifier     "Screen1"
        Device         "Device1"
        Monitor        "Monitor1"
        DefaultDepth    24
        Option         "TwinView" "0"
        Option         "metamodes" "DFP-1: nvidia-auto-select +0+0"
        Option	        "Rotate" "CCW"
        SubSection     "Display"
            Depth       24
        EndSubSection
    EndSection
    

    Hardcoded rotation disables RandR, which seems to not matter, although it does prevent the XFCE Display config applet from starting. I tried RandR some time ago and it basically didn’t work on the setup I had, so I gave up. As I never change screen resolutions or rotations on the fly, it doesn’t solve a problem I have, anyway.

    Update: it seems the “nvidia-auto-select +0+0” setting causes an occasional hang when logging out; I must ssh in and reboot the system. Replace that string in both Screen sections with the actual resolution: 1600×1200 and 1680×1050, respectively, leaving the DFP-? in place.

    Save the new xorg.conf, copy it, log out, restart X, and log back in again. Now the right-hand monitor runs in portrait mode: wonderful for editing pages of text. Stand the right-hand monitor on its left ear.

    Wacom Tablet

    I have a Wacom Graphire tablet, which sort of worked with the default xorg.conf, but the mouse pointer switched to the right-hand screen in the middle of the left screen. I think the default single-X configuration confused it mightily.

    These sections pin it to the left-hand screen, let it rove over the full screen, and swap the side-switch buttons on the stylus. Tweak these sections and save copies as needed

    Section "InputDevice"
            Identifier      "stylus"
            Driver          "wacom"
            Option          "Device" "/dev/input/wacom"
            Option          "Type" "stylus"
            Option          "Mode" "Absolute"
            Option          "ScreenNo" "0"
            Option          "Button2" "3"
            Option          "Button3" "2"
    EndSection
    
    Section "InputDevice"
            Identifier      "eraser"
            Driver          "wacom"
            Option          "Device" "/dev/input/wacom"
            Option          "Type" "eraser"
            Option          "Mode" "Absolute"
            Option          "ScreenNo" "0"
    EndSection
    
    Section "InputDevice"
            Identifier      "cursor"
            Driver          "wacom"
            Option          "Device" "/dev/input/wacom"
            Option          "Type" "cursor"
            Option          "Mode" "Absolute"
            Option          "ScreenNo" "0"
    EndSection
    

    Trackballs

    I have two trackballs, one on each side of the keyboard, to distribute the strain equally on both wrists. The default configuration treated them both as mice and didn’t allow separate configuration. That meant the left-hand ball operated in right-hand mode; a bit of a problem.

    Fortunately, evdev now allows button configuration, so the setup was straightforward. Add these two sections

    Section "InputDevice"
            Identifier      "LogiBall"
            Driver          "evdev"
            Option          "Device" "/dev/input/by-id/usb-Logitech_USB_Receiver-event-mouse"
            Option          "Emulate3Buttons" "false"
            Option          "Buttons" "10"
    EndSection
    
    Section "InputDevice"
            Identifier      "KenBall"
    	Driver		"evdev"
            Option          "Device" "/dev/input/by-id/usb-Kensington_Kensington_Expert_Mouse-event-mouse"
            Option          "Emulate3Buttons" "false"
            Option          "ZAxisMapping" "4 5"
            Option          "ButtonMapping" "3 2 1"       # Left hand
    EndSection
    

    The default mouse configuration now doesn’t do anything, so remove the automagically generated Section “InputDevice” for Mouse0.

    ServerLayout

    With all that in place, the Section “ServerLayout” entry becomes

    Section "ServerLayout"
        Identifier     "Layout0"
        Screen      0  "Screen0" 0 0
        Screen      1  "Screen1" RightOf "Screen0"
        InputDevice    "Keyboard0" "CoreKeyboard"
    #   InputDevice    "Mouse0" "CorePointer"
        InputDevice     "LogiBall" "CorePointer"
        InputDevice     "KenBall" "SendCoreEvents"
        InputDevice     "stylus" "SendCoreEvents"
        InputDevice     "cursor" "SendCoreEvents"
        InputDevice     "eraser" "SendCoreEvents"
    EndSection
    

    Save it, copy it, log out, restart the X server, log back in again, and enjoy …

    Although your setup will differ from mine, here’s the entire xorg.conf file for your perusal and my backup. It’s saved as an OpenOffice odt document: just open it and Save As plain old text and it’ll work fine. There’s a bit more cruft than I mentioned, but that’s how it goes…

    This doesn’t resolve the random USB disconnects and X hassles I described there, but now that I’m not wearing an acrylic overshirt it’s not so much of a problem.

  • Linux Install Tweaks: Firefox

    I wish there was a way to bulk-install a list of add-ons, rather than futzing around installing them one-by-one. On the other hand, this way you’re sure to get the latest-and-greatest, while not attempting to install anything that’s obsolete.

    Copy passwords & suchlike from your previous installation into ~/.mozilla/firefox/whatever

    • key3.db
    • signon3.txt

    Install add-ons:

    • Adblock Plus
    • GreaseMonkey — then get GoogleMonkeyR for two-up search results
    • Google Gears — for wordpress blogging
    • Image Zoom
    • Tab Focus — 250 ms delay
    • Print Context Menu
    • FireGestures
    • Linkification
    • PDF Download
    • Brief

    Install themes

    • Microfox
    • Littlefox
    • Classic Compact

    I like Microfox: it doesn’t waste vertical space on foo-foos.

    Kill off Flash cookies and disable all the sharing and enabling and local storage: does anyone really want Flash apps to use the microphone & camera by default? This technique is not obvious and you must do it for every user and every browser on each system.

    The Adobe Knowledgebase article is here:

    http://kb.adobe.com/selfservice/viewContent.do?externalId=52697ee8

    The actual Flash control panel is here:

    http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager02.html

    You should also search on the obvious keywords for more info.

    Exit Firefox, fire it up again, do the obvious tweakage, and you’re set!

  • Linux Install Tweaks: System Infrastructure

    As before, most of this is peculiar to my Xubuntu setup, but this way I’ll remember it and you might get some benefit, too… something similar will work for whatever distro you’re using, perhaps with a bit of adaptation.

    Note: for all the files you tweak, first copy the original. I tend to save file whatever as whatever.base, but you may do as you see fit.

    Edit ~/.bashrc to enable aliases and get a decent colored prompt:

    force_color_prompt=yes
     ... snippage ...
    PS1="\[\e[1m\][\[\e[33m\]\u\[\e[32m\]@\[\e[36m\]\h \[\e[37m\]\W\[\e[32m\]]\\$ "
     ... snippage ...
    alias ll='ls -l'
    alias la='ls -A'

    What look like gratuitous backslashes in PS1 actually make it work: they escape the unprintable stuff so bash (or whatever) correctly counts the length of the string. That way the command line wraps correctly and backspaces actually back up correctly from line to line.

    It seems WordPress randomly eats backslash characters, so here’s that line with backslashes turned into pipe symbols. Use your favorite editor to replace pipes with backslashes and you should get the original text back:

    PS1="|[|e[1m|][|[|e[33m|]|u|[|e[32m|]@|[|e[36m|]|h |[|e[37m|]|W|[|e[32m|]]||$ "

    Incidentally, the reason you want a colored prompt is so you can find the prompts when you scroll upward in a terminal window. If all the text is the same color, you can’t spot the commands amid the output.

    Edit /etc/bash.bashrc to turn on command completion:

    if [ -f /etc/bash_completion ]; then
        . /etc/bash_completion
    fi

    Add local addresses to /etc/hosts

    192.168.1.1 gateway
    192.168.1.2 oyster
     ... etc ..

    Create NFS mount points:

    sudo mkdir /mnt/bulkdata
    sudo mkdir /mnt/diskimages
    sudo mkdir /mnt/userfiles
    sudo mkdir /mnt/music

    Add NFS shares to /etc/fstab so they auto-mount:

    oyster:/mnt/bulkdata    /mnt/bulkdata   nfs     defaults,noatime,noexec 0 0
    oyster:/mnt/diskimages  /mnt/diskimages nfs     defaults,noatime,noexec 0 0
    oyster:/mnt/userfiles   /mnt/userfiles  nfs     defaults,noatime        0 0
    oyster:/mnt/music       /mnt/music      nfs     defaults,noatime,noexec 0 0

    People pee all over NFS, but the alternatives seem worse. NFS preserves users & groups & permissions, doesn’t have the FAT 2-second timestamp resolution issue, and basically works. Admittedly, when the server goes Tango Uniform, things get really ugly, but that’s not a routine event.

    If you have these files already set up on another system, you can fetch ’em using scp:

    cd /etc
    scp oyster:/etc/hosts /tmp
    sudo mv hosts hosts.base
    sudo cp /tmp/hosts .

    Or, if you’re doing this in another partition, just cp the files from the old installation to the new one. Run diff on the two files to verify that you’ve changed what you think you have and that there’s nothing new sneaking in while you weren’t paying attention.

  • Xubuntu Install Tweaks: Repositories and Programs

    With a fresh Xubuntu (but it’s similar for the rest of ’em) install up & running, it’s time to set up some basic system-level stuff.

    Fire up Synaptic, enable some repositories:

    • Backports
    • Multiverse
    • Restricted

    Add custom repositories (first link is the main site, second is repository & install info):

    There’s some public-key installation required to validate each repository; check the howtos or just search for the obvious keywords, then do what the nice man tells you.

    Update: There seems to be a Synaptic buglet in 8.10 that prevents the Quick Search bar from finding third-party packages; the ordinary Find works correctly. If you can’t find, say, acroread from Quick Search, do this:

    sudo update-apt-xapian-index

    That should get it up to speed again.

    Update 2: The bug is still present in 9.04, if you’re keeping track: 288797

    Reload package info, mark upgrades, apply. Perhaps you’ll get a new kernel out of that, so do one of the few mandatory reboots…

    Install useful programs using Synaptic:

    • flashplugin-nonfree — but turn off Flash cookies — more on that later
    • acroread
    • libdvdcss2 — gasp!
    • non-free-codecs
    • mplayer / mencoder / ffmpeg / sox / lame
    • realplayer — to watch NASA TV
    • nfs-common
    • ssh
    • htop
    • java-common
    • openoffice — not installed by default in Xubuntu
    • msttfcorefonts
    • pilot-link
    • build-essential — you will compile something, eventually
    • gizmo or skype
    • xchm (for LTSpice IV)
    • digikam (it normalizes camera filenames during upload)
    • kmail (or all of Contact, sigh)
    • kmymoney
    • kate

    You can shortcut some of those by installing xubuntu-restricted-extras if you prefer.

    The National Weather Service radar plots require Genuine Sun Java, so:

    • install sun-java6-jre, -bin, -fonts, -plugin
    • remove default-jre, default-jre-headless, openjdk6-jre, openjdk6-jre-headless, -lib

    Doing it in that order makes the dependencies work out. Otherwise, you’d yank the entire OpenOffice suite out by the roots.

    Installing KDE apps perforce drags in much of the KDE infrastructure, but it mostly works. The KDE program menu fonts are tiny and there seems no obvious way to crank them up.

    Download & install:

  • Linux Install Tweaks: The Basics

    The conventional wisdom for Linux installations is to put your /home directory in a separate partition, so that your next installation won’t blow it away. The intent is to save your settings for the new installation and avoid a bunch of tedious reconfiguration.

    That probably made sense back in the day when Unix installations didn’t change very much, very often, but it seems nowadays that hulking programs use elaborate configurations and don’t take kindly to being blindsided by old config files. I can’t provide specific details, but some upgrades have gone awry for mysterious reasons; a clean install fixed everything up again.

    I now do a clean OS installation in a freshly formatted partition, then spend a day or two tweaking everything. This eliminates a tremendous amount of cruft, takes advantage of new features, and generally seems to be more productive than dicking around trying to figure out exactly which old setting pooched the new version.

    Two meta-configuration choices help a lot:

    • All our “data” files live on a file server in the basement that’s mounted via NFS, so the local system doesn’t have much more than its own configuration.
    • Hard drives have plenty of space, so slicing the drive into smaller chunks and preserving the old installations doesn’t cost anything.

    Case in point: I’m setting up Xubuntu 8.10 on a system with partitions containing Kubuntu 7.10 and 8.04. I’ve blown away several different trial installations of Kubuntu & Xubuntu in this partition already; now things are looking good. The trick is to use manual partitioning and aim the installer at the correct spot.

    Make sure you get that right and always back up your partitions first!

    The disk layout on this box:

    sudo fdisk -l /dev/sda
    
    Disk /dev/sda: 160.0 GB, 160000000000 bytes
    255 heads, 63 sectors/track, 19452 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Disk identifier: 0xd0f4738c
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1               1           7       56196   de  Dell Utility
    /dev/sda2   *           8        2489    19928633    7  HPFS/NTFS
    /dev/sda3            2489        2973     3888569+  db  CP/M / CTOS / ...
    /dev/sda4            2974       19452   132367567+   f  W95 Ext'd (LBA)
    /dev/sda5            2974        3496     4200966   82  Linux swap / Solaris
    /dev/sda6            3497        6107    20972826   83  Linux
    /dev/sda7            6108       15245    73400953+  83  Linux
    /dev/sda8           15246       19452    33792696   83  Linux

    Yup, it has Windows on it; rarely gets booted, but it’s there. You cannot begin to imagine the number of reboots required to update even a minimal Windows install after a year.

    So, to begin…

    The first steps with a new PC:

    • back up the drive
    • shrink the Windows partition down to maybe 20 GB
    • snuggle the other pre-installed partitions next to it
    • create an extended partition over the rest of the disk
    • set up the Linux partitions

    After you’ve done that the first time, you never have to do it again… just ping-pong between two (or three!) Linux partitions with each new installation. There’s a bit of fussiness with grub, but it’s easy enough to either let the new installation capture the MBR or re-aim it at the old installation after the fact.

    For more details on partitioning & backups, particularly for laptops, go there. Use partimage (use System Rescue CD) for whole-partition backups to a USB drive and move on.

    I favor the mini.iso installation method, as it tends to install less cruft and loads the latest versions right from the start. Start from there and proceed as directed.

    Don’t do an x86_64 installation, even though you think it’d be cool. Flash doesn’t work yet and restarting Firefox a dozen times a day simply isn’t attractive. Trust me on this.