changing konsole schema using dcop

In an effort to combat lameness, I’m not going to make a shitty inaugural post about nothing. I’ll get right to the point and make a useful post.

If you’ve ever found yourself sitting in front of a dozen konsoles to as many hosts, particularly if some of those are to production machines, you might also have found yourself about to type something Unfun at that production prompt. I decided I needed some visual cue to know that I’m on a production machine.

Enter my elite script ‘dcopssh.sh’ which wraps ssh via an alias inside of a couple of dcop calls.
—–

#!/bin/bash
#
# use this with an alias along the lines of:
# alias ssh='/home/rwoodrum/bin/dcopssh.sh'
#
if [ "$KONSOLE_DCOP_SESSION" ] && [[ $@ =~ "wad" ]]
then
   dcop ${KONSOLE_DCOP_SESSION} setSchema "scary_production.schema"
   ssh $@
   dcop ${KONSOLE_DCOP_SESSION} setSchema "normal_unscary.schema"
else
   ssh $@
fi

—–
The super fool-proof way that this works, is that I’m lucky enough to have a hostname convention in my production infrastructure (as opposed to a half-dozen test environments), and I can cue off of the hostname. In my case, I know that the string “wad” is going to appear in production hosts… but clearly you can make this as smart or as dumb (such as in my case) as you want.

Now when I ssh into my production machines from my KDE desktop, my konsoles turn an eerie set of colors as a visual cue that I’m on a machine in our production infrastructure and that I shouldn’t do something stupid. When I log out of the host in question, the schema reverts to the original. Yay, dcopssh!

Comments

Leave a Reply