about content dotfiles desktops scripts stats recent posts


pbrisbin dot com at 8080


Welcome to pbrisbin dot com at 8080. You'll find it's mostly [GNU/]Linux-related geekery here and some of the information presented is specific to the [amazing] distribution known as Arch Linux. Some of my favorite topics are the XMonad window manager, Bash scripting (or just general command-line adventures), and the great email client Mutt.

Please don't hesitate to contact me; simply send emails to anything at pbrisbin dot com.

Enjoy the site.

Current Desktop

Xmonad is a type of tiling window manager. It makes me happy. If you've never used a tiling window manager, the idea is simple: automatically resize any open windows to fill the whole monitor with no gaps and no overlap. Usually you get a bunch of virtual workspaces to spread out your windows by category too. And there's always a floating layer available if you want to pop any windows out of the tile and move/resize them freely (or have them start that way by default). It's a very efficient way to work with your computer as you waste no screen space, you can quickly navigate to or rearrange your windows, and you can do all of it without ever touching the mouse.

Desktop Shot

About Arch

If you haven't noticed, my desktop runs on Arch linux. Arch is an amazing DIY distro that gives the user the barest of bare installs; from there, you can build your system, piece by piece. There is no hand-holding, and the user is expected to install, maintain, and configure his entire system on his own. Through appropriate use of the amazing Arch wiki, forums, and IRC, this isn't so bad - it simply takes reading, and time. The benefit being not only can you make it exactly what you want, but you'll learn more than you could imagine about the inner workings of your system. This transparency and required effort can lead to both fulfillment and frustration; this is a feature, not a bug.

If you want to try a distro that expects a lot from its users while still offering a great package manager and simple transparent tools for maintaining /your/ system, please try Arch. Be sure to read the Beginners guide before installing, and do some research (manpage, wiki, forum, google) before asking questions - Though most Archers are extremely friendly and willing to help, showing that you've done some research before asking the same often answered question will go a long way in earning the respect of the group; and, at least in the beginning, I'd bet you find your question's already been asked and answered somewhere.


AUR Packages

Aurget A simple pacman-like interface to the AUR

Raw Script: http://pbrisbin.com:8080/bin/aurget

Dedicated Page: http://pbrisbin.com:8080/pages/aurget.html

AUR Package: http://aur.archlinux.org/packages.php?ID=31933

Downgrade Bash script for downgrading one or more packages to a version in your cache or the A.R.M.

Raw Script: http://pbrisbin.com:8080/bin/downgrade

Dedicated Page: http://pbrisbin.com:8080/pages/downgrade.html

AUR Package: http://aur.archlinux.org/packages.php?ID=31937


Recent Posts

Content - I've done a bit of maintenance on the ol' site the past two days. Nothing really visible from a readers perspective, but a lot of little things to make my life easier.

First and foremost, I've added a content page. This basically lists all 'articles' on the site in order of most recently modified. It pulls title, description, and link through a bash script and formats the html page which you can see here.

This content page will be auto-updated along with my RSS feed whenever I add or modify a post on the site. Eventually, I'd like to rework how my site's content, the Content page, and this Recent posts listing all interact... but I haven't decided on the best approach for that yet.

While writing this content page script, I noticed I was doing alot of the same little tasks I do in all my other site scripts (writing a header, grepping for a Title, etc); so, with reuse of code as the main goal, I decided to rewrite all my site scripts.

I made one consolidated scriptutils file with functions and constants to be sourced by all my little site management scripts themselves. This is also part of an overall effort to get this site into some sort of html compliance (i.e. my write_page_header() function will need to be modified, so I'd like to only do it once). Anyway, if you'd like to see how that turned out, you can find my siteutils file here.

---

Completion - I wrote my first custom bash tab completion function today; turns out, it wasn't really all that complicated. I wrote a bit about how it all works by way of an overly commented example function for a fictitious burning script. Details here.

---

SubShell Hell - I just got bit by this twice so I feel like I should post about it. Anyone who scripts a fair amount has to have been caught in SubShell Hell at one point or another.

Take the following script:

    lines=0

    ls / | while read output; do

      lines=$((lines+1))

    done

    echo "there were $lines lines"
  

It will output 0. Why? becuase of the '|'. The pipe to read puts the while loop inside a subshell, only in this subshell is lines incremented. Once you hit 'done' the variable lines is destroyed and you get back it's original copy which equals 0.

Now, this is bash 101; but the same principle is a bit more subtle in something like this:

    somethingbroke=true

    ls / | while read output; do

      if $somethingbroke; then
        echo 'error!'
        exit 1
      fi

    done

    echo 'can you see me?'
  

Here, something broke and I called exit, but the script carries on. That's because exit is called in the subshell, therefore it only exits the subshell. Not good if you've got something complicated that shouldn't run if something breaks upstream.

So, how to fix?

  # one way
  for output in $(ls /); do
    ...
  done

  # i prefer this one
  while read output; do
    ...
  done < <(ls /)
  

So that's it, no more SubShell Hell :). Note: you should also look into IFS and read -r as these will affect how while read loops behave.

---

Automounting - A dead simple, one-tool approach to automagically mounting usb flash drives under linux. Uses a udev rules file to mkdir and mount in /media. Also included: an automount on/off script that moves the file around so you can turn this automounting on or off easily. Details here.

---

Backups - Everyone should be backing up important data, of course. In linux with tools like cron and rsync is way to easy to not be doing this. I did a little writeup on my solution; it's not perfect, but it works. It's probably not a drag 'n drop script for anyone else but it could be adapted with some effort. Check out the details here.

---

Euler problems - So I started the Euler problems in haskell. Such a mathy languange seems perfectly suited for the task. It's a great way to learn a programming language. My working euler file as well as a link to the project can be found here.

---

RSS - So, I've added an RSS feed to the site. I tried to hold off, but people seem to find it useful. Details are here or subscribe here.

I'm wicked lazy, so I may become noticeably slower adding entries here as I add content; I will, on the other hand, be updating the RSS feed automatically each time a new page is created; so this will be much more up to date.

Not an RSS user, but want to stay up to date? Well, the feed itself loads as a decent looking page in firefox, or you can always view the file listing at http://pbrisbin.com:8080/pages/ directly to see all the individual pages.

---

User input - Just wanted to quickly document a bash trick I just learned. Say you need to validate that the user entered only an integer.

Some script writers are tempted to do this, which works just fine:

  if echo $input | grep [^0-9] &>/dev/null; then
    echo bad input
  fi
  

This would be a slightly cleaner version:

  if echo $input | grep -q [^0-9]; then
    echo bad input
  fi
  

But I recently learned you can take care of this right in bash!

  if [ -n "${input//[0-9]/}" ]; then
    echo bad input
  fi
  

Just shaved .003 s off that sucker!

---

Controlling MPlayer - Simple, bindable commands to control mplayer via a FIFO. You just need to adjust (or create) ~/.mplayer/config to tell mplayer to accept commands when echo'd into a FIFO.

  # the fifo has to exist, so create it with the
  # the following command

  mkfifo ~/.mplayer_fifo

  # then edit mplayer's config with whatever
  # editor you use

  vim ~/.mplayer/config

  # adding this line will tell mplayer to listen for
  # commands from the fifo you created

  input = file=/home/username/.mplayer_fifo

  # then play something

  mplayer ./some_movie.mpg
  

Now you can control mplayer simply by echoing valid commands into that fifo.

  echo pause > ~/.mplayer_fifo
  

You could also set up a quick bash script to handle this:

  #!/bin/bash
  #
  # mpplayer - control mplayer by echoing into a fifo
  #
  ###

  MPLAYER_FIFO="$HOME/.mplayer_fifo"

  echo $* > $MPLAYER_FIFO
  

Now you can bind whatever keys you want to control mplayer to either the echo commands directly or your wrapper script. Here's a snippet from my xmonad.hs to get you started:

  , ("M-<XF86AudioPlay>"     , spawn "mpplayer pause"     ) -- play/pause mplayer
  , ("M-<XF86AudioStop>"     , spawn "mpplayer stop"      ) -- stop mplayer
  , ("M-<XF86AudioPrev>"     , spawn "mpplayer seek -10"  ) -- seek back 10 seconds
  , ("M-<XF86AudioNext>"     , spawn "mpplayer seek 10"   ) -- seek forward 10 seconds
  

Now I just Alt+Play to play/pause mplayer.

---

Multi-screening - No, not multi head or multi monitor. I mean using GNU/screen for different purposes in different situations as simply and easily as possible. Type screen, get a default setup... type irssi, get irssi in a screen window (create or re-attach)... same with rtorrent. Want to know how to set up it? Read the details here.

---

Bookmarks - I've come up with what I think is a nifty way to handle bookmarking. It's easy, intuitive, built of simple text files, and allows your bookmarks to be accessed from anywhere in any browser on any OS (if you're ok with them being "public"). Check out all the details here. Uzbl users only, sorry. UPDATED (now not just for uzbl users).

---

Coverart - I don't use it much as I'm typically an mpd + ncmpcpp guy, but I can see the benefit. I found a script on the arch forums by lolilolicon particularly useful as it gave conky an easy way to display album art while also providing automagical search / download features. I rewrote it into a general purpose script that starts with your ~/Music directory and ends up with a nice ~/.covers directory with symlinks from each picture to the appropriate ~/Music/.../album/cover.jpg location that's expected from most GUI players that display covers. Check out the extended info and a download link at coverart's own dedicated page.

---

Bashkell - Seeing as I've been head-down in my xmonad.hs so much lately, it makes sense that I'd be in a very functional mode of thinking. When I decided to give my handy downgrade script a rewrite, I really had no idea it would turn out the way it did. File this under "things I find interesting, but no one else will" I guess. Anyway, if you want to see an interesting application of very functional thinking in bash script form used to downgrade Arch linux packages... please, check it out here.

---

Uploads! - I get bored. It happens. So I wrote a little script that polls a particular folder under ~/Mail then uploads anything meeting certain criteria to my site and replies to the email with a link. It runs every 15 minutes. If you want to try it out, send an email with an attachment and a Subject of "UPLOAD" (no quotes) to pbrisbin@gmx.com (a garbage account). Within 15 minutes you /should/ get a response with a link to the attached file. Useless script is useless. Oh well. If you're interested, the script can be viewed here.

Note: I've since disabled the cron job due to lack of use (surprise!). Time wasted is time well spent :).

---

CLI Texting - Just a short script to pass an email message off as a text message, right from the commandline. This requires a little setup, but it's worth it. Read the details here.

---

Vim tweak - Best ~/.vimrc snippet ever. Define a function MapToggle, then bind keys to toggle options like hls, paste, or spell.

Not sure where I picked it up, but now I quickly turn on/off spell checking with F6 or turn on/off paste with F7. Best vimrc entry I ever added.

  " define the toggling function
  function MapToggle(key, opt)
    let cmd = ':set '.a:opt.'! \| set '.a:opt."?\<CR>"
    exec 'nnoremap '.a:key.' '.cmd
    exec 'inoremap '.a:key." \<C-O>".cmd
  endfunction
  command -nargs=+ MapToggle call MapToggle(<f-args>)

  " then set up whatever commands you want to toggle
  MapToggle <F6> spell
  MapToggle <F7> paste
  MapToggle <F8> hlsearch
  MapToggle <F9> wrap
  

It even displays a nicely formatted notification of the change in option.

For reference, my full vimrc can be found here

---

Goodsong - I showed some love to my handy script goodsong. Leveraging the power of an mpd/mpc combination one can catalog good songs as they pop up in the current playlist, then later play a random 'good song' or build a playlist of all good songs. Check out the details here

---

Multi-account email - A followup to my first mutt + offlineimap tutorial, here I document how I added my GMX IMAP email account into the mix. I rewrote some configs and came up with some new mutt tricks to make the usage of two IMAP accounts together as convenient and non-intrusive as possible. Read the details here.

---

Wifi-Pipe - I simplified the awesome tool wifi-select to output as an openbox pipe menu. If you use netcfg to manage wireless and openbox as your WM, this is a really slick way to connect to hot-spots on the fly. Details can be found here

---

Dvdcopy - I realized today that I haven't been getting the word out about my dvdcopy script enough. It's a bash script that copies a standard DVD9 to a standard DVD5 playable on any player. Works better and with less overhead than k9copy or whatever else is around. Moreover, it auto-calculates the video bitrate required to get the best possible quality copy while staying under the 4.3 GB size limit. Check out the page here.

---

Lightest DM ever - What do you use as your display manager? GDM, KDM, SliM? You don't need that bloat! startx works just fine.

And what if someone kills your X session? You're left logged in on tty1. Fear not, by adding just four lines to the bottom of ~/.bashrc, X is auto-magically started whenever you log into tty1. And if someone kills your X session, they see nothing but... username: ?.

  if [[ -z "$DISPLAY" ]] && [[ $(tty) = /dev/tty1 ]]; then
    startx
    logout
  fi
  

Simple huh?

---

Aurget deps ftw! - Finally, my handy-dandy Aurget script has some auto-dependency resolution. Now, by default Aurget will find any required deps not offered by pacman and add them to the list of targets to be installed (and in the proper order no less!). BE WARE -- this requires sourcing of an unviewed PKGBUILD to get the depends and makedepends arrays. This is a BLATANT RISK TO YOUR SYSTEM. Personally, I don't mind, but you may feel differently. Simply pass the -D option as mentioned in the --help to prevent this check. Check out Aurget's dedicated page here.

---

Uzbl - The browser that follows the Unix philosophy. A fast moving project spawned on the Arch forums, uzbl does one thing and does it well, browse webpages. Check out my Uzbl how-to to get set up to take this uber-lightweight browser for a spin. I haven't used firefox in months... just kidding, even the lead dev himself says you should keep your normal browser around as a backup. It's still fun to play with though.

---

Mutt, Gmail, Offlineimap - The best way to use gmail on linux I can find. In this How-to I'll walk you through setting up a local Maildir synced with gmail IMAP and accessed by Mutt. You'll look like a super l33t hax0r in all the screenshot threads. Take a look at Mutt + Gmail + Offlineimap for the step-by-step.

---

Xmonad status bars - Woot for xmonad giving me something to write about! In this short how-to I go through my method for setting up an xmonad status bar. Two dzen's to look like one, urgencyHooks and conky mpd and system stats. Check it out, Dzen Status Bar[s] in Xmonad. -- UPDATED

---

Xmonad IM layout - First in what might prove to be a series of How-to's, I go through setting up an IM-centric layout in xmonad. Maybe I'll write more, maybe not. For now, check out Xmonad's IM Layout for details on using that awesome module from xmonad-contrib. -- UPDATED

---

Conky patched! - I found recently that the new conky allows one to put comments in after TEXT, this also meant that I couldn't pipe hex colors (#909090) into dzen as any output after # was ignored. The intent was that \# would escape the character and allow its printing, but this didn't work. Well, someone submitted a patch to fix this behavior. Thank you wiredalex.

---

Scripts overhauled - I've been spending a lot of time in ~/.bin lately. I've tried to simplify a lot of my scripts, drop the wordy comments for a short -h message; take out the pretty color printing and just echo the important information. I'm really happy with my little utilities; everything can be done via CLI, and every CLI activity can be scripted. Check out what's available in the readme or head right to the scripts page.

---

Prompt bug squashed - I finally got fed up with rxvt mangling my two line prompt. The other night, I went on a google hunt, found the fix, and made a patch. If you think you might have this issue, check out the forum post.


pbrisbin dot com at 8080 - 2009