Aspire to Crudeness: Special Ogg Vorbis Issue
Cyberspace is a magick place that's not like Earth, man. Remember that happy load of crap? That heavy, powerful idea that a bunch of nasty machines (that you cut yourself on when you try to fix them after they crash when you're out of town and heat up your closet and suck themselves full of strange, clingy, powdery yet fuzzy dust) are really just the mundane shell for some kind of magickal aether, and that on top of this substrate rides CyBeRsPaCe—the strange and wonderful place where if you're smart enough and imagine something and stay up really late doing really hard things, you can call it into being and rule it.
Can I just confess something mildly embarrassing here? I had a Macintosh and a subscription to Wired in the mid-90s. I traded the former for a 486 box to run Linux and web stuff on well before I let the latter expire. I was starting to believe all this cyber-folderol. I learned HTML and made this cool, like, virtual dungeon, where you could wander around by clicking on little blue words! And this virtual newspaper in Perl, where people could, like, seize the media away from the Man! And I read John Perry Barlow's “Declaration of the Independence of Cyberspace”:
I declare the global social space we are building to be naturally independent of the tyrannies you seek to impose on us. You have no moral right to rule us nor do you possess any methods of enforcement we have true reason to fear.
Woo hoo! Right on! Look out, military-industrial-television complex! Cyber magick will rock your lame ass!
Fortunately, most of us have grown out of this stuff and figured out that the Internet is a lot more like regular reality than it lets on. (Damn!) But the epidemic of wild and woolly cyber-woo-woo airheaditude is still out there, and this time the people building glitter-covered stuffed-animal-sex rave palaces in the air are the Entertainment Industry. Somehow they're going to make their business bigger by selling us every piece of content multiple times at a micropayment per play, and they're all going to have perfect control of how many times everything gets copied or played, and their pure Mind is going to call into being a consensus reality of all poor-ass musicians getting Paid with a capital P. I wish it were so easy. In a way, I wish I were still up late at night with strong coffee, Programming Perl and a white board full of happy BS.
Anyway, this is the special Ogg Vorbis issue of this newsletter, so get set for some tips on how to do things that will probably be illegal soon, so don't forget these instructions are for Entertainment Purposes Only.
Play the oggs, don't hog the pizels and make the Pause key work.
I've looked at several of the Ogg Vorbis players out there—and they either put a window on your screen or take up space in some GNOME or KDE panel thingy that I don't allow on my screen anyway.
I can't stand having a background application I rarely if ever touch use some of the pixels I paid for. The closest player to being cool is the command-line player ogg123, but I don't want to start an xterm for it. It's supposed to be an audio player and has no reason to get in my eyes—just my ears. If only there were some way of running it in the background and sending signals to it to tell it what to do.
It turns out you can do this. Start up an ogg123 and do a killall -STOP ogg123. It pauses. Do a killall -CONT ogg123. It starts up again. Start up an ogg123 with several files and do a killall -INT ogg123. It skips tracks.
So, you can control ogg123 “remotely” with the power of signals. Whoa!
Let's do one quick thing so that we don't hopelessly confuse ourselves here—let's cd /usr/local/bin and do a ln -s ../../bin/ogg123 bg-ogg. That way we have what looks like a separate program called bg-ogg, so we can “killall” it as much as we want without messing up any other ogg123 processes we might want to run in the foreground.
Now we can just add the player to our .xsession file, like this:
# find all the oggs and play them in random order forever (while (true) do find ~/ogg -name *.ogg | xargs bg-ogg -z; done) &
I'm assuming that your oggs live in ~/ogg—if not, you should know what to do.
Now quit and restart X. Oggs! Playing in your ears with nothing on the screen! Bliss! If this doesn't happen, here are some troubleshooting hints: first, run that shell command by itself and see if it works. Then put some random command such as
in .xsession to make sure .xsession is actually running. (I always make .xsession and .xinitrc links to the same file so that I don't have to remember which one gets run from startx and which one gets run from xdm. Don't bother sending me mail to tell me which is which; I've learned it before and just forgotten it.)
Meanwhile, for those of you who aren't cursing miscellaneous X startup files, let's look at how to pause and restart. Do this:
(test -e ~/.paused && killall -CONT bg-ogg && rm ~/.paused) || \ (killall -STOP bg-ogg && touch ~/.paused)
The music paused. Do the same command again. It restarted. Why is this important? Why not just use the -CONT and -STOP commands individually? So that we can bind one key in the window manager and have it act as a pause/play button, instead of having to bind two keys.
We'll take a break now for you to fire up your window manager configuration tool of choice, bind a key to that command, and come back. (I don't know about you but I don't use the “Pause” key for anything else.) You folks back early must be the Sawfish users; have some coffee while we wait for the Enlightenment folks.
After that, the next binding should be easy. Just bind killall -INT bg-ogg to a different key. That's your “skip track” button. And finally, you probably want a keyboard volume control, too, so here are the commands to do that:
# turn it down aumix -v-4 # turn it up aumix -v+4
You can change the 4 to a different step if you want to make your volume control coarser. This control will affect all audio programs on your system, not just bg-ogg. Now how much would you pay?
Step two in this plan is to build an adapter to connect a couple of buttons to the parallel port and write a daemon to sit there and wait for button presses, then send the appropriate signals. Then I can put this in my car.
The solution to the transcription problem:
Sam Phillips of dasbistro.com in Reno sent me the answer to the “configure Vim for transcribing” problem I assigned you people in the issue before last. Here's Sam's answer:
BEGIN SAM'S ANSWER
> 2. Configure Vim to pause an audio-playing application when the user > hits backspace, then restart it after a configurable amount of idle > time. This will help Your Humble Editor transcribe speeches and > interviews for your benefit.
Okay, so I did some simple testing with xmms and this seems to work:
(note: ^H = ^v and then the backspace key^M = ^v and then the enter key)
map ^H :!xmms -u^M^M
Of course, that just pauses it and doesn't start it again. If you made a short shell script like:
---->8--- #!/bin/sh xmms -u sleep 5 xmms -u ---->8---
and put that into some file, let's say xmms-pauser.sh, and placed that into your ~/bin, this could work with a short 5 second pause:
map ^H :!xmms-pauser.sh&^M^M
So far both of these only work when you're not in insert mode. Here's one that only works in insert mode:
(note: ^[ = ^v and then the Esacpe key)
imap ^H ^[:!xmms-pauser.sh&^M^Mi
Of course, now the backspace key doesn't work in insert mode, this should fix that:
imap ^H ^[:!xmms-pauser.sh&^M^Mxa
Okay, now if you hit backspace multiple times it's going to pause and unpause the media player erratically. This can be fixed by only having one instance of xmms-pauser.sh running at a time with a lock file of sorts:
---->8--- #!/bin/sh if [ -f ~/.xmms-pauser ]; then ppid=`cat ~/.xmms-pauser` echo $ppid ps ax | sed -e's/^[ ]\+//' | cut -d' ' -f 1 | grep "^$ppid$" > /dev/null if [ $? = 0 ]; then # process is still around exit fi fi echo -n $$ > ~/.xmms-pauser xmms -u sleep 5 xmms -u rm -f ~/.xmms-pauser ---->8---
Now we have some annoying flashing because when Vim goes to a shell it redraws the screen. This can be fixed by using silent, which also allows us to get rid of one of our ^Ms:
imap ^H ^[:silent !xmms-pauser.sh&^Mxa
So there you have it. Kinda. Is that what you were thinking of?
-- Sam Phillips <firstname.lastname@example.org> http://www.dasbistro.com Reno Nevada
END SAM'S ANSWER
(Since this worked out medium-well, I will assign future Exercises for the Reader in future issues.)
One more thing—spamassassin is rapidly shaping up to be the “Free Software of the Year”. The spam problem has finally gotten bad enough to be interesting. Hmm, maybe we should do a conference on spam-fighting technology and ask John Gilmore to speak on how to fight spam without creating a precedent for content-based filtering by ISPs, which is some scary dookie, freedom lovers. Check out toad.com for more info before your spam-fighting instincts make you do something you might regret later.
Here's yet another reason I'm a spamassassin fan. I added a rule to match messages containing “Linux” (case insensitive) in the body text. I had to set my spamassassin tolerance high enough to allow press releases—but with the Linux rule in place I can see which press releases are Linux-related just from the headers. A big time saver. PR people, don't trash your precious carpal tunnel tissue mailing me about stuff that has nothing to do with Linux. I am a Linux bigot and proud.
And all you sons-of-bitches who sneaked out of Nigeria with the oil money or diamonds or whatever and want my help moving it to the USA—forget it. Take your loot back to Nigeria, tell the truth and say you're sorry. I mean it.
—Don Marti is Technical Editor of Linux Journal.
Getting Started with DevOps - Including New Data on IT Performance from Puppet Labs 2015 State of DevOps Report
August 27, 2015
12:00 PM CDT
DevOps represents a profound change from the way most IT departments have traditionally worked: from siloed teams and high-anxiety releases to everyone collaborating on uneventful and more frequent releases of higher-quality code. It doesn't matter how large or small an organization is, or even whether it's historically slow moving or risk averse — there are ways to adopt DevOps sanely, and get measurable results in just weeks.
Free to Linux Journal readers.Register Now!
|Secure Server Deployments in Hostile Territory, Part II||Jul 29, 2015|
|Hacking a Safe with Bash||Jul 28, 2015|
|KDE Reveals Plasma Mobile||Jul 28, 2015|
|Huge Package Overhaul for Debian and Ubuntu||Jul 23, 2015|
|diff -u: What's New in Kernel Development||Jul 22, 2015|
|Shashlik - a Tasty New Android Simulator||Jul 21, 2015|
- Hacking a Safe with Bash
- Secure Server Deployments in Hostile Territory, Part II
- Huge Package Overhaul for Debian and Ubuntu
- KDE Reveals Plasma Mobile
- The Controversy Behind Canonical's Intellectual Property Policy
- Shashlik - a Tasty New Android Simulator
- Home Automation with Raspberry Pi
- Embed Linux in Monitoring and Control Systems
- diff -u: What's New in Kernel Development
- General Relativity in Python