OSS Start/Stop Script

November 4th, 2009, 5:37 pm

With Kernel 2.6.26.32-rc6 suspend-2-ram (aka sleep/standby) finally works on my machine! However OSSv4 does not support suspend/hibernate which means that OSS must be unloaded.

This scripts does the following:

In my case I have the script stop mpd. Then it kills ossxmix and attempts to unload oss. On spawn it starts mpd again and loads ossxmix.

Here it is:
oss_s.py

#!/usr/bin/env python

import subprocess
import sys
import os

#Daemons that need to be stopped
daemons=('mpd',)

#Programs that are safe to kill
kill_apps=('ossxmix','vlc','mplayer','xine','xmms','audacious',)

#Programs to load on spawn/resume
load_apps=('ossxmix -xb',)

#User to start apps as
user='pyther'

def start():
    p=subprocess.Popen(['soundon'])
    p.wait()    

    for d in daemons:
        p=subprocess.Popen(['/etc/rc.d/' + d, 'start'])
        p.wait()

    for a in load_apps:
        #Load the program as a user, not root
        os.system('sudo su -c \'' + a + ' &\' ' + user)

    return

def stop():
    for d in daemons:
        p=subprocess.Popen(['/etc/rc.d/' + d, 'stop'])
        p.wait()

    for a in kill_apps:
        p=subprocess.Popen(['killall',a])
        p.wait()

    o=subprocess.Popen(['soundoff'],stdout=subprocess.PIPE)
    output=o.stdout.readlines()

    list=[]

    for line in output:

        #If the line is empty skip it
        line = line.rstrip("\n")
        if line == '':
            pass
        #Otherwise lets split the line by spaces
        else:
            line=line.rsplit(' ')

            #Going to see if the first word is an int
            try:
                pid=int(line[0])
            except ValueError:
                #Must not be an int
                pass
            #Good it is an int... lets continue
            else:
                app=line[1] #The second word is the name of the app

                #If the list has no values, we will add the first running program
                if len(list) == 0:
                    list.append([pid,app])
                #Now lets check and see if the pid is already in the list
                else:
                    inList=0 #Set to False by default
                    #Scanning items already in the list
                    #If we find a match we set inList to True and break out of the loop
                    for x in list:
                        if int(x[0]) == int(pid):
                            inList=1
                            break
                    if not inList:
                        list.append([pid,app])

    if list:
        print("Apps that need to be killed:")
        for x in list:
            pid=x[0]
            app=x[1]

            subprocess.Popen(['notify-send', '-u', 'normal', '-i', 'audio-card', '-t', '120000', 'PID: ' + str(pid) + ' is using OSS', str(pid) + ' - ' + app + '\nPlease kill this application.' ])
            print("PID: " + str(pid) + " - " + app) 

            #Exit abnormally
            sys.exit(1)

    return

if __name__ == "__main__":
    if len(sys.argv) <= 1:
        print("Usage: start or stop")
        sys.exit(1)

    if os.geteuid() != 0:
        print "You must be root to run this script."
        sys.exit(1)

    if sys.argv[1] == "start":
        start()
    elif sys.argv[1] == "stop":
        stop()
    else:
        print "Usage: start or stop"

Usage is simple enough:
./oss_s.py start
./oss_s.py stop

Then to get the script to run on suspend/wake:
Save this as /etc/pm/sleep.d/48oss

#!/bin/bash

case $1 in
    hibernate)
        /home/pyther/bin/oss_s.py stop
    ;;
    suspend)
       /home/pyther/bin/oss_s.py stop
    ;;
    thaw)
        /home/pyther/bin/oss_s.py start
    ;;
    resume)
        /home/pyther/bin/oss_s.py start
    ;;
esac

Then make it executable
chmod +x /etc/pm/sleep.d/48oss

Of course you will have to modify the code as necessary.


Category: Code, Linux | Comment


PAL to NTSC

October 25th, 2009, 1:15 pm

I was asked to convert some European (PAL) dvds to the American (NTSC) format. With the help of a few linux tools, the process is pretty painless. A cautionary note: the process takes about 3 hours for one dvd using  my AMD X2 7750.

What you need:

First, we need to rip the DVD to the computer. We can do this by using dvdrip or vobcopy. Vobcoby is a simple command line utility that rips vob files straight from the dvd to the hard drive. dvdrip is a gui tool which is very easy to use. Load it up, create a new project, select the rip tab, and pick the title you want to rip. Ripping the dvd will probably take anywhere from 15-20 minutes.

Vobcopy Example: cd /home/pyther/dvdrip and vobcopy /dev/sr0

Next, we want demux (seperate) the audio and the video. ProjectX is very easy to use for this task and ProjectX insures the video and audio stay in sync.

To Demux the video:

This result in the following files being created:

If there are multiple audio tracks you will see zorro-001.ac3, zorro-001[1].ac3, zorro-001[2].ac3
In my case:

Lets clean up the directory right now:

Tags: , , , , ,
Category: Linux | Comment


Passed!

July 25th, 2009, 11:57 am

That’s right I passed the RHCT! Woot!


Category: Computers, Linux | 2 Comments »


RHCT Taken…

July 24th, 2009, 3:17 pm

Well  I got up this morning at 4:30am and headed of at 5:15am to Columbus, Ohio. The trip wasn’t bad, however the fog made it a bit harder. After 2hrs and 20 minutes in the car I made it. 1hr 30min early. I got breakfast, and looked over a few things.

The exam was fairly easy and took me about 1hr 30 minutes to complete. I got stuck on the last part of the exam which involved auto-mounting.

On my way home I stopped at Hardee’s, a great burger place!

We were instructed that we would be given an email letting us know if we passed or failed.

Tags: , , ,
Category: Linux | Comment


Evolution of the Arch Community

June 28th, 2009, 7:35 pm

I have been using Arch Linux since 2005. It is a great distro and there are a few devs that are still keeping it the Arch Way. For this I am grateful. However, the community has taken a change for the worse. When I first started using Arch if you asked a noob question you were given a man page or a google query. If you wanted to succeed with arch, you had to read up. I think this turned away a good amount of users, but that was the type of distro Arch was. Now the community is soft, we are willing to put up with people that have no clue what they are doing and that can’t survive on their own!

ataraxia summed it up very well:

“A part of me really misses those old days. We’re far too welcoming of people who don’t substantially get what The Arch Way is even about, or who just don’t agree with it. Arch hasn’t been materially harmed by the changes, but I think we’re overly patient in these forums nowadays with people that are just too inexperienced to succeed anyway, and even more so with BIGNUM practically-identical threads that could have been avoided by simply reading the last day’s posts (or even the front page news) before posting a new thread.”

Tags:
Category: Linux | Comment


02/16/2009

February 16th, 2009, 10:57 pm

2009-02-16

WM: Openbox
GTK: MurrinaGilouche
Wallpaper: Space
Tray: Stalonetray
Sidebar: Conky
Top Bar: Conky (mpd info + clock)


Category: Screenshots | Comment


12/14/2008

December 14th, 2008, 11:14 pm

2008-12-14

WM: Openbox
GTK: MurrinaGilouche
Wallpaper: Lambency Blue
Tray: Stalonetray
Sidebar: Conky
Top Bar: Conky (mpd info + clock)

Tags: , , , , , ,
Category: Screenshots | Comment


Xorg 7.4

November 16th, 2008, 8:13 pm

Xorg’s hotplugging is pretty cool. I installed it both on my desktop and laptop. I can unplug my mouse from my desktop and plug it into the laptop. Within a second or two it detects the mouse, and it supports all the fancy buttons (middle click, back/foward buttons).

Just simply amazing!!! Now I just can’t wait until the open ati driver becomes stable!

Tags: , , , ,
Category: Linux | 1 Comment »


11/08/2008

November 8th, 2008, 6:41 pm

2008-11-08

Openbox, Conky, Stalonetray

I decided to get rid of my panel and use the middle click window listing that conky uses, simply amazing!


Category: Screenshots | Comment


10/12/2008

October 12th, 2008, 8:36 pm

2008-10-12

Openbox, bmpanel: transpy, conky


Category: Screenshots | Comment