Procrastiblog

June 24, 2008

Resetting a Terminal

Filed under: Linux, Tech — Chris @ 2:04 pm

You tried to cat a binary file and now your terminal displays nothing but gibberish? Just type reset (it may look like ⎼␊⎽␊├).

It has taken me more than 10 years to learn this.

[UPDATE] Interestingly, this doesn’t work in my (alas, ancient) Mac OS X 10.3.9 terminal. Any tips? Also, why did curl URL_TO_BINARY hose my terminal in the first place?

Advertisements

April 30, 2008

Linux Quickies

Filed under: Emacs, Linux, Tech — Chris @ 8:31 pm


The upgrade from Ubuntu Gutsy to Hardy Heron (cool logo, right?) was relatively uneventful. Some minor points…

  • I always thought the main Ubuntu servers would farm my downloads off to an appropriate mirror, but apparently that’s not the case. You’re likely to get better download times if you choose a mirror in System -> Administration -> Software Sources. If you choose “Other…”, there’s a “Select Best Server” feature. Oddly, my best response times were from New Zealand… maybe because they were all asleep when I tried it.
  • The “ugly fix” for the infamous hard disk annihilating bug stopped working after I upgraded. This new, different (but still ugly) fix worked for me. It would be really great if the Ubuntu team could find a way to make the OS stop trying to kill my hard disk by default.
  • My WiFi light stopped working after the upgrade. This is very easily fixed by installing the package linux-backports-modules-hardy.
  • etckeeper is a great idea: it puts all the config files in /etc under Git, Mercurial, or Bazaar source control and forces APT to commit before and after any upgrade, so it’s easy to isolate and revert changes. (As a side note, using Bazaar for a few weeks makes it physically painful to be forced to deal with CVS.)
  • Anti-aliased fonts in Emacs are really nice. On Ubuntu Hardy, install emacs-snapshot-gtk (on prior releases, downloads “Pretty Emacs”), then run emacs-snapshot instead of emacs (or run update-alternatives to set emacs-snapshot as the default). You should then be able to run, e.g., emacs --font "Monospace-10" and get pretty, pretty (lick-able, as they say) fonts. Other reasonable choices are "BitstreamVeraSansMono-X" or "LiberationMono-X", where X is your desired point size. You can also invoke M-x set-default-font and type your choice interactively, but for some reason the TrueType fonts above won’t tab-complete—if you type a non-existent font, Emacs will silently use the default system fixed-width font (see System -> Preferences -> Appearance -> Fonts). I’ve added the following to my .emacs:

    (if (>= emacs-major-version 23)
    (set-default-font "Monospace-10"))

    (The conditional is necessary if you may come into contact with earlier versions of Emacs, which will barf on TrueType fonts.)

  • In my experience, the fonts in your web browser will look better if you don’t use Microsoft’s gratis TrueType core fonts (package msttcorefonts in Ubuntu/Debian). In particular, the Trebuchet font (which crops up frequently, including at the top of this page) tends to look pretty bad with subpixel rendering turned on. Red Hat’s Liberation fonts (package ttf-liberation) are designed as drop-in replacements for the Microsoft fonts, but I haven’t seen much value in installing them.
  • The instructions I gave last month for hooking up to a projector aren’t complete, because they often won’t let you run the projector at a resolution greater than 640×480. This led to a rather embarrassing scene in front a class of undergraduates, where OpenOffice.org simply refused to operate at such a pathetic resolution. This problem can be solved by the methods presented here, though it requires a bit of tweaking to get things just so. I haven’t yet discovered a minimal solution—first I need to crack the meaning of the X11 “MetaModes” option. When I do, you’ll be the first to know.

April 15, 2008

Only Thus Can It Be Unmade

Filed under: Linux, Tech — Chris @ 3:08 pm

The cleverer among you will espy the problem below immediately

$ export DATE=`date`
$ echo $(DATE)
bash: DATE: command not found

In my half-caffeinated state, it took several minutes of frustration to figure out what was wrong: $(DATE) is a Make-style variable; in Bash, $(DATE) is the same as `DATE` (a command substitution). The correct token is $DATE.

$ echo $DATE
Tue Apr 15 11:08:38 EDT 2008

I apologize for inflicting my stupidity upon you.

April 2, 2008

Using an External Monitor or Projector With My Linux Laptop

Filed under: Linux, Tech — Chris @ 9:26 pm

For years, it was difficult enough to get my laptop working with an external monitor that I didn’t even bother trying: I would boot into Windows in order to give a presentation. (This is the only reason I ever booted into Windows (or have a Windows install).) It either got dramatically easier to accomplish this at some point in the last year, or I’ve been incredibly stupid all this time. Just in case, here’s how it works on my Dell Inspiron 6400 running Gutsy. My video card is an NVIDIA GeForce Go 7300

  1. Plug in the external monitor or projector. The monitor may work immediately (especially if you’re repeating this step after fiddling about below), but it may be at the wrong resolution.
  2. Open “Applications -> System Tools -> NVIDIA Settings” or execute sudo nvidia-settings on the command line. This utility is provided by the nvidia-glx-new package, which you should probably have installed.
  3. Choose “X Server Display Configuration” and click “Detect Displays” at the bottom of the screen.
  4. The external monitor should appear in the Layout pane. Click on it, then click “Configure”. Choose “TwinView” (which should hopefully not say that it requires an X restart).
  5. In the “Display” box, choose “Position: Clones”. This means that you want the same display to appear on both monitors. This is what works best for me, particularly for giving presentations. Having separate displays seems to confuse applications—for example, “Presentation Mode” in Evince will “center” the slides, displaying the left half of a slide on the right half of the laptop screen and the right half of a slide on the left half of the projector. It’s probably possible to tweak this with exactly the right viewport/workspace settings (ugh), but that’s not how I roll.
  6. If the display is smaller than the default display—the display’s square will be smaller in the Layout pane and the displayed area will be cropped on the screen—click on the
    default display in the Layout pane and choose a lower resolution. 1024×768 is usually safe. The laptop display will probably look bad, but the external display should look fine.

    Be careful: any smaller than 1024×768 and the Settings applet will be too big to display on the screen. If this happens, you’ll have to navigate blind or hit Ctrl-Alt-Backspace to restart X (or don’t automatically hit OK after the resolution changes and it will revert after 15 seconds).

To remove the external monitor or projector:

  1. Unplug the monitor.
  2. Click “Detect Displays”.
  3. A message “The display device FOO has been unplugged…” will appear. Click “Remove.”
  4. Click “Quit”.

Under no circumstances should you click “Save to X Configuration File” at any point in this process. That’s just asking for trouble.

Some sequence of actions—it’s not clear which—may screw up the “X Server Display Configuration” pane. The display will
continue to function in the meanwhile, but all the above commands are inaccessible. Restarting X made it go away (for me).

[UPDATE] It seems it’s necessary to update your xorg.conf to get decent resolution on some projectors. I’m still investigating… In the meantime, this should help.

November 25, 2007

Gnome Sessions

Filed under: Linux, Tech — Chris @ 8:56 pm

I tentatively clicked “Remember current running applications” in Gnome Session Preferences (aka gnome-session-properties) and lived to regret it. What this does is it restarts any currently running application when you login. This is useful for, e.g., your online backup daemon, but kind of annoying for, e.g., five Emacs windows, Last.fm, some random Nautilus directory window, etc.

Now, first I tried checking and unchecking “Automatically remember running applications when logging out”, as the window layout makes it seem as if these two settings are related. They are not. Then, I was tempted to fix this by futzing with the “Startup Programs” or “Current Session” lists. This is Not Right.

The Right Thing is to close all your programs (or just the offending ones) and then click again on “Remember current running applications”. That is to say: the only way to change the “remembered” snapshot is to take another snapshot*.

Note: Session Preferences has a Help button, but the Gnome manual page on it doesn’t mention “Remember currently running programs” or “Automatically remember running applications when logging out”. This is annoying.

* Presumably there is a text file tucked away somewhere that controls this (maybe ~/.gnome2/session?), but I haven’t the patience to find out.

November 10, 2007

Eye Candy

Filed under: Linux, Tech — Chris @ 11:24 pm

The difference between “Desktop Plane” and “Desktop Wall” in the Ubuntu “Visual Effects” options (aka CompizConfig Settings) is that the latter allows windows to overlap a viewport* and the former does not. (Along with this comes a lot of incidental options and visual fillips, like the ability to drag a window entirely from one viewport to another.) Although this does not sound like a big productivity booster, I’m going to give the Wall a chance.

I’m not going to give the “Desktop Cube” a chance, because it won’t let me place viewports above and below, as well as left and right, seemingly out of some wrong-headed sense of pseudo-three-dimensional literalism (although your “cube” can have an arbitrary number of faces, they must be arranged linearly from left to right: Euclidian topologies only).

* For some reason the “Desktop Plane,” “Desktop Wall,” and “Desktop Cube” options all use viewports and not workspaces**, so they don’t work well with the Gnome Workspace Switcher.

** For some other reason, Gnome has two distinct ways of implementing virtual desktops (viewports and workspaces) even though theres no discernible advantage to one over the other (except for compatibility with this application or that).

[UPDATE] Visual Effects lead to intermittent system freezes. Fun! Going back to boring old workspaces.

November 6, 2007

Updating for Daylight Savings Time on Ubuntu

Filed under: Linux, Tech — Chris @ 9:28 pm

My system clock has been all wiggy since Daylight Savings Time ended (or started?) (it’s ended) on Sunday. Believe it or not, it was actually flipping back and forth between correct and one hour ahead for no apparent reason. I did two things which together seem to have fixed things.

First, via Fast Track Sites, I found that my system timezone information was out of date. The test for this is:

% sudo zdump -v /etc/localtime | grep 2007
/etc/localtime Sun Mar 11 07:59:59 2007 UTC = Sun Mar 11 01:59:59 2007 CST isdst=0 gmtoff=-21600
/etc/localtime Sun Mar 11 08:00:00 2007 UTC = Sun Mar 11 03:00:00 2007 CDT isdst=1 gmtoff=-18000
/etc/localtime Sun Nov 4 06:59:59 2007 UTC = Sun Nov 4 01:59:59 2007 CDT isdst=1 gmtoff=-18000
/etc/localtime Sun Nov 4 07:00:00 2007 UTC = Sun Nov 4 01:00:00 2007 CST isdst=0 gmtoff=-21600

If the output doesn’t exactly match the above, you have a problem. Download the latest tzdata2007X.tgz file (where X is a lowercase letter) from the National Cancer Institute (seriously). For gorey details, see the Fast Track Sites post cited above. (I don’t think you really have to do the ln step, which sets your timezone to EST5EDT instead of, e.g., America/New_York. I skipped it.)

Now your system ought to know the right start/end dates for Daylight Savings Time. But your clock is probably still out of whack.

Now, via Ubuntu Forums and Stephen Sykes, use ntpdate to reset the clock. The trick(s) here are: (a) you have to shut down ntpd first, (b) setting the clock back an hour will convince sudo that you’re trying to do something nefarious (“timestamp too far in the future”), and (c) I had to give ntpdate the -u option to get past some unseen firewall.

% sudo /etc/init.d/ntp-server stop
 * Stopping NTP server ntpd                                 [ OK ]
% sudo ntpdate-debian -u
 6 Nov 17:00:00 ntpdate[13693]: step time server 66.36.239.104 offset -3598.042737 sec
% sudo /etc/init.d/hwclock.sh restart
sudo: timestamp too far in the future: Nov  6 17:59:56 2007

Oops. Using the “Adjust Date & Time” applet, manually set the clock one hour forward. Now, run sudo -k. Now, set the clock back to the correct time (again using “Adjust Date & Time”). Starting over:

% sudo ntpdate-debian -u
 6 Nov 17:00:00 ntpdate[13693]: step time server 66.36.239.104 offset -3598.042737 sec
% sudo /etc/init.d/hwclock.sh restart
 * Saving the system clock
% sudo /etc/init.d/ntp start
 * Starting NTP server ntpd                                [ OK ]

All done. Enjoy.

[UPDATE 3/12/2008] It looks like this might be a semi-annual ritual: my system pulled the same schizo act when DST started this week. On Gutsy, ntp-server has become ntp. It’s easier springing forward than falling back, because sudo just times out when you set the clock forward.

[UPDATE 3/9/2009] A fall back and a spring forward with no problems. Whoopee.

April 27, 2007

Ubuntu Names

Filed under: Linux, Tech, Waste of Time — Chris @ 4:06 pm

Oddly enough, Ubuntu has a web page about the names. Apparently, it just didn’t occur to them to go in alphabetical order until after breezy. But why did they skip C?

I think Adjective Animal would be a great name for their 27th release.

Azureus

Filed under: Linux, Tech — Chris @ 3:53 pm

What’s the story with this piece of crap? Azureus seems to be every right-thinking Linux geek’s favorite BitTorrent client, but I have never once had it succesfully download anything. It hangs and/or crashes pretty much immediately. This has been the case on multiple computers and four different versions of Ubuntu. Is it me? Is it SafePeer?

[UPDATE] There was a widespread, virulent bug in Azureus. I’ve been able to work around it, though I’m not quite sure how. It really is a great BitTorrent client…

Feisty Fawn

Filed under: Linux, Tech — Chris @ 3:28 pm

I upgraded my laptop from Ubuntu edgy to feisty last night and I’m please to report (after a rather unpleasant experience upgrading from dapper to edgy, documented here, here, and here) that the whole thing went off without a hitch. The upgrade process asked a lot of annoying questions about whether or not it should clobber various config files, but I just said “Yes” to all of them and have seen no ill effects. It even gracefully downgraded my nVidia driver to the latest version in the Ubuntu repository and Suspend still works. Who knew that was possible?

Are there any great benefits to upgrading? Um… not that I can tell. The version of Liferea is more recent and there’s a search button in the Panel. These are hardly blockbuster features. The main benefit to me is that “are you running feisty?” will not be the first and last response to every question I post to the support forums. (This will be replaced with “are you running gutsy?” within a month.*)

* Speaking of which: I am really fond of the names Breezy Badger, Dapper Drake*, Edgy Eft, and Feisty Fawn. But, Gutsy Gibbon? Yuck.

** Does anyone know the story behind the naming scheme? I.e., how Ubuntu went from Warty Warthog and Hoary Hedgehog to the current Sue Grafton-esque release-naming convention? And why they skipped A and C?

« Newer PostsOlder Posts »

Blog at WordPress.com.