Daniel T Lavelle

Unplanned Happiness

Perl bliss
Git rollback of local Perl modules
Quick fix for sound with Aspire One 722
Enable smooth fonts in Linux
Openbox
Conky

This section will eventually hold snippets of code or configuration files for the most useful applications, languages, etc.

Perl bliss

In the lab, I used a mixture of Mac OSX and linux machines. When working in a Mac OSX environment with MacPorts, one will inevitably install multiple versions of Perl that are dependencies for installation of different ports. Don't get me wrong, I really like MacPorts, but it can be frustrating to remember what version of Perl (usr/bin; /usr/local/bin/; /opt/local/bin; etc.) contains your Perl module of interest. Likewise, it is often hard to keep up with the latest version of Perl on an older Mac. Update: It is even hard to keep up to date when using linux since most linux distributions package older versions of Perl. This is where perlbrew steps in and allows almost painless management of your local Perl version. To install:

curl -L http://xrl.us/perlbrewinstall | bash

perlbrew then installs itself to "~/perl5/perlbrew/bin". perlbrew will provide what to add to your .bashrc, which will be something like the following:

source /YourHomeDirectory/YourUserID/perl5/perlbrew/etc/bashrc

To install the latest Perl 5.16.0 locally:

perlbrew install perl-5.16.0 -Dusethreads
perlbrew list
perlbrew switch perl-5.16.0
perl -v

Installing large packages like Catalyst through CPAN or CPANPlus often requires some user interaction. Installing from source can almost become painless when using cpanminus. cpanm will install module dependencies without interaction. There are multiple ways to install, but ironically, the best way may be using CPAN (especially if you are using perlbrew):

perl -MCPAN -e 'shell'
install App::cpanminus

To install large bundles ( and walk away ) simply type in a normal shell:

cpanm Catalyst::Runtime
cpanm Catalyst::Devel

Or, if you already have a Perl project that you are working on or maintaining within a directory, then you can use cpanminus to install most if not all of your dependencies. This can be incredibly useful after installing a new version of Perl:

cd directory/Perl_project
cpanm --installdeps .

If you are new to Perl and not already an Emacs user, you can check out Padre (Perl Application Development and Refactoring Environment), the Perl IDE written in Perl. Although I have not used it, Padre seems to offer decent context relevant help and a REPL within the text editor that new Perl users should find especially appealing. If you follow the above instructions for configuring a recent local Perl using perlbrew, then the installation and running of Padre is as simple as the following:

cpanm Padre
padre

To upgrade to the latest release of all locally installed Perl modules, first install App::cpanoutdated:

cpanm App::cpanoutdated

To view what has changed on your outdated Perl modules, you need to install one Perl application and type the following exactly using "backticks":

cpanm App::cpanlistchanges
cpan-listchanges `cpan-outdated -p`

To update all your local Perl modules, you now only need one line. Painless. Enjoy!

cpan-outdated | cpanm

Git rollback of local Perl modules

Although, the ability to keep an updated version of Perl with upgraded modules using cpanminus is wonderful, it can be risky to develop on a machine that cannot be easily reverted to the last working state. When an application is working, the last thing you want to have happen is an update to your Perl modules that breaks your application. Git can help. In fact, by using the magic of git with the ease of cpanminus, Perl can be a wonderful development environment that can be continuously updated.

Once you have a working fresh install of Perl with all your required modules installed as above, then you can install a git repository within the local Perl installation:

cd perl5/perlbrew/perls/perl-5.16.0/
git init
git add .
git commit -a -m "Initial working Perl 5.16.0 installation"

As recommended by the Effective Perler, it is probably a good idea to set aside a known working branch marked pristine and then switch back to master:

git checkout -b pristine
git checkout master

Before committing a new set of updated Perl modules that may break your working Catalyst or Perl project you can checkout a testing branch, install the updated modules, and test to see if your Perl project is still functioning before merging the updated modules to your master repository:

git checkout -b testing
cpan-outdated | cpanm

Do tests to confirm your Perl project still works!

git add .
git commit -a -m "Perl modules updated on month-day-year that passed testing for projects x, y, and z."
git checkout master
git merge testing

Quick fix for sound with Aspire One 722

The only aspect of the Acer Aspire One 722 that did not work out of the box in Lubuntu 11.10 was the audio. I cannot test this, but it appears that the default sound is assigned to the HDMI port. Not a bad default for playing movies on an external HDMI monitor or projector. There are many solutions posted on the Internet for changing the default sound output from HDMI to the speakers and/or the headphone jack on the Aspire One 722. I did not find any solution quite as easy as the one provided below. It does not involve changing system-wide defaults. Include a ".asoundrc" file in your home directory to switch the defaults. It has been tested with Lubuntu 11.10 and now Lubuntu 12.04 with Linux kernels 3.0 and 3.2, respectively. Add the following to your .asoundrc file or create the file in your home directory if it is not already present:

defaults.ctl.card 1
defaults.pcm.card 1
defaults.rawmidi.card 1
defaults.hwdep.card 1
defaults.timer.card 1

Enable smooth fonts in Linux

I love smooth, sharp fonts when I am using emacs, a terminal, or even a browser. I do not know how people deal with monitors set to the wrong resolution or display fonts set to fuzzy defaults. Unfortunately for Linux users and especially those of us who do not use KDE or Gnome, the location of where to attempt to change the font rendering mostly remains hidden from view. After a bit searching and reading, I found a great reference at the Arch Linux Wiki. There, I learned that most of my font woes can be addressed by editing one file, .fonts.conf, in my home directory:

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
  <dir>~/.fonts</dir>
  <match target="font">
    <edit mode="assign" name="antialias">
      <bool>true</bool>
    </edit>
    <edit mode="assign" name="hinting">
      <bool>true</bool>
    </edit>
    <edit mode="assign" name="autohint">
      <bool>false</bool>
    </edit>
    <edit mode="assign" name="hintstyle">
      <const>hintfull</const>
    </edit>
    <!-- Ignore any embedded bitmaps in TTF, etc (Microsoft's Calibri and others from Office 07/Vista) -->
    <edit mode="assign" name="embeddedbitmap">
      <bool>false</bool>
    </edit>
    <edit mode="assign" name="lcdfilter">
      <const>lcddefault</const>
    </edit>
    <edit mode="assign" name="rgba">
      <const>rgb</const>
    </edit>
  </match>
</fontconfig>

Openbox

I run a very plain Openbox desktop — yes I have a black screen with the only distraction being the small Conky information bar on the bottom. I tried a few panel apps awhile ago, but I found that I rarely used them. I have become accustomed to hitting Ctl-Alt-Left or Right arrow to move between desktops and Alt-Tab to move between applications. An excellent Openbox setup guide can be found at urukrama's weblog. I use a slightly modified version of PaperDelusion (I changed the text color from light blue to light green) as my Openbox theme with the original version available at Box-Look.org. I also made an amber version that I rarely use. Ironically, I always type on an amber terminal. Openbox themes can be easily changed with obconf.

Here is my autostart.sh for my Openbox session:

# Run the system-wide support stuff
. $GLOBALAUTOSTART

# Programs to launch at startup
/usr/bin/xsetroot -solid Black

# Programs that will run after Openbox has started
mrxvt &
(sleep 5 && conky) &

Conky

I slightly modified the Conky configuration file supplied with the elegant Dyne theme for Openbox. Here is the .conkyrc file that I use for dual cpu/core computers with 1280 pixel wide screens. This file can easily be adjusted to accommodate the pixel resolution of your monitor.

## Conky config modified from Dyne openbox theme
## http://www.box-look.org/content/show.php/Dyne?content=62000

#avoid flicker
double_buffer yes

#own window to run simultanious 2 or more conkys
own_window  yes
own_window_transparent no
own_window_type normal
own_window_hints undecorate,sticky,skip_taskbar,skip_pager

#borders
draw_borders no
#border_margin 1 #deprecated
window.border_inner_margin

#shades
draw_shades no

#position
gap_x 0
gap_y 4
#alignment top_left
alignment bottom_left

#behaviour
update_interval 1

#colour
default_color  9f907d

#default_shade_color 000000
own_window_colour 3d352a

#font
use_xft yes
xftfont bauhaus:pixelsize=11

#to prevent window from moving
use_spacer left
minimum_size 1280 0

TEXT
${time %d %B} ${color D7D3C5}${time %I:%M%p} | ${color}Cpu1: ${color #D7D3C5}${freq_g 1} ${color #D7D3C5}${cpu 1}%  ${color}Cpu2: ${color #D7D3C5}${freq_g 2} ${color #D7D3C5}${cpu 2}%  ${color D7D3C5} ${acpitemp}${color}C ${color D7D3C5}| ${color }Mem: ${color D7D3C5}$mem/$memmax $memperc% ${color} ${color D7D3C5} | ${color }Swap: ${color D7D3C5} $swapperc% | ${color} Home: ${color D7D3C5}${fs_free /home} - ${fs_free_perc /home}% | ${color}Bat: ${color D7D3C5}${battery_time BAT1} - ${color D7D3C5}${battery BAT1} | ${color} L: ${color D7D3C5}${addr eth0} ${color}W: ${color D7D3C5}${addr wlan0} ${color D7D3C5} ${upspeed wlan0} / ${color D7D3C5} ${downspeed wlan0} ${color} |