Command Line Lyrics Viewer

April 17th, 2012

Advertisements

If you are a fan of command line music players like Cmus, Pianobar, or Shell-fm you may have wondered how to get lyrics for the song you are playing. There is a program called Cmus-Lyrics that does just that. Originally created to display lyrics for music playing in Cmus, the program has been expanded to handle Shell-fm and Pianobar. It uses glyr to download lyrics. I am sure glyr may be packaged in future releases of Ubuntu, but as I am using Vinux 3.0 based on Ubuntu 10.04, I have to compile it. So here are instructions for getting the latest and greatest glyr:
sudo apt-get install cmake libglib2.0-dev libcurl3 libcurl4-openssl-dev libsqlite3-dev
git clone https://github.com/sahib/glyr.git
cd glyr/
cmake -DCMAKE_INSTALL_PREFIX=/usr .
make
sudo make install
Then, to get cmus-lyrics:
cd
git clone https://github.com/ok100/cmus-lyrics.git
cd cmus-lyrics/
For the program to work you will need to have music playing in one of the players it supports, Cmus, Last.fm, or Pianobar. I recommend using a multitermnal program like screen or tmux. When you have music playing, to launch cmus-lyrics, while in the cmus-lyrics directory type:
./cmus-lyrics
It will find and download the lyrics for the currently playing song.
There are a couple of additional steps you need to take for it to work with either Pianobar or Shell-fm. The setup is very well documented in the README>MD file in the cmus-lyrics directory.
This program is very well written and is hours of fun.

Help Power my blog posts, keep my caffeine buzz going strong!

Easily Share Files and Directories with Dropbox’s Public Directory

October 28th, 2011

Advertisements

After reading this Lifehacker Article, I was convinced that similar functionality is possible in Linux. turns out I was right. Here’s a script you can add to .gnome2/nautilus-scripts to add the same functionality without having a program constantly running in your system tray like is required for Windows users. further more, my script will zip a directory before copying it to Dropbox, so no need to right click each file individually if you want to share a whole directory. If you’re not sure how to get it set up, here are instructions:
open Accessories, Terminal
cd ~/.gnome2/nautilus-scripts/
wget http://stormdragon.us/scripts/share-with-dropbox.sh
chmod 700 share-with-dropbox.sh
Now, you can right click any file or directory, select scripts, and click on share-with-dropbox to copy the file to your public directory and have the link automatically placed in your clipboard. This script requires that xclip be installed. From terminal:
sudo apt-get install xclip
enjoy, and I hope you find this useful.

Help Power my blog posts, keep my caffeine buzz going strong!

Softphones for Linux

August 27th, 2011

Advertisements

With the news that Microsoft has bought skype, Linux users are left wonderinf how much longer a Skype client will be available to them. Although Skype is currently the most popular internet calling service there are other options that work equally as well and have the added binnifit of being open source. Open source softphones use the SIP protocol. This means, in order to use a softphone, you need to get a SIP address. There are a lot of sites that offer free SIP addresses.

  • Iptel.org
  • Sip2sip.info
  • Ekiga.net
  • are great examples of sites that offer free sip addresses. Often your sip account will include some great features too like free voice mail, and the ability to get the voice mail emailed to you.
    After you have registered and gotten your SIP address you will need a softphone. once again there are several choices. My personal favorite is Linphone but there are also Ekiga Softphone, Twinkle, and a lot of others available for Linux. Softphones are available on all opporating systems, Windows, Mac, Linux, Android, etc all have softphones.
    After you have installed your softphone:
    sudo apt-get install linphonec
    in Ubuntu and Vinux for linphone, you need to configure it. This may be different for different softphones. Here, I will show how to set up Linphone using iptel.org as an example. One great thing about Linphone is it is usable in the terminal, so if you happen to be in a console you can still make and receive calls. The way you launch Linphone in terminal is by typing:
    linphonec
    You will get some messages as the program starts and finally a warning about video being disabled in linphonec. If you are in Gnome, for example, and using gnome-terminal you can enable it by typing:
    linphonec -v
    Then, to add your sip address type:
    proxy add
    Here is each of the prompts you will get an what should go in it:
    linphonec> proxy add
    Adding new proxy setup. Hit ^D to abort.
    Enter proxy sip address: sip:iptel.org
    Your identity for this proxy: sip:YourUserName@iptel.org

    Do you want to register on this proxy (yes/no): yes
    Specify register expiration time in seconds (default is 600): 3500
    Expiration: 3500 seconds
    Specify route if needed:
    No route specified.
    ——————————————–
    sip address: sip:iptel.org
    route:
    identity: sip:YourUserName@iptel.org
    register: yes
    expires: 3500
    registered: no
    ——————————————–
    Accept the above proxy configuration (yes/no) ?: yes
    Proxy added.
    linphonec> Registration on sip:iptel.org successful.
    If you are using linphonec you can get help on the commands by typing help. Most things are pretty simple, answer answers a call, terminate hangs up, to make a call do:
    call sip:UserName@sipprivider.whatever. There are lots and lots of softphones. If you have a favorite and would like to provide instructions for setting it up please do so in the comments. Please also say on which opp operating system it is available. Unless you are sure you are using IPV6 you will want to type the command ipv6 disable. If you do not do this you may not be able to connect.

Help Power my blog posts, keep my caffeine buzz going strong!

Sharing the Clipboard with the Console

May 18th, 2011

Advertisements

Sharing the clipboard between your GUI desktop and the console can be a bit of a challenge. I was doing it by pasting into a temperary file then opening that file in the console. Then, however, I got to thinking there has to be a better way. So, I wrote a bit of code in python to automatically check the clipboard for text and write it to /tmp/clipboard. It works quite nicely, but I have noticed that when it is running, switching between applications with alt+tab is slower than normal. It may be something to do with the loop slowing things down, but I am not sure. For those who are interested, here is the code:
#!/usr/bin/python
#Clipboard to File Written by Storm Dragon
#Copyright May 2011 by Storm Dragon
#License GPL
#This program places any text in the clipboard into the file /tmp/clipboard
#The file is updated every 0.5 seconds

#Library import section
import time
import pygtk
import gtk
#Loop forever!
while True:
    #Get the clipboard
    cb = gtk.clipboard_get()
    #assign the clipboard contents to a variable.
    cbText = cb.wait_for_text()
    if isinstance(cbText, str) == True:
        file = open(“/tmp/clipboard”,”w”)
        file.write(cbText)
    time.sleep(0.5)
After I completed this small program I learned of the existance of a clipboard manager called parcellite. In Ubuntu and Vinux you can install it with:
sudo apt-get install parcellite
You can adjust parcellite’s preferences by right clicking on it in the panel and selecting preferences. If you left click it you will get the clipboard’s contents and the history up to 100 previous selections depending on the setting in preferences. You can also access the clipboard history with the keyboard shortcut control+alt+h. In order to have parcellite start when you login, you will need to add it to startup applications in System, Preferences, Startup Applications. If you choose to use my script you can add it to startup applications instead.
If you use parcellite you can access the clipboard history in the console in the file located at:
~/.local/share/parcellite/history
Because it is a binary file it does not work in Gedit.
If you use my program or the clipboard manager glipper it will work in gedit. The file my program writes to is:
/tmp/clipboard
My program does not contain any history, only the last text in the clipboard.
After a bit more research I find I prefer using the clipboard manager Glipper:
sudo apt-get install glipper
To access the clipboard press control+alt+c. To access the history in the consolesimply open the file:
~/.glipper/history
Of course, if you use glipper you do not need my script.
Parcellite also has the ability to copy text from the terminal, gnome-terminal or any terminal opened from the desktop. If you try from the console you get an error about not being able to open the display. If you do:
echo “hello world” | parcellite
then the words "hello world" will be in your clipboard. You can accomplish the same thing by using a program called xclip:
sudo apt-get install xclip
To place something in the clipboard:
echo “hello world” | xclip -selection clipboard
You can download Clipboard to File by right clicking the link and selecting save link as.
After some descussion it was decided that probably the best way to cut out the lag caused by clipboard-to-file is to drop the loop completely and just bind the program to a keyboard shortcut. So, here is the new code, the download link will now also get you this code as well:
#!/usr/bin/python
#Clipboard to File Written by Storm Dragon
#Copyright May 2011 by Storm Dragon
#License GPL
#This program places any text in the clipboard into the file /tmp/clipboard

#Library import section
import time
import pygtk
import gtk
#Get the clipboard
cb = gtk.clipboard_get()
#assign the clipboard contents to a variable.
cbText = cb.wait_for_text()
if isinstance(cbText, str) == True:
    file = open(“/tmp/clipboard”,”w”)
    file.write(cbText)
I went to System, Preferences, Keyboard Shortcuts and added clipboard-to-file and set its shortcut to control+alt+v. This new method has all of the coolness with none of the slowness.
One more thing that will make sharing info between the GUI desktop and the console easier is a paste command for the IRC client irssi. I actually have 2 of them. These use assume you are using glipper. The first simply pastes the last thing in your clipboard history to irssi and sends it as a message:
/alias paste /exec -o cat /home/USER/.glipper/history | head -n 2 | tail -n 1
the other is for when you want to paste several lines. Each line will be sent as a message so be careful with this one. Irssi will prompt you if you try to send more than seven lines, so there is a safety net:
/alias read /exec -o cat /tmp/clipboard
To use this one just make sure the text you wanto to send as a message is in the file /tmp/clipboard.

Help Power my blog posts, keep my caffeine buzz going strong!

Facebook Comes to the Command Line

April 13th, 2011

Advertisements

I have been searching for a way to access Facebook from the command line for a while now. I don’t use Facebook all that much, I prefer Twitter, but I do have a lot of friends who use Facebook. So, I created an account, and fortunately got the Twitter application working for it before they broke (disabled) it for new users. So, to make a long story short, the only updating my Facebook account gets is usually done from my Twitter stream. Facebook, to me, just seems kind of clunky to use with a browser, that and there aren’t many accessible clients for it, so the only way to use it was with a browser. I recently got an Android phone and it adds another way to access Facebook but I really don’t use that method much either. Then, my friend Burt Henry found fbcmd. Fbcmd is a command line application written in PHP for Facebook. It is really easy to get installed. To do so, first install php by typing:
sudo apt-get install php5-CLI
Then get the fbcmd software by typing:
wget --no-check-certificate https://github.com/dtompkins/fbcmd/raw/master/fbcmd_update.php
If you are wondering about the certificate flag in the above command it is there because wget gives an error for github’s certificate. It is really the destination it claims to be. After the download completes, type the following two commands:
sudo php fbcmd_update.php
sudo php fbcmd_update.php install
Then, if you would like to verify that everything installed correctly, type:
fbcmd
You should get a short help message describing the procedure for granting authorization to fbcmd. if everything goes OK you can now remove the installation package using the command:
rm fbcmd_update.php
Now, to grant authorization to fbcmd type:
fbcmd go access
This will open your default browser, most likely Firefox if you are in Gnome, you will need to click allow. Next, type:
fbcmd go auth
When you click the allow button here you will be given a six6 character authorization code. I had trouble copying it to the clipboard with Orca, so you may have to memorize it long enough to type it in to terminal:
fbcmd auth XXXXXX
Where XXXXXX is your code.
Now, to see what your friends have been up to while you were busy installing this really cool program, type:
fbcmd stream
To set your status:
fbcmd status 'Thinks Thoughts of a Dragon is the greatest blog in the whole world, no, the whole universe!'
when you read through your stream you will notice each item is numbered. You can comment on the post by typing:
fbcmd comment 3 "If you need help with your diabolical world domination plans just let me know."
This will of course reply to the third post in your stream which was hopefully about diabolical world domination and not cute little bunnies, although cute world dominating bunnies might be kind of cool.
For a full list of commands and all kinds of great help visit the fbcmd wiki. You can also get help on a command by typing fbcmd help command as in:
fbcmd help status
I foresee all kinds of neat cron stuff for this application. If you think of any example feel free to share with everyone in the comments.

Help Power my blog posts, keep my caffeine buzz going strong!

Music Status for BitlBee

March 17th, 2011

Advertisements

For nearly every instant messenger in Linux there is a plugin or the ability to set your status to the currently playing song. I was surprised to find that nothing like this was available for Irssi and BitlBee though. So, I decided to see if I could do anything about it. It turned out to be a lot harder than I thought it would be to get this working, but finally after a lot of tinkering and help from the #irssi channel on irc.freenode.net as well as the Irssi info email list, it’s alive!
First, let’s get everything set up. You will need the cron script for Irssi. Save the script to your ~/.irssi/scripts directory. You may need to create the scripts directory. Then create a simlink to cron.pl from the ~/.irssi/scripts/autorun/ directory. the autorun directory may also need to be created. to make the simlink:
ln -s ~/.irssi/scripts/cron.pl ~/.irssi/scripts/autorun/cron.pl
This causes the cron.pl script to start with Irssi. For this example I decided to use Pianobar, console based Pandora player. You can use a script file called eventcmd.sh located in ~/.config/pianobar/ to make Pianobar do some pretty nifty things. Part of what mine does is set status for Pidgin instant messenger and also write a file in /tmp/irssistatus that contains a small script to set by bitlbee status to the currently playing song. Here is my file which is based off the example file included with Pianobar:
#!/bin/bash
# create variables
while read L; do
k="`echo "$L" | cut -d '=' -f 1`"
v="`echo "$L" | cut -d '=' -f 2`"
export "$k=$v"
done < <(grep -e '^\(title\|artist\|album\|stationName\|pRet\|pRetStr\|wRet\|wRetStr\|songDuration\|songPlayed\|rating\|coverArt\|stationCount\|station[0-9]*\)=' /dev/stdin) # don’t overwrite $1…
album=$(echo "$album" | sed 's/ (Explicit)//g')
case "$1" in
"songstart")
/usr/bin/purple-remote "setstatus?status=available&message=Listening to $title by $artist from $album" &> /dev/null
irssiStatus="#!/bin/bash
echo \"set status 'Listening to $title by $artist from $album'\"
exit 0"
irssiStatus=$(echo "$irssiStatus" | sed 's/\&/and/g')
irssiStatus=$(echo "$irssiStatus" | sed "s/'/\\'/g")
echo "$irssiStatus" > /tmp/irssistatus
chmod 700 /tmp/irssistatus
;;

"songfinish")
if [ -n "$songDuration" ] && [ $(echo "scale=4; ($songPlayed/$songDuration*100)>50" | bc) -eq 1 ] && [ "$rating" -ne 2 ]; then
/usr/lib/lastfmsubmitd/lastfmsubmit --artist "$artist" --title "$title" --album "$album" --length "$((songDuration/1000))"
fi
;;
"songlove")
statusText="#nowplaying \"$title\" by \"$artist\" from \"$album\""
ttytter -readline=0 -silent -status="$statusText"
;;
*)
if [ "$pRet" -ne 1 ]; then
echo "naughty.notify({title = \"pianobar\", text = \"$1 failed: $pRetStr\"})" | awesome-client -
elif [ "$wRet" -ne 1 ]; then
echo "naughty.notify({title = \"pianobar\", text = \"$1 failed: Network error: $wRetStr\"})" | awesome-client -
fi
;;
esac
exit 0
#end eventcmd.sh
If you have createdd the file to ~/.config/pianobar/eventcmd.sh, set it to executable, and it doesn’t seem to work, edit the file ~/.config/pianobar/config and add the line:
event_command = /home/USER/.config/pianobar/eventcmd.sh
You can add your Pandora user name and password if you want:
user = Your Email Address
password = YourPassWord
This will allow you to automatically login without being prompted for your information each time.
The above script will also post the songs you love by pressing the + key to Twitter using TTYtter. It scrobbles to Last.fm using lastfmsubmitd:
sudo apt-get install lastfmsubmitd
Then edit the file:
/etc/lastfmsubmitd.conf
and add the following three lines:
[account]
password = yourLast.fmPassword
user = Last.fmUserName
Your user name is your account user name not your email address.
And now, back to the original idea for this article. You have your shiny new eventcmd.sh file in place, you have your cron.pl script in the ~/.irssi/scripts directory and have it set to start when Irssi does. So, now, start irssi and type the following line:
/jobadd -server localhost * * * * * /exec -msg &bitlbee /tmp/irssistatus
To save it for future use type:
/jobssave
Then, the next time you start Irssi and login to BitlBee type:
/jobsload
to get it up and running again. And there you have it, your very own musical status for BitlBee. If you don’t have BitlBee installed but use a public installation, you will need to change the -server bit in the /jobadd line to your public server. There is one small problem though. In your &bitlbee control channel you will keep getting your message to set the status and then the root confirming it has been set. I have managed to get rid of the confirmation message but the actual set status from your nick will still show up. To block out the confirmation:
/ignore -regexp -pattern “(set status|status =)” *
There is probably a better way but regexps are not my strong point, so suggestions are welcome.
If you aren’t listening to anything and the /tmp/irssistatus file doesn’t exist you will get an error. the easiest way to correct this is to write the /tmp/irssi file by hand with your chosen status:
#!/bin/bash
echo 'set status "GREEN! like a booger!"'
exit 0
That one will definitely get you some ims Usually consisting of things like "What the hell!?". If you would like a bit more of a random status you can use this instead:
#!/bin/bash
status=$(fortune -s | sed "s/'/\\'/g")
status=$(echo "$status" | tr "[:space:]" " ")
if [ $(echo "$status" | wc -l) -eq "1" ] ; then
echo "set status '$status'"
fi
exit 0
The above script will give an error if the fortune is not in English. In the music script, some songs with odd things in their names may cause errors. this is rare as far as I can tell. I think I have fixed most if not all of them.

Help Power my blog posts, keep my caffeine buzz going strong!

Commanding the Command Line (Part 3)

January 17th, 2011

Advertisements

It’s finally here! The third installment of Commanding the Command Line. And this time I have some great goodies for you like…

Fun With Scripting

Bash scripting could and probably should have a religion devoted to its glory. It’s powerful, simple for the most part, and if you know anything about using the command line you already know some about bash scripting. If you want to read a great book that is free and will teach you all you need to know and more about scripting with bash then read the Advanced Bash-Scripting Guide. So now you want a good use for all this knowledge? How about a signature script for your email client like Evolution or Thunderbird. Here’s a script that will change part of your signature while keeping some things the same each time. the html tags are necessary to make it display correctly in Evolution. You can right click the link and select "save link as" to download it. For Evolution save the script in ~/.evolution/signatures/random-signature.sh and set the permission to executable with:
chmod 700 ~/.evolution/signature/random-signature.sh
then start Evolution, and under Edit, Preferences, Composer Preferences select Signatures. Select the Add Script button, add it as random-signature, then select ~/.evolution/signatures/random-signature.sh as the signature script. Finally, to make it the default signature for your e-mail. From the Preferences page select your email account, press enter on edit then select random-signature from the drop-down box.
If you happen to be a fan of the CLI email client Alpine you can use the random signature by editing the file ~/.pinerc. Search for the line that reads signature-file= and put the path to the signature file:
signature-file=/home/USER/path/to/random-signature.sh|
Notice the | at the end of the file name so Alpine knows to execute it as a script.
With Alpine though, you do not need the div and pre tags, in fact they just show up in the message and ruin your otherwise beautiful signature. Bash to the rescue again. All you have to do is check for a variable that is set when you are in Gnome or your prefered desktop that isn’t set in the console. In Ubuntu and Vinux, using Gnome, this works:
if [[ -n $COLORTERM ]] ; then
echo "<div>-- </div>
<pre>
$signature
</pre>"
else
echo "-- 
$signature"
fi
Thunderbird it is a little more tricky. You have to point Thunderbird to your signature.txt and change the above script to write its contents to the txt file every time it is ran. But how do you get the script to run and change the file thereby making it random? Simple, you schedule the signature script to run at intervals using…

Scheduling with Crontab

Cron jobs are great things. They run a command at specified times. It can be once a day, once a week, once a month, multiple times a day, month, etc. Each job takes 6 parameters. In order they are:

  1. minute from 0 to 59
  2. hour from 0 to 23
  3. Day of month varies depending on the month
  4. Month 1 through 12
  5. Day of Week 0 through 7 0 and 7 are both Sunday
  6. Command

To specify that the task should run for each occurance use the * in place of the number. To have something run at several different occurances but not every one use a , between each number like
5,25,55
used in the minute field would run the task at 5, 25, and 55 minutes in the hour or hours specified. To make it run the command for a specific period of time say every minute from 5 to 10 in the hour use a – like this:
5-10
The above example will run the task at 5, 6, 7, 8, 9, and 10 minutes after the specified hour.
Now, for some working examples:
0 6,18 * * * espeak "hello world"
This not so useful example will make your computer say hello world using the Espeak synthesizer at 6:00AM and 6:00PM every day. while the following:
0 12 * * * crontab -l > /home/USER/crontab.bak
will back up your crontab jobs to your home directory under the name crontab.bak every day at 12:00PM. So, finally, if we wanted to run the signature script which we have modified to write to the .txt file we use as our thunderbird signature we could do:
* * * * * /home/User/path/to/random-signature.sh
This cause the script to run every minute of every day changing your signature to a new random saying each time it happens.
Of course you need to change the signature slightly to write to the .txt file you use as your signature in Thunderbird. It’s not a big change, just edit these lines in the original script:
#code
echo "<div>-- </div>" > /home/USER/path/to/signature.txt
echo "<pre>
$signature
</pre>" >> /home/USER/path/to/signature.txt
#end code
Another great use, if you have TTYtter set up, is to use Cron to wish your Twitter contacts happy birthday. this way you remember to tell them happy birthday and you get a reminder that it is their birthday all at the same time.

Aliases

Aliases are shortcuts to commands. Basically you can say one thing and mean something much longer. You can even change how commands behave by aliasing the command. A great example of this is the date command. If you open terminal and type date you will get something like this:
Mon Jan 17 22:50:47 EST 2011
But by creating an alias for date you can get something you may find easier to read like this:
10:51PM
Monday, January 17, 2011
To set up these aliases open a file in your home directory called .bash_aliases:
gedit ~/.bash_aliases
and put aliases in the form:
alias shortcut="command"
Here is the date command aliased to the format I have above:
alias date="date +'%I:%M%p%n%A, %B %d, %Y'"
After you save the file your date alias will be nearly ready to go. the only thing you have to do after adding an alias before you can use it is source your .bashrc. So, type the command:
source ~/.bashrc
Now when you type the word date you should get the more readable format. If you want the previous version for some reason just prepend it with a \ character:
\date
If it does not work you may want to check your .bashrc file for the correct lines to load the alias file:
gedit ~/.bashrc
If you do not find the following code then you may want to add it to the file:
if [ -f ~/.bash_aliases ] ; then
. ~/.bash_aliases
fi
If you find the code but each line begins with a # character it means the code has been commented out. Code that is commented will not run, so all you have to do to fix it is remove the # from the 3 lines of code.

Bash One Liners

To further show off the power of bash here are a collection of one line commands that can do some really impressive things. This section will grow as I find or think of good examples. And now, some truly awesome code:
#Although I strongly believe everyone should use .ogg files I know that is not always possible.
#Convert files in current directory to mp3
#Using unrestricted version of sox:
for i in ./*.*;do sox "$i" "${i%.*}.mp3";done
#Using ffmpeg from medibuntu or compiled:
for i in ./*.*;do ffmpeg -i "$i" "${i%.*}.mp3";done

Video In The console

There are two ways to do this, you can use aaxine:
sudo apt-get install xine-console
and then:
aaxine path/to/video.avi
You may need to specify an audio device as in:
aaxine -A pulseaudio path/to/video.mpg
You can accomplish the same thing using libcaca and mplayer. to get libcaca:
sudo apt-get install libcaca0
then play a video with:
mplayer -af volnorm -vo caca path/to/video.avi

Help Power my blog posts, keep my caffeine buzz going strong!

Shell-fm, a Command Line Last.fm Player

September 16th, 2010

Advertisements

I was searching for a good command line last.fm player to use on my netbook. Command line apps really have an advantage on netbooks because of their speed. The player I chose is shell-fm. It is easy to configure and use, and has a nifty ability that makes it, in my opinion, easily the best choice. You can run other command line commands from inside shell-fm and, better still, bind the command to a keypress. I will show you why this is so awesome in just a sec, but first, installation.
Although you can install shell-fm from the repositories with:
sudo apt-get install shell-fm
you will probably want to compile it from source. The latest version has built in volume controls using the + and – keys. To compile from source open terminal and type:
sudo apt-get install git-core
sudo apt-get build-dep shell-fm
git clone http://github.com/jkramer/shell-fm.git
cd shell-fm/
make
sudo make install PREFIX=/usr MANDIR=/usr/share/man
When it is finished installing switch back to your home directory by typing:
cd
Create the .shell-fm/ directory by typing:
mkdir .shell-fm/
mkdir .shell-fm/cache/
then create the shell-fm configuration file:
gedit ~/.shell-fm/shell-fm.rc
There are several things you can put in this file. I only have three or four lines in mine though. The format is:
variable = setting
Here is a sample of what you can put in it. Replace USER with your Last.fm user name and PASSWORD with your Last.fm account password. Note that only upper case words should be changed:
username = USER
password = PASSWORD
title-format = Now playing %t by %a from %l
screen-format = Now playing %t by %a from %l
term-format = Now playing %t by %a from %l
default-radio = lastfm://user/USER
The last line loads your chosen radio station when shell-fm opens. If you use the default-radio line above with your user name the station that plays is your last.fm library. If you would like to automatically download free songs, add the next line replacing USER with your home directory:
download = /home/USER/Downloads/%a – %t.mp3
Downloaded tracks will be saved in your ~/Downloads directory.
And now, as promised, I will show you some extra coolness. If you have installed TTYtter, Here is a script that uses TTYtter to tweet the currently playing song. To get it set up open terminal and type the following line:
wget --output-document ~/.shell-fm/tweet.sh http://www.stormdragon.us/scripts/tweet.sh
chmod 700 ~/.shell-fm/tweet.sh
Finally, the key binding thing I mentioned earlier. In your ~/.shell-fm/shell-fm.rc add the following line. Replace USER with the name of your home directory (usually your login name):
key0x74 = /home/USER/.shell-fm/tweet.sh %t %a %l %T
This binds the tweet script to the lower case letter t. the key format uses the HEX value of the ASCII character. You can get the HEX value using a Hex to ASCII Converter. The key must be entered as:
key0xHEXNUMBER = command
Shell-fm also has the ability to run a command when a song starts or when it ends. One use for this is to set your status in Pidgin to the currently playing track. To do this, open your ~/.shell-fm/shell-fm.rc and add the line:
np-cmd = /usr/bin/purple-remote ‘setstatus?status=available&message=Listening to %t by %a from %l’
If you do it this way though your status may have a lot of \ characters in it. To avoid this, put it in a script and call it like the tweet script above without the URL. Here is status script. Save it in your ~/.shell-fm/ directory and call it like this:
np-cmd = /home/USER/.shell-fm/status.sh %t %a %l
Don’t forget to change permission to 700 with:
chmod 700 ~/.shell-fm/status.sh
To get instructions on using shell-fm type:
man shell-fm
or if you are running shell-fm type:
?
for a list of commands.

Help Power my blog posts, keep my caffeine buzz going strong!

Extending TTYtter

September 12th, 2010

Advertisements

The TTYtter extension pack has been moved to github. The original article and files have been left intact for anyone who wants them. The new way to get the extensions is to open terminal and do the following:
git clone https://github.com/stormdragon2976/ttytter-extensions
To add an extension to your .ttytterrc, the soundpack for example, you would do:
ext=/home/USERNAME/ttytter-extensions/soundpack.pl
And now back to the original article already in progress…
One of the very numerous awesome things about the greatest Twitter client in the world, TTYtter, is its ability to use extensions. extensions are third party add ons for TTYtter that add functionality that hasn’t been included in the TTYtter program itself. One of the things I wanted in TTYtter was sound alerts for the different types of events. So, with some help from TTYtter’s author, Cameron Kaiser, I wrote my first TTYtter extension to add soundpack functionallity. The soundpack goes in a directory in your home folder. If you download the script by itself you may need to create this directory structure. The path to the sounds is:
~/.ttytter/sounds/soundpack-directory
My first soundpack was created using the Espeak speech synthesizer. If you would like, you can download the soundpack. Use the file names as a template to create your own soundpacks. The file names must match exactly. They are:

me.ogg
Sound to play when you post a tweet.
default.ogg
Sound when you receive a new tweet
dm.ogg
Sound when you receive a direct message
search.ogg
sound when you get new results for what ever you are tracking
reply.ogg
sound when someone mentions you

The soundpack can be named anything you like and must be placed in:
~/.ttytter/sounds/
To get your chosen sound pack to load when TTYtter starts, add the line:
extpref_soundpack=sound-pack-name
to your .ttytterrc. Alternatively you can just rename your chosen sound pack to:
default/
and it will load with no modification needed in the .ttytterrc file.
Usually I put all the extensions I use in the ~/.ttytter/ directory so it keeps everything nice and tidy. If you would like to use the full pack of extensions that I use I have created a convenient package that has everything already set up in it. Just extract the folder in your home directory and set up your .ttytterrc file to point to the extensions. If you have previously installed TTYtter using my previous post, you only need to add a line and the notification type for the soundpack. Open terminal and type:
gedit .ttytterrc
Somewhere in the file above the notify information, add the following replacing USER with your user name, the name of your home directory:
exts=/home/USER/.ttytter/soundpack.pl,/home/USER/.ttytter/timestamp.pl,/home/USER/.ttytter/groups.pl
Next find the line that reads:
notifytype=libnotify
and chage it to:
notifytype=soundpack,libnotify
save the file and everything should just work when you open TTYtter.
Included in the pack are the soundpack script, a timestamp script originally written by @vkoser and heavily modified by me, and a groups extention also written by @vkoser. when you install the pack there is a default group created with @ttytter, myself, and some other extention writers in it. If you follow any of us our tweets will be stored in the ttytter group. For help with group commands type:
/grouphelp
If you would like an automated way to create your .ttytterrc using all the extensions then check out http://www.stormdragon.us/ttytterrc/. Note that it assumes you will be using both libnotify and the soundpack extension. If you don’t want to use libnotify edit the file and remove it from the notifytype line.

Help Power my blog posts, keep my caffeine buzz going strong!

Command Line Spell Checker

August 4th, 2010

Advertisements

Sometimes you may want to spell check a word without having to open a browser or a word processor. In a situation the command line can once again come to the rescue. To get the spell checker, in a terminal, type:
sudo apt-get install hunspell hunspell-en-us
After the installation has completed you can do:
hunspell
and type in each word you want checked. If the word is spelled correctly it will display *. If the word is not correct it will offer suggestions. Another way to check a word is to type:
echo “word” | hunspell
To make things even easier, you can create a file named spellcheck in ~/bin/ and add the following lines:
#!/bin/bash
echo “$@” | hunspell
exit 0
Save the file and change its permissions by typing:
chmod 700 ~/bin/spellcheck
Now you can check words by typing:
spellcheck word to check
the above line should yield 3 * symbols. So, the next time you need to check a single word to paste in to an application, open a terminal and get the correct spelling in a few seconds.

Help Power my blog posts, keep my caffeine buzz going strong!