Schurger.org

12 juin 2008

HOWTO know if your laptop screen is closed or open ? the desktop way (in python)

Classé dans : Code, Python — Jean Schurger @ 3:08
#!/usr/bin/python

import dbus
import dbus.glib
import sys

class LidSwitch(object):
    def __init__(self):

        bus = dbus.SystemBus ()
        hal_obj = bus.get_object ('org.freedesktop.Hal',
                                  '/org/freedesktop/Hal/Manager')
        hal = dbus.Interface (hal_obj, 'org.freedesktop.Hal.Manager')
        udis = hal.FindDeviceByCapability ('input.switch')

        for udi in udis:
            dev_obj = bus.get_object ('org.freedesktop.Hal', udi)
            dev = dbus.Interface (dev_obj, 'org.freedesktop.Hal.Device')
            if dev.GetProperty ('button.type') == "lid":
                self._lid_dev = dev

    def _is_closed(self):
        if hasattr(self, "_lid_dev"):
            return self._lid_dev.GetProperty ('button.state.value')
        else:
            raise ValueError("no lid switch found")

    is_closed = property(_is_closed)

if __name__ == "__main__":
    ls = LidSwitch()
    print "Lid switch is %s" % (ls.is_closed and "closed" or "open")

29 mai 2008

Setup usefull key bindings for metacity with python

Classé dans : Code, Python — Jean Schurger @ 3:51

 As you will read the following script configure metacity to let you move your windows to the edges of your screen pressing the keys <Alt> + <Shift> + <the direction key of your choice>

Also it bind <Ctrl> + <Shift> + Up and <Ctrl> + <Shift> + Right to respectivly toggle vertical and horizontal window maximization.

#!/usr/bin/python

from gconf import Client

bindings = dict(
    move_to_side_e='<Alt><Shift>Right',
    move_to_side_w= '<Alt><Shift>Left',
    move_to_side_s= '<Alt><Shift>Down',
    move_to_side_n= '<Alt><Shift>Up',
    maximize_vertically= '<Ctrl><Shift>Up',
    maximize_horizontally= '<Ctrl><Shift>Right')

root = "/apps/metacity/window_keybindings"
c = Client()
for key in bindings.keys():
    c.set_value("%s/%s" % (root, key),
                bindings[key])

28 mai 2008

get X idle time with python

Classé dans : Code — Jean Schurger @ 20:46
#!/usr/bin/python

import ctypes, os

class XScreenSaverInfo(ctypes.Structure):
    """ typedef struct { ... } XScreenSaverInfo; """
    _fields_ = [('window',      ctypes.c_ulong), # screen saver window
                ('state',       ctypes.c_int),   # off,on,disabled
                ('kind',        ctypes.c_int),   # blanked,internal,external
                ('since',       ctypes.c_ulong), # milliseconds
                ('idle',        ctypes.c_ulong), # milliseconds
                ('event_mask',  ctypes.c_ulong)] # events

class XScreenSaverSession(object):
    def __init__( self):
        self.xlib = ctypes.cdll.LoadLibrary( 'libX11.so')
        self.dpy = self.xlib.XOpenDisplay( os.environ['DISPLAY'])
        if not self.dpy:
            raise Exception('Cannot open display')
        self.root = self.xlib.XDefaultRootWindow( self.dpy)
        self.xss = ctypes.cdll.LoadLibrary( 'libXss.so.1')
        self.xss.XScreenSaverAllocInfo.restype = ctypes.POINTER(XScreenSaverInfo)
        self.xss_info = self.xss.XScreenSaverAllocInfo()

    def get_idle( self):
        self.xss.XScreenSaverQueryInfo( self.dpy, self.root, self.xss_info)
        return self.xss_info.contents.idle / 1000

if __name__ == "__main__":
    s = XScreenSaverSession()
    print s.get_idle()

10 avril 2008

et voilà, je suis arrivé !

Classé dans : Non classé — Jean Schurger @ 17:02

19 mars 2008

another HP calculator emulator packaged : free42

Classé dans : Calculatrices, Ubuntu — Jean Schurger @ 16:52

Free42 

Packages for hardy are available in my repository.

The package contain only the Gtk+ version, and no "décimal" mode, only RPN.

Here is a screenshot :

Free42

13 mars 2008

Packages for nonpareil

Classé dans : Calculatrices, Ubuntu — Jean Schurger @ 11:48

I've build packages for nonpareil, it's an microcode-level simulator for electronic calculators.That mean that it let you have the folowing calculators working on your desktop :

HP 11C Scientific Calculator
HP 12C Financial Calculator
HP 15C Scientific Calculator
HP 16C Computer Scientist Calculator
HP 21 Scientific Calculator
HP 25 Programmable Scientific Calculator
HP 32E Scientific Calculator
HP 33C Programmable Scientific Calculator
HP 34C Programmable Scientific Calculator
HP 35 Scientific Calculator
HP 37E Financial Calculator
HP 38C Programmable Financial Calculator
HP 38E Programmable Financial Calculator
HP 41CV Programmable Scientific Calculator
HP 41CX Programmable Scientific Calculator
HP 45 Advanced Scientific Calculator
HP 55 Programmable Scientific Calculator
HP 80 Business Calculator

you can see The Museum of HP Calculator to have more information about these models.

Here is a screenshot of the HP 16C

HP 16C Emulator

18 janvier 2008

GemPC400 (GPR400) Smartcards reader works again under linux

Classé dans : Drivers, Smartcards, Ubuntu — Jean Schurger @ 13:21

I've made a new version of the old gpr400 (gempc400) Gemplus (Gemalco) card reader driver.
It's based on the work of Henryz PLötz, but modified to run with recent kernels (> 2.6.13).
It seems to work fine with the 2.6.24 kernel.
I've rebuild the ifd-handler what work with too.

The sources and ubuntu packages are available here : http://wazoo.schurger.org/gpr400/

20 juin 2007

x48 usage / comment utiliser x48

Classé dans : Calculatrices, Howto — Jean Schurger @ 10:51

If you’ve installed x48 (the HP48 emulator), here is a quick guide how to make it works.

If you start it from a terminal from the first time, you’ll see that x48 needs roms to works.

These roms are availables on the Berlios project page of x48 :

for the GX version of the calculator, it’s here : http://download.berlios.de/x48/x48-gxrom-r.tar.gz

for the SX version of the calculator, it’s here : http://download.berlios.de/x48/x48-sxrom-e.tar.gz

Just extract the .hp48 directory of one of theses archives in you $HOME directory, and x48 will work.

HP48 Emulator

Packages for feisty availables

Classé dans : Ubuntu — Jean Schurger @ 10:41

I’ve rebuild my packages for feisty : Here

There is packages for

  • aseqview (updated with the version 0.2.8),
  • my nice soft “multi-backgrounds-daemon” that had no code change since 2003 ! and always works)
  • x48

the source line for your ubuntu is

deb http://schurger.org/feisty ./

enjoy.

19 juin 2007

CDImage.ape CDImage.ape.cue

Classé dans : Audio — Jean Schurger @ 10:23

Que faire avec ça (sous linux).

Comme son nom l’indique, le format APE sert à compresser de la musique de singe.

Il sagit d’une compression non destructrice à l’instar de ZIP ou RAR pour les données, mais

la méthode à sans doute été conçue pour facilité la lecture, et le format doit pouvoir contenir des tags.

Plus d’informations sur cette technologie ici : http://www.monkeysaudio.com/

Mais, sous linux, qu’en faire ?

Je suis sur que des codecs existent pour vos lecteur favoris, je vais juste présenter deux programmes permettant d’extraire les morceaux de musique d’un fichier .ape accompagné de son .cue

Le premier est mac il permet de décompresser le fichier CDImage.ape en fichier WAV.

Il est disponible sur le site http://www.rarewares.org/

Mac s’utilise en ligne de commande (à partir d’un terminal), pour décompresser de la façon suivante.


$ mac CDImage.ape CDImage.wav -d


Decompressing…
Progress: 63.2% (54.0 seconds remaining, 92.6 seconds total)

Progress: 100.0% (0.0 seconds remaining, 143.5 seconds total)
Success…

d’autre fonctionnalités sont disponible et documentées en invoquant mac sans paramètre.

Le second est bchunk il permet de décompresser le fichier CDImage.ape en fichier WAV.

Il est disponible sur le site http://he.fi/bchunk (aussi packagé ubuntu sous le nom bchunk dans le dépôt universe)

Mac s’utilise en ligne de commande (à partir d’un terminal), pour décompresser de la façon suivante.

$ bchunk -w CDImage.wav CDImage.ape.cue morceau-

binchunker for Unix, version 1.2.0 by Heikki Hannikainen
Created with the kind help of Bob Marietta ,
partly based on his Pascal (Delphi) implementation.
Support for MODE2/2352 ISO tracks thanks to input from
Godmar Back , Colas Nahaboo
and Matthew Green .
Released under the GNU GPL, version 2 or later (at your option).

Reading the CUE file:

Track 1: AUDIO 01 00:00:00
.
.
.
Track 8: AUDIO 01 33:39:00

Writing tracks:

1: morceau-01.wav 36/36 MB [********************] 100 %
.
.
.
8: morceau-08.wav 28/28 MB [********************] 100 %

Et voila, plein de petits wav qui n’attendent que d’être gravés ou convertis en autre chose.

Powered by WordPress