@CheriePie: Here goes nothing

.
@mhnotnot: Thanks again

.
As for running stuff from the CLI, I vaguely remember some scripts calling a compiled java class through cvm directly, but I have no idea how said class must be engineered for that to work.
As for running stuff on unplug, that simply requires something running in the background and listening for the usb unplug event (both the ScreenSavers & Fonts hack have a mechanism that handles this, albeit disabled by default on FW 5.x).