Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Script] Gestion de 2 cartes son (a completer :) )
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index French
View previous topic :: View next topic  
Author Message
mcfly.587
Tux's lil' helper
Tux's lil' helper


Joined: 29 Mar 2005
Posts: 118

PostPosted: Sun Oct 16, 2005 10:52 am    Post subject: [Script] Gestion de 2 cartes son (a completer :) ) Reply with quote

Bonjour à tous :)

Je possède 2 cartes son et malheureusement je ne suis pas parvenu à jouer le même son sur les 2 cartes en même temps.

Donc j'ai bidouillé un script qui permet de créer une icone dans la barre des tâches et qui permet de switcher les fichiers de configuration entre l'une au l'autre carte son en un simple clic. ( Lors de mes recherches je n'avais pas trouvé un moyen de déterminer la carte son maitre ou secondaire sans redémarrer alsa ou la session de mémoire ).

Le script fonctionne pour mplayer pour le moment et je vais essayer de le completer pour totem, xmms etc etc ...

Voila si çà peut interesser quelqu'un :

Code:

import os
path= "/"
import sys
print sys.path
from wxPython.wx import *


class MainWindow(wxFrame):

    TBMENU_SHOW = 1000
    TBMENU_HIDE = 1001
    TBMENU_TOGGLE = 1002
    TBMENU_EXIT = 1003
   
    def __init__(self, parent, id, title):
        wxFrame.__init__(self, parent, -1, title, size = (800, 600),
                         style=wxDEFAULT_FRAME_STYLE)

        # create tray icon and initialize it       
        self.tbicon = wxTaskBarIcon()
        self.status = 0
        self.updateIcon()

        # set up event handlers to catch tray icon events
        EVT_TASKBAR_LEFT_DCLICK(self.tbicon, self.restoreWindow)
        EVT_TASKBAR_RIGHT_UP(self.tbicon, self.showTaskBarMenu)

        # handlers for tray icon popup menu       
        EVT_MENU(self.tbicon, self.TBMENU_SHOW, self.restoreWindow)
        EVT_MENU(self.tbicon, self.TBMENU_HIDE, self.hideWindow)
        EVT_MENU(self.tbicon, self.TBMENU_TOGGLE, self.toggleIcon)
        EVT_MENU(self.tbicon, self.TBMENU_EXIT, self.exitApp)

        # handler for main window minimization       
        EVT_ICONIZE(self, self.onWindowMinimize)

        # start with main window showing
        self.Show(false)

    def __del__(self):
        # clean up taskbar icon
        del self.tbicon

    def updateIcon(self):
        # update icon based on current state
        if self.status == 0:
            self.tbicon.SetIcon(wxIcon('icon1.ico', wxBITMAP_TYPE_ICO), 'Icon Demo - state 1')
       os.system("rm /home/tux/.mplayer/config")
       os.system("cp /home/tux/.mplayer/configdsp /home/tux/.mplayer/config")
        else:
            self.tbicon.SetIcon(wxIcon('icon2.ico', wxBITMAP_TYPE_ICO), 'Icon Demo - state 2')
          os.system("rm /home/tux/.mplayer/config")
       os.system("cp /home/tux/.mplayer/configdsp1 /home/tux/.mplayer/config")

    def toggleIcon(self, event):
        # switch icon state
        self.status = not self.status
        self.updateIcon()

    def restoreWindow(self, event):
        # show/restore main window
        self.Show(true)
        self.Iconize(false)

    def hideWindow(self, event):
        # hide main window
        self.Iconize(true)

    def showTaskBarMenu(self, event):
        # create popup menu
        menu = wxMenu()

        # choose show/hide based on current window state       
        #if self.IsIconized():
        #    menu.Append(self.TBMENU_SHOW, '&Show Window')
        #else:
        #    menu.Append(self.TBMENU_HIDE, '&Hide Window')

        # these entries are always present         
        menu.Append(self.TBMENU_TOGGLE, '&Toggle Icon')
        menu.Append(self.TBMENU_EXIT, '&Exit')

        # pop up the menu       
        self.tbicon.PopupMenu(menu)
        menu.Destroy()
        wxGetApp().ProcessIdle()

    def exitApp(self, event):
        self.Close()

    def onWindowMinimize(self, event):
        # minimize
        self.Iconize(true)

        # hide taskbar button       
        self.Show(false)

class MyApp(wxApp):
    def OnInit(self):
        wxInitAllImageHandlers()
        frame = MainWindow(None, -1, 'Taskbar Icon Demo')
        return true

if __name__ == '__main__':
    app = MyApp(0)
    app.MainLoop()


Les 2 icones : http://users.skynet.be/fa082425/icones/icon.tar.gz

Pour mplayer copier le fichier /.mplayer/config en : configdsp et configdsp1
Rechercher la ligne : ao = oss:/dev/dsp ajouter un 1 dans configdsp1 ao = oss:/dev/dsp1

Voila si quelqu'un connait bien python si il pouvait nettoyer ce code çà serait bien car je ne connais pas grand chose la dedans ! ( il y a une fenêtre de base que je n'ai pas réussit a supprimer ).

EDIT: sous kde pas de problème, sous gnome soucis avec la fenêtre je pense.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index French All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum