Search this site

Metadata

Articles

Projects

Presentations

mserv, it's neat.

In my quest to stop using xmms (it requires that whole.. mouse thing) I ran across a mp3 jukebox server called mserv [mserv.org].
It's pretty cool and can support just about anything I want it to since it uses external programs to play them. It uses a server protocol similar to that of Joe's Moonshot Jukebox. I don't have any oggs so his jukebox is mostly useless to me.
I quickly hacked together a script (well, it functions as several tools) to let me play songs more easily. It's called mq and you can see it here if you want. With it you can do things like: mpick Cake | mq to enqueue all tracks matching "Cake"
Put it in ~/bin/ and have it propogate its tools with symlinks by doing mq -setup. Look at the code to figure out what does what, it's fairly straight forward.

yes, even more ksh prompt fun...

So the next thing that bothered me about my prompt was the fact that sometimes I'd have some crazy long directory filling up 90% of the line - this was a bad thing. So I set out along with my companion, sed, and together we squashed this beast.

PS1='$(A=$?; [ $A -ne 0 ] && A="!!{$A}!! " || A=""; SPWD=$(/bin/pwd | /usr/bin/sed -Ee "s,(/usr)?$HOME,~,; sz(/[^/]+/).*(/.{20,})$z\1...\2z"); /bin/echo -n $HOST"("$SPWD") [!] ${A}${Z} " )'

[ -w "/" ] && Z="#" || Z=">"; export Z
PROMPT='$(A=$?; [ $A -ne 0 ] && A="!!{$A}!! " || A=""; SPWD=$(/bin/pwd | \
/usr/bin/sed -Ee "s,(/usr)?$HOME,~,; sz(/[^/]+/).*(/.{20,})\$z\1...\2z"); \
/bin/echo -n $HOST"("$SPWD") [!] ${A}${Z} " )'

case $TERM in
   aterm|xterm|dtterm)
      PROMPT=${PROMPT%)*}'; /bin/echo -n "^[]2;"$HOST"("$SPWD") [!] ${A}^G" 1>&2)'
      ;;
esac
PS1=$PROMPT
The part marked in bold is what actually shortens the path. This will take what was previously a terribly long prompt and shorten the directory... ie;
/usr/local/lib/perl5/site_perl/5.6.1/Curses/UI/Dialog
will become
/usr/.../5.6.1/Curses/UI/Dialog

Oh, and this new feature actually makes the overal content of $PS1 shorter by 3 characters! Instead of 257 characters, it's 254. This is due to a rewrite of part of the code - pwd and sed are only called one time now.

converting mbox to mh

I had a bit of mail in my old mbox files that I wanted to refile to mh, so here's the oneliner that does it.
cat main | \
perl -e '\
$x = 0; \
while (<>) { \
   if (m/^From /) { \
      $x++; \
      open(MAIL, "> $x"); \
   }; \
   print MAIL $_; \
}'
main is the name of the mbox. After doing this, I simply used the refile(1) command to drop them in my main mh folder. <3 perl.

nmh mail reader, v1.1

mailfilter (my new mailreader for nmh) got a fairly important upgrade today. I added in both screen support and better pgp handling.
Screen is supported if you want to use it, see SCREEN_POLICY in the script.
Mail starting with -----BEGIN PGP SIGNED MESSAGE----- will now be sent through pgp_verify_command much in the same way that multipart/signed (pgp signature attachment) mail is.

So that was how I spent 4 hours this morning (among other projects...)

nmh mail viewer

"version 1" of my mail viewer for mh is done. It currently supports any number of viewers including w3m, links, lynx, less, more, vi, emacs, joe, and others. It also will do pgp verification on mail that is signed with a signature attached (Although mail that is simply armored and begin with -----BEGIN PGP SIGNED MESSAGE----- is NOT supported, yet).

Anyhoo, it supports multipart mail and will display HTML email properly (aswell as html attachments). If you want to try it, click the link on the right.

mh fun, still.

I'm still awake from last night, yadda yadda yadda.
So I got leet with my vim stuff and wrote a keymap that automatically generates an attached pgp signature. I should note, however, that you'll have to run mime from whatnow or run mhbuild yourself, before you send out your email.
" MH comp header/body separator
let g:mhseparator="---------"

if bufname(1) == '/u9/psionic/Mail/draft'
set tw=72
map \t :w<CR>1G:exec "/^" . g:mhseparator . "$"<CR>jyG:enew<CR>PGdd:w! ~/tmp/.draft<CR>:bn<CR>O#<text/plain<ESC>Go#<application/pgp-signature<ESC>:exec "r!gpg --detach-sign --no-secmem-warning --output - --armor --textmode ~/tmp/.draft"<CR>
endif
This should be placed in your .vimrc. The only thing I'll really mention above is the g:mhseparator. This should be exactly the same line that separates your headers from your body (comp, repl, and forw formatting)
Just modify the variable in .vimrc to match your comp format.

One final note: To get the pgp signature mail part to play nice with mhbuild, you'll have to add this line to your .mh_profile
mhbuild-compose-application/pgp-signature:

This just lets mhbuild know of the existance of Content-Type: application/pgp-signature.

 

So the other update is to my mailfilter script. It now supports better html stuffs and pgp signature verification. I've done a bit of testing with other people's pgp signature attachments (though not extensive) and trial runs verifying emails tagged by vim keymapping above. It seems to work pretty well.

Slight update.. ksh prompt

Found a few issues with the latest changes I made to my ksh prompt...

[ -w "/" ] && Z="#" || Z=">"; export Z
PROMPT='$(A=$?; /bin/echo -n $HOST"("`/bin/pwd | /usr/bin/sed -Ee "s,(/usr)?$HOME,~,"`") [!] "$([ $A -ne 0 ] && /bin/echo -n "!!${A}!! ")$Z" " )'
XTERM=
case $TERM in
   aterm|xterm|dtterm)
      XTERM='$(echo -n "\033]2;'${PROMPT%%$Z*}')\007" 1>&2)'
      ;;
   esac
export PS1=$XTERM$PROMPT

Keep in mind that PROMPT is very long...
Previously, it didn't report exit codes due to kludges that made $? change to 0 due to the exit status of some of the crap that runs inside the prompt.

Huzzah. However, on a sad note I'll point out the obnoxious length of PS1 now...

nightfall(~) [569] > echo "${#PS1}"
257

more mh coolness

I got annoyed at html mail being displayed as.. well, plain text. So I stopped being a lazy fool and wrote a script to it right.

The product isn't quite finish at the time of posting, because I want to add lots of more features to it. This will run w3m on your mail if it matches one of the following conditions:
* The Content-Type of the mail is text/html
* The Content-Type is multipart/alternative and the first part is text/html
* The Content-Type is multipart/alternative and the second part is text/html (Useful when mail is transmitted in both text/plain and text/html

I am the winner, take THAT ksh!

I've been trying off-and-on for some time now to get dynamically updating xterm titles in ksh. Sure, you could set your prompt to something like:

XTERM="^[]2;Yay for titles^G"
PS1=$XTERM'$HOST($PWD) >'

This works all good and dandy until you try to write something on the command line longer than what's displayable on a single row of text, you'll see that ksh thinks the end of your line is shorter than where it's at. This is due to the problem that your xterm title is still physically a part of your prompt. This was too annoying for me to bother dealing with since my prompt at a minimum is something around 20 characters.
So I gave up trying different ways, and today I had another idea. $() and `` doesn't return anything printed to stderr. We'll use that to our advantage!

PROMPT='$HOST($(/bin/pwd | sed -Ee "s,(/usr)?$HOME,~,")) [!] '$EXITCODE'$Z '
EXITCODE='$(A=$? && [ $A -ne 0 ] && echo "!!${A}!! ")'
XTERM= 
case $TERM in
  aterm|xterm|dtterm)
    XTERM='$(echo -n "\033]2;'$PROMPT'\007" 1>&2)'
    ;;
esac
export PS1=$XTERM$PROMPT

As you can see, the $(echo ...) has stdout redirected to stderr, and therefore our xterm title text gets completely ignored by PS1 when it's executed.
Huzzah!

ion-devel rocks me sideways

I finally got off my lazy ass and learned to do kludge and lua stuff for ion-devel. I'm *so* glad I did.
With the new lua5 usage in ion-devel, you can basically script anything in key bindings. Using different means, I wrote two keybindings that let me view and rename frame region names (the physical frames themselves, not the deskspace name or the program name).
kpress(DEFAULT_MOD.."F10", function(reg) 
	    query_query(reg, "rename: ", nil, function(msg)
	       query_message(reg,"Set current region name to: "..msg)
	       region_set_name(reg,msg)
	       end,nil)
	  end),
press("F10", function(reg)
             query_message(reg, "name: " .. region_name(reg))
             end),
	     
These bindings were added to mplex_bindings.
Using nested, anonymous functions, we acheive our goals. Hitting "F10" in ion will now print the name of the currently-focused frame. ALT+F10 will prompt you to change it's name. Neat, eh?

I also did a bunch of kludge stuff for gaim, mozilla (firebird, really, but it'll work for mozilla), and gimp. Gimp required a bit of work telling what windows to go where since there are quite a few windows that can pop up.

So how do I do this kludge nonsense?
You'll need a tool that comes standard with XFree86, xprop This tool allows you to identify the class and instance of a given window. Simply type this command in a shell:
xprop WM_CLASS
The cursor will now turn into a crosshairs and you will need to click on the window you want to discover. For instance, clicking on one of my xterms produces this output:
WM_CLASS(STRING) = "xterm", "XTerm"
Now, the first word "xterm" is the instance. "XTerm" is the class. Now to make this a working kludge that'll send any programs matching this to a specific frame, you need to write a valid winprop entry.

winprop {
   class = "XTerm" 
   instance = "xterm"
   target = "target_frame"
}

We'll need a frame called 'target_frame' for this to work, so using the ALT+F10 keybinding from above, we can name a given frame. Restart ion with the F11 key (unless you've rebound that) and your kludge will now work. Run an xterm from anywhere in ion, and it'll be placed inside that frame.

In the screenshot on the right, you can see gimp in the works. All of those windows were placed in their own frames automatically, without me having to move a single one of them!