Schurger.org

1 août 2008

Copy X selection to Tomboy

Classé dans : Non classé — Jean Schurger @ 19:58

Put that code into a script, set a keybinding desktop wide, and tomboy notes will be created, containing your current X selection, simple, easy, and terribly  usefull ! (needs xsel)

#!/usr/bin/env python

import sys, dbus, dbus.glib
from datetime import datetime
from subprocess import Popen, PIPE

bus = dbus.SessionBus()
obj = bus.get_object("org.gnome.Tomboy", "/org/gnome/Tomboy/RemoteControl")
tomboy = dbus.Interface(obj, "org.gnome.Tomboy.RemoteControl")
p = Popen(args=["/usr/bin/xsel"], shell=False, stdout=PIPE)
p.wait()
sel = p.stdout.read()
if sel:
    now = datetime.now().ctime()
    new_note = tomboy.CreateNote()
    tomboy.SetNoteContents(new_note, "X %s\n\n%s" % (now, sel))
    tomboy.AddTagToNote(new_note, "X")

10 juillet 2008

Colemak

Classé dans : Non classé — Jean Schurger @ 4:09

"Apf jyl pfaij ragurtufs bj jylp clppfkg efjbyaps iajylg ^ ug maj bf ar y;gumuzfs ar jyl ghuke !"

This is the sort of thing you may write starting to use the Colemak layout.Why not trying it, here is its
description pasted from the original website : http://colemak.com :

"The QWERTY layout was designed in the 19th century to allow typewriter salesmen to easily type the word "typewriter" and to prevent typebars from sticking. We've been stuck with QWERTY ever since.
Colemak is a modern alternative to the QWERTY and Dvorak layouts. It is designed for efficient and ergonomic touch typing in English.
Learning Colemak is a one-time investment that will allow you to enjoy faster and pain-free typing for the rest of your life. Colemak is now the 3rd most popular keyboard layout for touch typing in English, after QWERTY and Dvorak."

And here is the complete layout build from the Gnome keyboard setting tool (available in hi resolution to print it and stick somewhere not far from you screen):

Colmak layout

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

Powered by WordPress