I used to believe that my computer was mine, and no program had any authority to do anything without my consent. (This can probably be traced back to my days on Slashdot, a decade ago; if I didn't get the opinion from there, they certainly reinforced it.) I believed I was sufficiently smart to manage my own software, without everyone's updater constantly nagging me to do so. I especially didn't want the updater to do it on its own; this often lead to problems, especially when Firefox got updated behind the scenes while I was using it. However, I liked automatic security updates on Linux, so I got rather used to restarting Firefox when links mysteriously failed to be followed, or menus and tabs couldn't be opened—these being the days before the "Firefox has been updated and needs to be restarted" notification.
Then, everything changed.
Friday, March 4, 2011
Wednesday, March 2, 2011
Quick tip: extending the man search path without $MANPATH
If you've ever tried to add a directory to man's search path, you've undoubtedly noticed that the
The documentation for
MANPATH environment variable replaces rather than extends man's built-in search path. Today, I rediscovered a clever little setup on a machine at work.- Copy /etc/man.config to somewhere in your home dir. Mine seems to be at ~/.config/man/man.config for optimal redundant redundancy. (I will say that keeping the "man.config" name of the file makes vim highlight it without additional fuss.)
- Add your desired
MANPATHlines to this file at whatever position you wish. Don't forget to curse the lack of an include mechanism at this point, which prevents you from automatically getting changes to /etc/man.config. Cheer up, because there probably won't be any. - Add an alias to your shell. For bash, you would put something like
alias man='man -C ~/.config/man/man.config'(which obviously includes the name of the file chosen in step 1) into~/.bashrc. Remember tosource ~/.bashrcto make it take effect in the current session.
man, your personal manpages will be searched as well.The documentation for
man on the system in question claims that it will use $PATH to guess at additional man page locations, but this does not actually work for me. Having a command in ~/.install/bin does not allow man to find the manpage in ~/.install/share/man.
Monday, February 28, 2011
Variable scope, require, and use
I ran into some interesting problems in Perl, which invoked more learning around the require/use mechanisms and how constants are interpreted. In this post, I'll lay out some general terms about variable scoping, such as lexical scope, dynamic scope, the differences between them, and how they all interact in Perl. And then I'll cover require and use with that foundation in place.
If you've been wondering about lexicals or closures, this is your post. I've tried to lay things out more or less from basic principles, despite the verbosity of the approach, because this has taken me years to understand. I started programming with Perl in 2000 and still learned a bit more about it today. Yes, it's 2011 now. Hopefully, you can read this and get it in less time.
If you've been wondering about lexicals or closures, this is your post. I've tried to lay things out more or less from basic principles, despite the verbosity of the approach, because this has taken me years to understand. I started programming with Perl in 2000 and still learned a bit more about it today. Yes, it's 2011 now. Hopefully, you can read this and get it in less time.
Saturday, February 19, 2011
Changing a Tablet's Active Area in Ubuntu Lucid
The following information applies to Ubuntu 10.04 LTS, Lucid Lynx, with xserver-xorg-input-wacom installed to provide xsetwacom. This is about fine-tuning your tablet; if your tablet isn't working at all, you probably need bug #568064.
There used to be a wacomcpl program to graphically configure a Wacom tablet; this quit working with changes to the upstream project and/or the Tcl dependency, so it hasn't been working for me for some time. Before it quit working, I set up a script to call the xsetwacom command-line program with the desired results, so the loss didn't affect me. Mainly, I had adjusted the active area so that tracing a circle on the tablet would result in a circular shape on the monitor.
With a new monitor came a new need to reconfigure the tablet, without using wacomcpl this time. I ultimately created a couple of formulas to make a strip of the tablet inactive. Without further ado, these are the formulas:
$aspect is the aspect ratio of the monitor, obtained by dividing where you write the colon. For example, 16:10 = 16/10 = 1.6. Alternatively, you can divide the width in pixels by the height, so a 2560x1600 display has an aspect of 2560/1600 = 1.6. (If you have square pixels, which practically everyone does because they're so convenient.) The monitor being narrower or wider refers to whether the monitor's aspect is lower or higher than the tablet's, respectively. You can calculate the tablet's aspect by dividing $w by $h; obtaining them is the subject of the next section.
$w and $h come from the actual tablet, which you can find easily enough. In these commands, $T represents your tablet's name, which you can get from `xsetwacom list dev`. In my case, there's a tool name attached, so it prints "Wacom Bamboo 4x5 Pen STYLUS" (among other things) but only the "Wacom Bamboo 4x5 Pen" portion is the actual device name. The first command simply resets the coordinates to cover the full tablet, just in case they have been changed.
$w is BottomX-TopX, and $h is BottomY-TopY.
Armed with this information, you should now choose the correct formula from above, and substitute all the numbers. In my case, the top coordinates are both 0, so BottomX=$w=14720, and BottomY=$h=9200.
My old monitor was much narrower (at 1280/1024=1.25) than the tablet (at 14720/9200=1.6), so I used the first formula, thus:
And to set that value:
xsetwacom set "$T" TopX 3220
My new monitor runs at 1920x1080, which yields 1.7778 for aspect. The monitor is wider than the tablet, so now I need the second formula:
Now that the offset is known, it's a simple matter to set up. I just add it to the original TopY value (zero for me, so no different) and set that as the new TopY:
xsetwacom set "$T" TopY 920
Altering TopX or TopY means that the inactive portion of the tablet runs down the left or across the top. I don't really care where the dead zone ends up, so I chose the method that results in the fewest calculations needed. You could just as easily set BottomX to BottomX-$x_offset to move the dead zone to the right side of the tablet, or adjust both TopX and BottomX by half of the $x_offset to keep the active area centered.
There used to be a wacomcpl program to graphically configure a Wacom tablet; this quit working with changes to the upstream project and/or the Tcl dependency, so it hasn't been working for me for some time. Before it quit working, I set up a script to call the xsetwacom command-line program with the desired results, so the loss didn't affect me. Mainly, I had adjusted the active area so that tracing a circle on the tablet would result in a circular shape on the monitor.
With a new monitor came a new need to reconfigure the tablet, without using wacomcpl this time. I ultimately created a couple of formulas to make a strip of the tablet inactive. Without further ado, these are the formulas:
$x_offset = $w - ($h * $aspect) # narrower monitor
$y_offset = $h - ($w / $aspect) # wider monitor
$aspect is the aspect ratio of the monitor, obtained by dividing where you write the colon. For example, 16:10 = 16/10 = 1.6. Alternatively, you can divide the width in pixels by the height, so a 2560x1600 display has an aspect of 2560/1600 = 1.6. (If you have square pixels, which practically everyone does because they're so convenient.) The monitor being narrower or wider refers to whether the monitor's aspect is lower or higher than the tablet's, respectively. You can calculate the tablet's aspect by dividing $w by $h; obtaining them is the subject of the next section.
$w and $h come from the actual tablet, which you can find easily enough. In these commands, $T represents your tablet's name, which you can get from `xsetwacom list dev`. In my case, there's a tool name attached, so it prints "Wacom Bamboo 4x5 Pen STYLUS" (among other things) but only the "Wacom Bamboo 4x5 Pen" portion is the actual device name. The first command simply resets the coordinates to cover the full tablet, just in case they have been changed.
xsetwacom set "$T" xyDefault 1
xsetwacom get "$T" BottomX
xsetwacom get "$T" TopX
xsetwacom get "$T" BottomY
xsetwacom get "$T" TopY$w is BottomX-TopX, and $h is BottomY-TopY.
Armed with this information, you should now choose the correct formula from above, and substitute all the numbers. In my case, the top coordinates are both 0, so BottomX=$w=14720, and BottomY=$h=9200.
My old monitor was much narrower (at 1280/1024=1.25) than the tablet (at 14720/9200=1.6), so I used the first formula, thus:
$x_offset = 14720 - (9400*1.25) = 3220
And to set that value:
xsetwacom set "$T" TopX 3220
My new monitor runs at 1920x1080, which yields 1.7778 for aspect. The monitor is wider than the tablet, so now I need the second formula:
$y_offset = 9200 - (14720/1.7778) = 920
Now that the offset is known, it's a simple matter to set up. I just add it to the original TopY value (zero for me, so no different) and set that as the new TopY:
xsetwacom set "$T" TopY 920
Altering TopX or TopY means that the inactive portion of the tablet runs down the left or across the top. I don't really care where the dead zone ends up, so I chose the method that results in the fewest calculations needed. You could just as easily set BottomX to BottomX-$x_offset to move the dead zone to the right side of the tablet, or adjust both TopX and BottomX by half of the $x_offset to keep the active area centered.
Wednesday, December 1, 2010
Customizing Everything I Touch: The Lucid Login Screen
This post is purposefully dense, due to my lack of time/typing budget. If you need clarification, please leave a comment.
Directions (shortcut):
you$ sudo -u gdm dbus-launch gnome-appearance-properties -p background
Directions (original):
you$ sudo -u gdm dbus-launch bash
The changes will take effect once all users log out (or possibly, the user on :0.)
Commentary:
The directions above copy the wallpaper to /var/lib/gdm (which is the home directory of the gdm user) to protect it against corruption. If you don't care, you can run the single command `sudo -u gdm dbus-launch gconf-editor` and set picture_filename to any file on the system.
In either case, dbus-launch is necessary so that there's a session bus running as the gdm user, which gconf needs to successfully run. Otherwise, AFAICT, it tries to connect to your own session bus, which the gdm user isn't allowed to do.
This edits the keys in /var/lib/gdm/.gconf, a config source set by /var/lib/gdm/gconf.path, which is wedged into the regular paths by inclusion from /etc/gconf/2/path.
Validity:
Tested on Ubuntu 10.04 LTS, Lucid Lynx; most likely, this applies to 9.10/Karmic and later Gnome 2.x-based Ubuntu releases. (IIRC, Karmic is when the new, non-themable GDM landed in Ubuntu.) The general philosophy probably applies to other contemporary Gnome environments, but the details may differ as there's a lot of Debian-ness in the GConf paths.
Directions (shortcut):
you$ sudo -u gdm dbus-launch gnome-appearance-properties -p background
Directions (original):
you$ sudo -u gdm dbus-launch bash
gdm$ cp wallpaper.png /var/lib/gdm
gdm$ gconf-editor
(set /desktop/gnome/background/picture_filename to /var/lib/gdm/wallpaper.png)
gdm$ exit
The changes will take effect once all users log out (or possibly, the user on :0.)
Commentary:
The directions above copy the wallpaper to /var/lib/gdm (which is the home directory of the gdm user) to protect it against corruption. If you don't care, you can run the single command `sudo -u gdm dbus-launch gconf-editor` and set picture_filename to any file on the system.
In either case, dbus-launch is necessary so that there's a session bus running as the gdm user, which gconf needs to successfully run. Otherwise, AFAICT, it tries to connect to your own session bus, which the gdm user isn't allowed to do.
This edits the keys in /var/lib/gdm/.gconf, a config source set by /var/lib/gdm/gconf.path, which is wedged into the regular paths by inclusion from /etc/gconf/2/path.
Validity:
Tested on Ubuntu 10.04 LTS, Lucid Lynx; most likely, this applies to 9.10/Karmic and later Gnome 2.x-based Ubuntu releases. (IIRC, Karmic is when the new, non-themable GDM landed in Ubuntu.) The general philosophy probably applies to other contemporary Gnome environments, but the details may differ as there's a lot of Debian-ness in the GConf paths.
Thursday, October 7, 2010
Autostart in Gnome 2: the missing docs [Updated 10/10]
I've been trying to understand the autostart mechanism in Gnome 2 for a small program I'm working on. This may continue to be a supported system in gnome-3, since it seems to be standardized by freedesktop.org and not the Gnome "Let's just rewrite around our bugs and drop features" team.
Without further ado or bitterness, here's a brief but technical dive into the modern autostart system on Gnome 2, as observed on a Lucid Lynx system (originally installed as Intrepid Ibex, I believe.) [Updated: autostart itself is also a freedesktop standard.]
Without further ado or bitterness, here's a brief but technical dive into the modern autostart system on Gnome 2, as observed on a Lucid Lynx system (originally installed as Intrepid Ibex, I believe.) [Updated: autostart itself is also a freedesktop standard.]
Sunday, October 3, 2010
Groupthink
I don't fit in; I never have. Some of it is by my choice, but in the tech communities that I've found, I still don't fit in, and I've often wondered why. It seems the short answer is right there in my blog description: "Frequently contrarian and occasionally cynical."
Subscribe to:
Posts (Atom)