Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

Wednesday, March 11, 2009

March Madness on your Conky

March Madness is here and and what better way to keep track of the action than with a scoreboard tracker at the bottom of your screen. Check out the image below:

This is accomplished by combining a python script with the conky variable scroll. The python script will get the data, parse it and put it into a acceptable format for conky to handle the display. I've talked about conky earlier and using displaying the last instant message.

Copy the following code and save it as bottomscore.py


#!/usr/bin/python
import urllib
# Open html page
fweb = urllib.urlopen("http://scores.espn.go.com/ncb/bottomline/scores")

gamestr=''
score=''
# Manipulate str for unneccessary chars
raw=str(fweb.readline())
raw=raw.replace('%20',' ');
raw=raw.replace('^','');
raw=raw.replace('&','\n')

# Open data storage
f=open('bottom.dat', 'w')
f.write(raw)
f.close()
f=open('bottom.dat', 'r')

# Parse each line, get game, create str, append str
for line in f:
if line.find('_left')>1:
gamestr=line[line.find('=')+1:-1]
score= score + gamestr + ' | '

f.close()
print score


My conky script is as follows. Save this
#avoid flicker
double_buffer yes

#own window to run simultanious 2 or more conkys
own_window yes
own_window_transparent no
own_window_type normal
own_window_hints undecorate,sticky,skip_taskbar,skip_pager, above

#borders
draw_borders no
border_margin 0

#shades
draw_shades no

#position
gap_x 0
gap_y 0
alignment bottom_middle

#behaviour
update_interval 1

#colour
default_color 8f8f8f
#default_shade_color 000000
own_window_colour 262626

text_buffer_size 1400

#font
use_xft yes
xftfont bauhaus:pixelsize=10

#to prevent window from moving
use_spacer none
minimum_size 1400

TEXT
${color e0e0e0} ${scroll 2847 ${execpi 60 python ~/scripts/bottomscore.py}}

Remember to edit your .conkyrc to run the right path to bottomscore.py. You may need to edit certain parameters for your screen resolution but this should give you a good start. Any questions, post a comment.
Pro Tip:To run multiple conky screens:"conky -c .conkyrc2"

Monday, March 2, 2009

How to Burn Compressed Video Files to DVD in Ubuntu

With some help from Realtimeedit and MEncoder, I developed a script file to convert common compressed video files into an .iso file which can be burned onto a DVD for set top playback on your TV.

Before you run the script, you'll need to install the following packages:

MEncoder: sudo apt-get install mencoder
DVD Author: sudo apt-get install dvdauthor

Download the script file here.

When you run the script it will prompt you for the directory, name, and extension of the video file. It will then prompt you for the aspect ratio of video file and run MEncoder to decompress the file to an mpeg format. It will then run DVD Author to write to DVD format and create an .iso file.

Use any DVD burning software to burn the .iso image to a DVD.

Hope this works for you, any comments are always appreciated.

Friday, January 30, 2009

How To: MPD/MPC with Ubuntu

For a few months now I wanted to try mpd mainly out of curiosity. Music Player Daemon (mpd) is a music server and mpc will be the client used to interact with the server. This how to will look at a localhost server of mpd.

Prereqs: Enable universal repositores in /etc/apt/sources.list

Installing & Configuring Software:
In terminal:
sudo apt-get install mpd mpc paprefs
Next we need to set up Pulse Audio.
Go to System->Preferences->Pulse Audio Preferences
Check "enable network access to local sound device" & "Don't require authentication"
Set up mpd.conf (use your favorite text editor)
sudo gedit /etc/mpd.conf
Add the following to the config file:
audio_output {
type "pulse"
name "Local MPD Output"
}
In the mpd.conf file, look for "music_directory" and change the corresponding path to your music directory.

Next, we shall build the database. In terminal, type:
sudo mpd --create-db
Finally, restart mpd by:
sudo /etc/init.d/mpd restart
Using mpc: mpd/mpc is higly scriptable so I recommend create some bash files for yourself. You will find the manual to mpc here: http://linux.die.net/man/1/mpc

Example: Add Radiohead to current playlist
mpc search artist Radiohead | mpc add
mpc play
Good luck

Further Reading:
http://mpd.wikia.com/wiki/What_MPD_Is_and_Is_Not
http://mpd.wikia.com/wiki/Hacks

Tuesday, November 18, 2008

SCP + SSH: Copying files from Windows to Linux

At the university I attend, it is mostly all about Windows and there is no support for linux so many things have to be done by the user to get anything done. However, most linux users are used to trying this on your own. Here I will show you how to successfully transfer files from your linux box at home to a windows computer at work/school. Linux commands refer to Ubuntu. Please see your distro's guide on installing packages.

Software Required:
Windows: Cygwin
Linux: openssh

Configuring linux box:
To install openssh, in terminal type
sudo apt-get install openssh-server
If the linux box is behind a router, please open the port corresponding to ssh. Default is 22. For more information please visit portforward.com.

To test the installation of ssh type:
ssh localhost
If everything works, then that should be up for setting up the linux box.

Configuring Windows:
After downloading setup.exe from the link above, double click to run. The important part of the installation is "Selecting Packages" diaglog box.
Expand the Net tree by pressing the +. Scroll down and look for openssh and click on "Skip" to change it to "Install". You will notice a check box under column B. Click Next when finished and complete the installation.

Operating the Windows Box:
After installation, open cygwin and a terminal will appear. The syntax for scp is:
scp [options] [[user@]host1:]filename1 ... [[user@]host2:]filename2

To copy 'report.pdf' from your Fall 2008 folder on your home directory, you would type:
scp report.pdf user@serverip:"/home/user/Fall 2008/" .
This will save report.pfg into your home directory. Notice the "."

More Information:

Good Luck.

Saturday, October 11, 2008

Conky: Display Last Pidgin Message

Recently, I removed the gnome-panels, added awn, and had a conky bar at the top. However, I missed having a system notification of when I would receive a message via Pidgin. So I browsed the pidgin wiki and create somewhat of a hack to display the last IM that received from Pidgin. This method is probably not the best way however I had some diffuculty.

The DBus method that listens for the received messages was chocking conky and not allowing the conky script to load correctly. So I had to create two files. getim.py would run at startup, listen for a new message and then write that message to a data file. lastim.py would be executed within conky and check the data file for the new message. I know its not real efficient and redundant but it just works. If you have any brilliant ideas please let me know.

Here is the getim.py file:
#!/usr/bin/python

# ----- GETIM.PY // LISTEN FOR AN RECEIVED MESSAGE ------------#
################################################################
# MOST OF THIS SCRIPT WAS TAKEN FROM THE PIDGIN DEVELOPER WIKI#
# PLEASE VISIT http://developer.pidgin.im/ FOR MORE INFORMATION#
################################################################

def conky_im(account, sender, message, conversation, flags):
reg = '<(.|\n)+?>' # REGEX FOR HTML TAGS
message = re.sub(reg,'',message) # REMOVE HTML TAGS
sender = sender.split("@")[0] # GET GCHAT NAME
message = message[0:24] # LIMIT TO 25 CHARS
file = ' ' # LOCATION OF DATA FILE
fim = open(file,"w")
IM = sender + " said: " + message
fim.write(IM)
fim.close()

import dbus, gobject, re
from dbus.mainloop.glib import DBusGMainLoop
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SessionBus()

bus.add_signal_receiver(conky_im,
dbus_interface="im.pidgin.purple.PurpleInterface",
signal_name="ReceivedImMsg")

loop = gobject.MainLoop()
loop.run()



Copy and paste the following and save as lastim.py:
#!/usr/bin/python

# SHOW LAST IM
f=" " # REPLACE WITH YOUR DATA FILE. ie.CONKYIM.DAT
fim = open(f,'r')
im = fim.read()
print im
fim.close


Finally, add this to your .conkyrc script
${execi 1 python ~/scripts/lastim.py}

Any questions/comments let me know. Here is a screen shot of what my conky looks like:

Monday, August 11, 2008

Dear NBC, I run Linux

After seeing the amazing comeback by Jason Lezak in the 400 free relay last night, I was eager to watch it this morning and relive the experience. However, I was disappointed when I clicked on "play video" and was unwelcomed with:


I run linux and am very very happy with it, but there are times where I feel almost neglected because of the operating that I use. Who knows, maybe there could be some discrimination suit against them.

But seriously, can someone enlighten me as to how hard it would be for them to make it available on linux systems?

Monday, May 12, 2008

Batch Convert FLV to MP3

Many times on youtube I find concert videos or acoustic shows that I want to keep for later. Using the Firefox plugin VideoDownloader, I can download these videos as flv files but these flv's are not as portable as mp3. So I searched for a way to convert flv to mp3 and found help on the Ubuntu forums.

After looking at the script and looking at my flv files, I noticed that it would be very inefficient to do each file individually. Therefore, I modified the script to convert a whole folder of flv's. I will show the whole script itself and how to run it, but first lets install some programs that we need in order to convert the flv's.

sudo apt-get install ecasound mpg123 lame ffmpeg

The script itself is the following:
#!/bin/bash
# FLV to MP3
#flv2mp3.sh

FLV_FILE=/home/ditto/Videos/
cd $FLV_FILE

for vid in *.flv
do
ffmpeg -i $vid -f mp3 -vn -acodec copy /tmp/temp.mp3
ecasound -i /tmp/temp.mp3 -etf:8 -o ${vid/.flv}.mp3
rm -f /tmp/temp.mp3
done

exit 0

I save my scripts in a ~/scripts and don't forget to make the script executable.
chmod u+x flv2mp3.sh

Run as follows:
user@home:/scripts~$ ./flv2mp3


Let's take a closer look at the code.
FLV_FILE=/home/ditto/Videos/
cd $FLV_FILE


FLV_FILE is the location of the flv video files that we want to be converted. In the next line, the directory is changed to the location of the videos.

Next, we will look through the files in that directory, only using the .flv files. Notice:
for vid in *.flv
Next we will convert the video to mono audio and create a temporary mp3 called temp.mp3
ffmpeg -i $vid -f mp3 -vn -acodec copy /tmp/temp.mp3
Since the audio by default is mono, we will then convert it to stereo, output it into the current directory, and save it as an mp3, while keeping the basename. The file is renamed by ${vid/.flv}.mp3
ecasound -i /tmp/temp.mp3 -etf:8 -o ${vid/.flv}.mp3
rm -f /tmp/temp.mp3
That is pretty much it. Any comments or ways to make it better, please let me know.

Friday, May 9, 2008

Setting up Broadcom B43 Wireless with Ubuntu 8.04

After installing 8.04, I never had a chance to test wireless until now. I was always plugged the ethernet in under my desk. I notice one time at home that Fn-F2 was not enabling my wireless radio. I checked hardware drivers in System->Administration->Hardware Drivers. My Broadcom B43 wireless driver was in use but no enabled. When I clicked enable, it would install drivers and prompt for a restart. After a restart, it was again unchecked as enabled.

I looked on the ubuntu forums and google to see if anyone else was having problems. I found this tutorial but the last step was causing me trouble so I decided to modify it for you.

First, you can find out what Wireless Card you have by typing
lspci
Mine is:
Broadcom Corporation BCM4309 802.11a/b/g (rev 03)
I like to keep everything I download to install in a properly named "Installs" folder

So lets begin. This will allow us to build the driver

sudo apt-get install build-essential
Now make the Installs directory and download b43-fwcutter which will allow us to extract firmware for Broadcom driver
sudo mkdir ~/Installs
cd Installs
wget http://bu3sch.de/b43/fwcutter/b43-fwcutter-011.tar.bz2

Now we are going to extract and compile
tar xjf b43-fwcutter-011.tar.bz2
cd b43-fwcutter-011
make
export FIRMWARE_INSTALL_DIR="/lib/firmware"

Now we are ready for the firmware and to properly install it.
wget http://downloads.openwrt.org/sources/broadcom-wl-4.80.53.0.tar.bz2
tar xjf broadcom-wl-4.80.53.0.tar.bz2
sudo b43-fwcutter -w /lib/firmware broadcom-wl-4.80.53.0/kmod/wl_apsta.o
The output should look something like this:
This file is recognised as:
ID : FW11
filename : wl_apsta.o
version : 351.126
MD5 : 9207bc565c2fc9fa1591f6c7911d3fc0
Extracting b43/ucode4.fw
Extracting b43/ucode5.fw
Extracting b43/ucode11.fw
Extracting b43/ucode13.fw
Extracting b43/pcm4.fw
Extracting b43/pcm5.fw
Extracting b43/b0g0initvals4.fw
Extracting b43/b0g0bsinitvals4.fw
Extracting b43/a0g0initvals4.fw
Extracting b43/a0g0bsinitvals4.fw
Extracting b43/b0g0initvals5.fw
Extracting b43/b0g0bsinitvals5.fw
Extracting b43/a0g0initvals5.fw
Extracting b43/a0g1initvals5.fw
Extracting b43/a0g0bsinitvals5.fw
Extracting b43/a0g1bsinitvals5.fw
Extracting b43/lp0initvals13.fw
Extracting b43/lp0bsinitvals13.fw
Extracting b43/b0g0initvals13.fw
Extracting b43/b0g0bsinitvals13.fw
Extracting b43/a0g1initvals13.fw
Extracting b43/a0g1bsinitvals13.fw
After that, restart the computer and your radio should be working. Make sure, that in the BIOS, the wireless device is set to on/fn-f2. You can load BIOS by tapping F2 while the computer is turning on.

Tuesday, April 29, 2008

Hardy Heron Hottness

On April 24, Ubuntu 8.04 codename Hardy Heron was released. The 8 refers to the 2008 and 04 because its the fourth month of the calendar year.The installation was flawless and the only techie thing I did was make a /home partition so that I could save my home directory for future updates. I also wrote over my Windows partition, so there is no way I can use windows apps except through wine.

The installation continued with a couple of questions about username and password, timezone, and a few others. After I rebooted, I was immediately prompted with the option to enable restricted drivers for my ati video card and broadcom wireless. Then wireless and desktop effects worked like a charm. Of course you need to install advance settings.
sudo apt-get install compizconfig-settings-manager.
New with Hardy is a simple configuration gui which can be installed with:
sudo apt-get install simple-ccsm
Installed with Hardy is Firefox 3 beta 5 and also the default bittorrent client Transmission. Also, playing music has been a breeze except for of course protected m4p files. Restricted codecs can be installed by Aplications->Add/Remove then look under all available apps and type in 'restricted'.

So far, I have been using many of the default applications for my needs. Pidgin instead of Kopete, Transmisison instead of qbittorrent, Rhythmbox instead of Exaile. I haven't decide which email client to use, Thunderbird or the default Evolution. For now, I just keep gmail.com open on a tab in Firefox.

F-Spot is a program I wish I used before to organize my photos. It has a great import tool that will tag your pictures. Also, you can export directly to sites like Flickr and Facebook.

Linux is so much easier for me to use and its exciting to support open-source. Linux is no longer an alternative to Windows. It is my OS!

Download the torrent here

Update: I forgot to mention the awesome feature of Wubi which installs Ubuntu as a program on Windows. Perfect for anyone who is unsure about trying Ubuntu and does not want to mess with partitions or losing data. Pass it on!