|
This one took me a little while to figure out, but I finally got it.
In the script below, you can just replace the USERNAME:PASSWORD with your Twitter credentials & it will work no problem. Or you can continue reading and learn how to modify it to your taste.
#!/bin/bash
curl --basic --user USERNAME:PASSWORD --data status="Listening to: ${*:1:1} #musicLibrary" http://twitter.com/statuses/update.xml > /dev/null
Line 1: path to your bash executable
Line 2: This is the part that has been throwing me for a loop for quite a while.
The first portion "curl --basic --username USERNAME:PASSWORD " is quite mandatory if you want to actually post anything. Curl is a CLI for pushing and pulling data on the internet.
The next part "--data " is telling curl what you want to do. In this case, we are telling curl to grab the supplied string "status="Listening to: ${*:1:1} #musicLibrary" and push it to "http://twitter.com/statuses/update.xml".
The last portion of this line "> /dev/null" is telling curl to send any and all returned data to the null device on the system which will prompty forget that it recieved anything at all.
Now, you may be wondering what exactly does the ${*:1:1} part of the command do. This is simply telling BaSH to pass all (${*) startup arguments beginning with position one (:1:) and only take one (1} argument and insert it into the text string. See line below for inserting the first five arguments.
eg: ${*:1:5} or if you want the fifth through seventh arguments ${*:5:3}
After you copy/paste & configure your own script, don't forget to make it executable with 'chmod +x FILENAME'!
Now for configuring xmms.
If you look closely, you can see I have the config window open for the 'Song Change' plugin in the XMMS preferences pane.
In the 'Song Change' dialog, type in the path to your new script followed by %n in quotes.
eg: /home/user/bin/tweet "%n"
If you read through the config page for xmms-song_change, you will find other variables & fun stuff to put into your command.
Don't forget to click the 'Enable plugin' check box after you have it configured & hit the [OK] button.
That's it for me. Lemme know what you think & if you come up with a better way, please let me know.
|