Sunday, September 29, 2013

KDE screensaver in Ubuntu 13.04, part 2: disable locking

Some security updates upgraded kde-workspace-bin, which upgraded /usr/lib/kde4/libexec/kscreenlocker_greet, which restored the infuriating behavior I've previously described: notably, that the screen locker runs after ~4 seconds of idle.

It's still not entirely clear to me what's happening, but it looks like the scenario goes something like this: ksmserver runs kscreenlocker_greet all the time. kscreenlocker_greet looks like it examines the configuration file(s) $HOME/.kde/share/config/kscreensaverrc and/or /usr/share/kde4/config/kscreensaverrc for settings and triggers off of those.

This can't be how it's supposed to work, because kscreenlocker_greet is only run once at the beginning of each idle period. I've verified this by replacing kscreenlocker_greet with this script:

#!/bin/sh
echo "`date` - start: $0 $@" >> $HOME/kscreenlocker_greet.log
exit 0
I can then "tail -f" the log file and watch as KDE tries to lock my screen.

Fortunately, kscreenlocker_greet appears to read the kscreensaverrc configuration file, which I've modified to read as this:
Enabled=false
LegacySaverEnabled=false
Lock=false
PlasmaEnabled=false
Saver=krandom.desktop
Timeout=1800
What all of those mean I cannot say, but "Enabled=false" and "Lock=false" seem to be helpful.

The part that's still troublesome is that while the screensaver is being activated, my keystrokes are being consumed, so it appears that I'm always dropping letters as I try to type.

Whatever's going wrong is doing it in ksmserver, and that program, naturally, has no man page. For now, this config file change should prevent the annoyance from recurring after an upgrade. I'll leave digging into ksmserver for another day...




Wednesday, September 18, 2013

Fix to prevent line breaks at hyphens in HTML

The problem

When writing HTML you may want to include something like a phone number in the form 1-800-555-1212. The problem is that this might be displayed as:
... 1-800-555-
1212...
This is probably not what you want - you'd prefer the entire thing to appear on one line.

Solution(s)

Non-breaking Hyphen

This is the most obvious logical solution - we have non-breaking spaces ( ) so all we need is a non-breaking hyphen, right? Well, not quite.
First, there is no standard entity for a non-breaking hyphen. Instead, this is a character defined in the Unicode specification as character #8209. If you want to use this in your HTML you can use either ‑ or ‑. The problem here is the font - most fonts probably don't include this character and will render it as some box with either digits or punctuation inside. What other options are there?


CSS white-space

This is the most correct answer. It requires two steps. First, define a CSS class:
.nobreak { white-space: nowrap; }
Then use it your HTML as:
<p>Lorem ipsum <span class="nobreak">1-800-555-1212</span>.</p>
The especially nice thing about this is that it's generic and will work equally well with:
<p>Dolor amit <span class="nobreak">1 (800) 555-1212</span>.</p>


My hack: super-under

And just in case you're curious what kind of craziness I can come up with, here's my third possible solution:
<p>Sibiliy si emgo: 1<sup>_</sup>800<sup>_</sup>555<sup>_</sup>1212.</p>
Yes, that's right: Take an underscore character ('_') and superscript it. A work of genius I say ...

Tuesday, September 03, 2013

Moving virtual hard disks in VirtualBox

Under Linux, VirtualBox likes to put it's virtual disks in a relatively inconvenient directory. Newer versions are more obnoxious, and have removed the ability to easily manage your virtual disks. As most of the information I find online is old and does not apply to VirtualBox 4 or 4.2 (the specific version I have, shipped with Ubuntu 13.04), or may work but just seems too hard, here's a nice little recipe:

To move a virtual disk from point A to point B:

  1. Ensure the virtual machine(s) owning the disk are powered off.
  2. Open the settings for the virtual machine(s) owning the disk.
  3. Go to "Storage", select the disk, and click the Remove icon. Then click OK.
    • Repeat for each associated VM as necessary
  4. From the main VirtualBox panel, select File->Virtual Media Manager
  5. Click on the Virtual Disk image, verify the Location, and that it is not attached to any VMs.
  6. Click the Remove icon along the top *
  7. Click Close.
  8. Now, from the commandline or file manager, move the newly-freed VirtualImage.* files from point A to point B.
  9. Finally, back in VirtualBox, select the virtual machine configuration and select "Settings".
  10. Go to "Storage" and select the Controller where the virtual disk used to be.
  11. Click on the Add Attachment icon and select Add Hard Disk.
  12. Select Choose existing disk, navigate to point B, and select your virtual disk.
If you try to skip steps 4-7 VirtualBox will complain about adding a disk image with an already existing UUID, so that image has to be removed from the Virtual Media Manager first. If you have multiple VMs attached to the same disk this can get tedious, but it's better then the other suggestions I've read, including cloning the disk or VM, or even removing the virtual machine itself (including all your settings!)

This also has the nice benefit that *you're never going to be prompted to delete the files from disk. (And if I'm misremembering that and you are prompted, but sure to select NO.) You may be able to select "Detach" from the Virtual Media Manager instead of going through each configuration, but I'd recommend doing it the hard way so you can be sure to take notes and verify what you're doing as you do it.