Monthly Archives: February 2011

wrapper script for disc_id

I wrote a little wrapper script for disc_id tonight, available here. disc_id is a little binary that ships with libdvdread, or at least, it used to in older versions.

I use disc_id to give me a unique 32-character string of a DVD, so I have an identifier to track them by in my database of DVDs.

I don’t know if it’s just me or not, but my DVD drives have issues trying to poll the devices. Once I insert a disc, it will take a few seconds for it to register completely so I can access it. However, binaries that access it will think it’s ready to respond sooner than it is able, and will die unexpectedly. So what I needed was a way to get the disc id and not worry about whether or not the drive has finished registering or not.

I just call my little script dvd_id and it is simply a small wrapper that checks the exit code of the disc_id binary. If it doesn’t work the first time, it sleeps for one second and tries again, then repeats the process until it gets a successful exit code of zero.

That’s it. Pretty simple, but like all little scripts, you really tend to depend on them.
#!/bin/bash
EXIT_CODE=1
DEVICE=$1
if [[ -z $DEVICE ]]; then
DEVICE=/dev/dvd
fi

if [[ ! -b $DEVICE ]]; then
echo "Device $DEVICE doesn't exist" >&2
exit 1
fi

while [[ $EXIT_CODE != 0 ]]; do
/usr/local/bin/disc_id $DEVICE 2> /dev/null
EXIT_CODE=$?

if [[ $EXIT_CODE != 0 ]]; then
sleep 1
fi
done

Leave a comment

Filed under bend / dvd2mkv, Gentoo, Multimedia, Programming

changing directions

I’m starting to remember why I don’t like moving. It takes me a long time to settle down into new routines. Small things that I don’t think about, like, “where do I keep my extra Wii controllers” suddenly become an issue. And there’s lots of little things like that.

Up until this week my strategy of dealing with post-moving hassles has been simple: ignore them. I’ve been doing great at that, and I’ve gone through one and a half seasons of Dr. Who on Netflix in no time flat.

Something must have stabilized recently, though, because I just barely started getting things organized at home again. On Sunday and Monday I setup my HTPC hardware in the new apartment, so I can watch my collection of shows. I’ve been without that for over a month, and that’s something I usually use every day. That’s how far gone I’ve been from getting things in order.

I think I’ve been a little shell-shocked from everything that landed on me at once: moving, the hospital stay, changing jobs and a new semester at school. My approaches at dealing with stress haven’t changed much during the years. I typically cut off activity and interest in most everything, and revert to just taking care of the basics such as putting on deodorant and having enough cereal in the house. It’s kind of like what someone would experience when going through a depression, but I use it as a bit of a cocoon.

As a result, a lot of responsibilities or commitments really suffer. I’m not a fan of that, but when I have too much going on, my defense mechanism is to just shut down and ignore it all. It actually beats the alternative of berating myself for not being able to meet a lot of demands.

Like I said though, I’m starting to get out of that a bit. I’ve lived in my apartment long enough now that I know where I want my computers to go, where to put my Wii controllers, and I’ve found enough new varieties of cereal that I’m willing to venture out a bit more and strap some more stuff on my back. That, and the fact that I have a midterm this week already kind of shell-shocked me back into the life of daily responsibility.

So, nothing really to report here, other than, if you’re waiting on me to get to something … I’m actually starting to get around to them now. Whatever that means. I don’t think many people have expectations of me anyway, other than putting on deodorant. Even then, I’m not so sure. Maybe they do. Who knows.

Leave a comment

Filed under Uncategorized