My Weblog

Thu, 02 Jul 2009

For quite some time now I've been using Fluxbox as my window manager of choice. It's simple, clean-looking and relatively lightweight. Like most other window managers, Fluxbox is a stacking WM, meaning windows can be moved around freely and overlap. I've never really worked well with this design however, since I tend to open lots of terminal windows and forget to close them. Eventually I have so many windows open it's hard to find anything, so I either have to spend time figuring out which ones I need and which I don't, or just let them be and open yet another terminal. Obviously, this only makes the situation worse.

To solve this problem, I recently switched to Awesome, a tiling window manager. Unlike stacking WMs, tiling WMs try to automatically arrange all of your on-screen windows so that they don't overlap (although most also support "floating" windows like you get with a stacking WM). Basically, when you open the first window it uses the entire screen. When a second window is opened, the screen will be divided between the two. If you close a window, the space it used is divided amongst the other windows, automatically resizing them as necessary to fill the space. This way you don't have to go manually moving and resizing everything.

Additionally, Awesome uses Lua for its configuration file, so it is much more extensible than many other window managers (tiling or not). Finally, like other tiling WMs, you can use the keyboard to do everything in Awesome, although you can use the mouse as well.

posted at: 14:14 | path: /computers/linux/apps/x11 | permanent link to this entry

Mon, 19 Mar 2007

Hiding Private Data on Public NFS Shares
I have a public read-only NFS share on my machine. Exporting it as read-only stops others from adding, deleting, or modifying any files. However normal Unix permission checks apply so if I make a file owned by my user id that only my user has the read permission for, anyone else can still read it as long as he has a user with the same id on his machine. I was running low on storage space on my home partition, and I needed to temporarily use this public share to store data. The problem is that I didn't want everyone to be able to read what I stored there.

I already have the root_squash option set, but that doesn't help me in this case. Reading the exports manpage, I found the all_squash option which maps all remote UIDs to the anonymous user (nobody). This way even if a remote user has a UID that matches mine, when he attempts to access a file or directory that doesn't have read permission for 'other' he can't read my data.

The moral of the story is that if you have a read-only public NFS share, it's good to add 'all_squash' to the export option list.

posted at: 11:19 | path: /computers/linux | permanent link to this entry

Wed, 02 Mar 2005

Tweaking Firefox's Popup Blocker
Recently advertisers have figured out how to get around firefox's popup blocker. Normally, firefox blocks popups except for those that happen within a specified interval of user actions like click, double click, submit, etc. The problem is that some sites like are set up so that most links have a javascript onClick handler that displays a popup ad. There's a way around this. Modify the dom.popup_allowed_events property to have the value 'change #click dblclick #mouseup reset submit'. This property specifies which events may create popup windows.

Commenting out 'mouseup' and 'click' allows popups associated with forms to work but stops onClick ads. Unfortunately, it also breaks sites that use onClick to do something useful, like display an image in a new window (which is still evil, but at least it's not an ad). If this breaks a particular site, set firefox to allow popup ads from it.

See this Slashdot thread for more useful stuff.

posted at: 09:04 | path: /computers/linux/apps/firefox | permanent link to this entry

Fri, 28 Jan 2005

MST3K Episode List
Here's the current list of all Mystery Science Theater 3000 episodes I have in my collection. Some are on DVD, some on VHS, and some in mpeg or avi format.

TitleEpisodeCastGenreRunning TimeFormat
Mitchell???Joe Don Baker, Linda EvansCrime Drama/ComedyFar too longDVD
Overdrawn at the Memory Bank???Raul JuliaScience Fiction00:00DVD
Manos: Hands of Fate???Bad ActorsHorror? (I guess)00:00DVD
Santa Claus Conquers the Martians???ChristmasDVD

posted at: 22:06 | path: /mst3k | permanent link to this entry

Command Line Niftyness
Every so often I find a command that has some nifty feature that I didn't know about. I want to document those commands and their features here.

Finding the full pathname of a file
The 'readlink' command is used to get the name of the file that a symbolic link points to. Normally it sends the exact contents of the symlink to stdout, but with the '-f' option it will resolve the full path to the file and send that to stdout instead. Useful if you want to determine from within a script the full pathname of a file. An additional bit of niftyness is that this works on non-symlink files too as long as you pass the -f option.

I think that only the linux version of readlink does this. There is a standard C library function called realpath() that does the same thing.

posted at: 21:29 | path: /computers/linux | permanent link to this entry

Mon, 18 Oct 2004

Red Hat Gets Terminal Settings Wrong
Okay, I don't really mind if Red Hat decides to do things differently than Debian, but I do mind if they way they do things breaks the standard, accepted way. In this case, I'm referring to the way that Red Hat configures the terminal backspace character.

Now, Red Hat configures the Backspace key to send Control-H, which is the classic, historical setting for it. However, this interferes with Emacs, which uses Control-H to start the help system. The modern (and IMHO correct) setting is to use ASCII DEL (^?, value 127) for Backspace. Debian follows this method as detailed in the Keyboard Configuration section of the Debian Policy Manual. This allows Backspace, Delete, and Control-H to be interpreted independently of one another.

The fact that Red Hat chooses to use the old configuration bothers me, but I can deal with that. What I can't deal with is that Red Hat puts the following code into /etc/bashrc:

    if [ -x /usr/bin/tput ]; then
      if [ "x`tput kbs`" != "x" ]; then # We can't do this with "dumb" terminal
        stty erase `tput kbs`
      elif [ -x /usr/bin/wc ]; then
        if [ "`tput kbs|wc -c `" -gt 0 ]; then # We can't do this with "dumb" terminal
          stty erase `tput kbs`
This sets the tty erase character to whatever is specified as the backspace code in the terminfo database. Whoever wrote this is trying to work around terminals that send one character with the backspace key, yet whose tty device is set to use the other character. This may work with terminals on the local machine, or with remote logins to machines that use the same erase character, but it breaks backspace on other systems. The erase character is correctly set by telnetd and sshd to match the erase character used on the client, and this code forces it to be whatever character the server uses. The program being run must generate output that is correctly displayed on the user's terminal, which means that the server must use the terminal settings the client wants, not the other way around.

It is also unreasonable to consider this a fix for local terminals whose erase character and Backspace binding don't match up. If this is the case, then there is a configuration problem and it should be corrected by changing the configuration for that specific terminal or emulator (i.e. by changing the backarrowKey, ptyInitialErase, or backarrowKeyIsErase resources for xterm). Writing a shell script to work around the problem doesn't fix it, it just hides the problem.

A possible solution would be to run stty erase ^? explicitly in my shell startup script. This is unacceptable however, since it 1) doesn't change the fact that Red Hat's default setup is broken and 2) some of my accounts are used by several other people who use different distros, and setting the erase character explicitly might break their terminal settings.

To take one step toward solving this problem, remove above code from /etc/bashrc. It's a nasty kludge written solely to cover up the fact that Red Hat can't figure out how to change X resources and terminal emulator settings to match their termcap and terminfo databases.

Update: I have noticed that the delete key is also broken. This isn't that big of a deal, it's just annoying. On some machines the delete key (in bash at least) has the same effect as the backspace key (delete previous character) and on others it prints a tilde (and probably some control characters). As long as it doesn't break things for anyone else, I'm fine with it. I use backspace a lot more than delete anyway :-)

Actually, this appears to only be a problem when running a remote screen session on some redhat boxes. Remote ssh sessions work fine. For some reason, screen on these machines doesn't set the kD termcap capability correctly. It would be awesome if the TERMCAP variable was preserved for remote logins. :-/

Update (2004-10-18): I've discovered another stupid RedHat BS/DEL 'fix'. RedHat provides a global configuration file for GNU screen, which is an application that I depend on everyday. In this /etc/screenrc file, there is the following code:
# This makes screen treat backspaces '^?' as
# deletes. There should be a fix in the code
# for the way termcap inheritance works,
# but I dont know where to put it, and this works.
bindkey -d -k kb stuff "\010"
This forces the backspace key to send ^H, which is WRONG!!! Even if you think that ^H is the correct character for backspace (which it isn't), it is not correct to force screen to send ^H for backspace. If my kb/kbs entry is defined as ^?, this code makes it absolutely impossible to send ^?, since screen will always translate it to ^H. I don't know what the heck this is supposed to fix. If my kb/kbs is defined as ^H to begin with, this does nothing and is therefore useless. If the kb/kbs entry is ^?, now it becomes impossible to send DEL to the application. This will break all apps that use the stty erase character to determine what backspace should be if the erase character isn't ^H. Now another fix is required, like the brain-dead 'stty erase `tput kbs`' hack described above. The only way to solve the problem is as follows:

  1. Remove all hacks from both system-wide and personal config files that change stty erase, the kb/kbs definitions, or the mapping for the backspace key
  2. Choose a system-wide backspace character (either ^H or ^?)
  3. Change terminfo/termcap entries so that kb/kbs is set to that character
  4. Make sure all terminal emulators send this character when the backspace key is pressed. This should be set system-wide
  5. Make sure all terminal emulators set the erase character to this value. This should be set system-wide
  6. Configure applications system-wide to use the stty erase character to determine what the backspace key sends
  7. If that is not possible, configure the application to accept both ^H and ^? for backspace
  8. If that is not possible, make sure the apps use termcap/terminfo to determine the backspace character
  9. If that is not possible, then the app is broken and must be fixed.

If you do these steps, backspace will only be broken under the following conditions:

In short, the stty erase character should be treated as correct at all times, and termcap/terminfo should match it. The backspace key should also match it. Any other configuration will have more problems than this one. If someone tells you otherwise, they're stupid. Ignore them.

posted at: 11:46 | path: /computers/linux/redhat | permanent link to this entry

Mon, 07 Jun 2004

Vi Keybindings for Firefox
I have finally figured out how to make firefox recognize vi keybindings. Below are the steps required to make it work on Debian boxes (most of them work for all unix platforms):

1. Copy /usr/lib/mozilla-firefox/chrome/browser.jar to your $HOME/.firefox/default/ directory.
2. Unzip browser.jar and edit the content/browser/browser.xul file, adding the following lines to the end of the section:

<key  key="," command="Browser:Back"/>
<key  key="." command="Browser:Forward"/>
<key  key="a" command="Browser:Home" />
<key  key="r" oncommand="BrowserReload();" />
<key  key="r" oncommand="BrowserReloadSkipCache();" modifiers="shift" />
<key  key="n" command="cmd_findAgain" />
<key  key="n" command="cmd_findPrevious"  modifiers="shift"/>
<key  key="o" command="Browser:OpenLocation" />
<key  key="O" oncommand="focusSearchBar();" modifiers="shift"/>
<key  key="w" command="cmd_newNavigator" modifiers="shift"/>
<key  key="w" command="cmd_newNavigatorTab"/>
<key  key="q" command="cmd_close" />
<key  key="q" command="cmd_closeWindow"  modifiers="shift"/>
<key  key="f" command="View:FullScreen" />
<key  key="z" command="cmd_textZoomReduce"  />
<key  key="z" command="cmd_textZoomEnlarge" modifiers="shift"/>
<key  key="s" command="View:PageSource" />
<key  key="i" command="View:PageInfo" />
<key  key="b" command="Browser:AddBookmarkAs"  modifiers="shift"/>
<key  key="b" command="viewBookmarksSidebar" />
<key  key="h" command="viewHistorySidebar" modifiers="shift"/>
<key  key="d" command="Tools:Downloads" />
<key  key="p" command="cmd_print"  modifiers="shift"/>

3. Edit the $HOME/.firefox/default/ file. Add the following attribute to the tag (below is the example from my chrome.rdf file):


4. Copy /usr/lib/mozilla-firefox/res/builtin/platformHTMLBindings.xml to /etc/mozilla-firefox.
5. Run 'dpkg-divert --rename /usr/lib/mozilla-firefox/res/builtin/platformHTMLBindings.xml'.
6. Run 'ln -s /etc/mozilla-firefox/platformHTMLBindings.xml /usr/lib/mozilla-firefox/res/builtin'.
7. Add the following lines to /etc/mozilla-firefox/platformHTMLBindings.xml at the end of the section:
<handler event="keypress" key="a" modifiers="alt" command="cmd_selectAll"/>
<handler event="keypress" key="u" command="cmd_scrollPageUp" />
<handler event="keypress" key="k" command="cmd_scrollLineUp"/>
<handler event="keypress" key="j" command="cmd_scrollLineDown"/>
<handler event="keypress" key="h" command="cmd_scrollLeft"/>
<handler event="keypress" key="l" command="cmd_scrollRight"/>
<handler event="keypress" key="g" command="cmd_scrollTop"/>
<handler event="keypress" key="g" command="cmd_scrollBottom" modifiers="shift"/>
<handler event="keypress" key=";" command="cmd_findTypeLinks"/>
Steps 4-6 prevent dpkg from replacing the modified file with the one in the package. If you're not running Debian, you can skip them and put the above lines straight into the platformHTMLBindings.xml file. You should be able to put the above lines into userHTMLBindings.xml in your chrome directory, but there is a bug in mozilla and firefox that prevents this from working. For now, doing steps 4-6 basically turns platformHTMLBindings.xml into a system-wide configuration file that will be preserved between upgrades.

posted at: 18:10 | path: /computers/linux/apps/firefox | permanent link to this entry

Thu, 27 May 2004

Scroll Wheel Hack for Text-Based Apps
Most mice these days have one of those scroll wheels as the middle button. Many graphical applications can use the scroll wheel to scroll various on-screen objects, such as list boxes and text boxes. I was wondering if it were possible to make text-based applications recognize the scroll wheel and scroll appropriately. I found some web sites that focused mainly on getting X to recognize the wheel, and a few that had info on configuring graphical apps to scroll on wheel clicks. The few pages that had any info on text-based apps provided a solution that mapped the wheel clicks to PageUp, PageDown, Up, Down, etc. While this works in many applications, it doesn't allow for the wheel to scroll by different amounts based on context (i.e. 1/2 page in less, 5 lines in vim, etc). So, I played with my .Xdefaults file a bit and came up with the following solution:

Instead of forcing the wheel clicks to map to PageUp or PageDown, why not map the clicks to unused escape sequences? This would effectively create two keys (or more if you want to use modifier keys with the wheel) that could then be mapped on a per-application basis. Here's the relevant section from my .Xdefaults file:

XTerm*vt100.translations: #override\n\
        Meta,: string("0x9b") string("[25;3~")\n\
        Meta,: string("0x9b") string("[26;3~")\n\
        Shift,: string("0x9b") string("[25;2~")\n\
        Shift,: string("0x9b") string("[26;2~")\n\
        Ctrl,: string("0x9b") string("[25;5~")\n\
        Ctrl,: string("0x9b") string("[26;5~")\n\
        ,: string("0x9b") string("[25~")\n\
        ,: string("0x9b") string("[26~")\n\

Here, I map button 4 (scroll up) to "^[[25~" and button 5 (scroll down) to "^[[26~" (the 'string("0x9b")' part expands to the escape character, or Ctrl-[ ). The other escape sequences are similar to what you would get if you held Ctrl, Shift, or Meta down while pressing a function key.

Once the above translations have been put into the .Xdefaults file and loaded (either by restarting X or running 'xrdb -merge .Xdefaults'), you can then configure text-based applications to recognize the wheel using their native key binding functions. For example, I put the following lines into my .zshrc to configure zsh to scroll through command history on wheel clicks:

bindkey "\233[25~"     up-line-or-history
bindkey "\233[26~"     down-line-or-history

Then, I configured less to scrolll 1/2 page on just a wheel click, a full page on shift+wheel click, and one line on ctrl + wheel click by putting this in my .lesskey and running lesskey:

posted at: 22:14 | path: /computers/linux | permanent link to this entry

Sat, 22 May 2004

My Proposed Partitioning Scheme
Lately I've been thinking of redoing my partitioning scheme. Currently I'm using an LVM-root setup, which has caused me some difficulty. I have been unable to upgrade to the new 2.6 kernel because I can't seem to build a kernel and initrd that support the version of LVM I'm using (can't find the correct version of vgscan). My solution is to move the root partition out of LVM, since I'm never going to resize it anyway. Also, this eliminates the need for an initrd and a seperate /boot partition. In addition, if the LVM partition gets hosed, I have a basic system I can use to fix it.

Here's my planned setup. This will be used on two drives, one 200GB and one 40GB (my laptop). The /var partition is larger because that's where my Apt cache is, and I need it for package downloads. 2.0GB is plenty for me for /usr because I don't install much under /usr/local (Debian has everything packaged already :-), I don't install packages I don't need, and I do my kernel builds under $HOME. /home usually fills the remainder of the disk (or physical volume) unless the disk is huge. I don't think I'll ever exceed 40GB for personal files, but I can always resize /home if I need to.

/dev/hda1	/	ext3	150MB
/dev/vg01/usr	/usr	ext3	2.0GB
/dev/vg01/tmp	/tmp	ext3	1.0GB
/dev/vg01/var	/var	ext3	1.0GB
/dev/vg01/swap	swap	ext3	1.0GB
/dev/vg01/home	/home	ext3	between 10GB and 40GB

Update: 2004-05-22
I've repartitioned my desktop according to the above scheme and it works well. The only problem I had was that I didn't have enough room to build a 2.6 kernel with the options I needed (none of the Debian kernel packages would work because I needed the CONFIG_IDE_STROKE option set). I was able to mount my old /home LV and use the extra space there to build the kernel.

Next time I'll make my root partition about 50 - 100 MB bigger, just to have more room to work with in case I lose my volume group or something. I don't want to use much more than that because I don't see the need for something like a 500 MB root partition with this setup.

posted at: 10:06 | path: /computers/linux | permanent link to this entry

Sat, 17 Apr 2004

Yet Another FTP Client
I'll admit it: I'm a commandline junkie. I cut my teeth on an Apple II+ (literally: I started messing with computers at age 3), so to me a GUI has always seemed foreign: nice eye candy, but not the real user interface. I hate being tied to the window system to do my work, so most of the applications and utilities I use are text-based. It bugs me that I have to use OpenOffice to do real word processing and Mozilla Firefox to browse the web (for you fellow CLI addicts, I do use w3m and lynx fairly often, but most sites these days pretty much require a graphical browser to be useful).

I also get frustrated when I can't find a text-based or commandline program to accomplish a task. For a long time, I've been looking for a text-based sftp client that supports command history and tab-completion. Today, I finally found one: yafc (Yet Another FTP Client). I could tell you all about this very cool app, but instead I'll just shamelessly steal the list of features from the project's website:

Need I say more? Download it and try it out. For those enlightened enough to use Debian, just 'apt-get install yafc', and you're set. The rest of you will need to hunt for an RPM or build yafc from source.

posted at: 21:26 | path: /computers/linux/apps | permanent link to this entry

Wed, 17 Mar 2004

Debian Advocacy
Lately (due to bad experiences with Red Hat boxes), I've been trying to find a page that clearly states the major reasons for choosing Debian over another Linux distro. The best I've found so far is Manoj Srivastava's "Why Linux? Why Debian?". If you're curious about switching to Debian, or want to persuade someone else to make the switch, you should read this.

posted at: 21:14 | path: /computers/linux/debian | permanent link to this entry