Manage Ubuntu via bluetooth

    A picture to attract attentionTo use your Nokia 5530 as a remote control for the computer I was using a wonderful program SmartTouch from KAIST 'a, but the server part for it only works with Windows, and I wanted to have also a version of Linux. Well, with the source code (SmartTouch distributed under the GPL), making ee for Ubuntu didn't seem like a big deal.

    Firstly, the server had to receive / send data via bluetooth, for which there was an excellent python-bluez module. It’s good also because it didn’t have to rewrite the code responsible for bluetooth for it.

    Secondly, the program was supposed to somehow report the appearance / disconnection of communication. The original server hangs in the tray and shows popups, but Canonical instructions ( 1 , 2 ,3 ) they do not recommend clogging up the tray with useless icons, so it was decided to use only libnotify messages, especially since there were excellent examples of using python-notify directly in the guidelines.
    So now the notification about connecting the device looks:
    Connection Notification

    Thirdly, it was necessary to somehow play the keyboard and mouse messages, for this the Gnome project has a PythonATSPI module . Using its functions pyatspi.Registry.generateKeyboardEvent and pyatspi.Registry.generateMouseEvent, this was not at all difficult to do.

    And finally, the client program sends directly key codes that are different from those on Linux. For the necessary actions, I had to code a code matching table: usingxmodmap -pk I got a list of the necessary codes, and then checked its operability with xev .

    Now the control panel is always at hand, regardless of the OS.

    As a bonus, a small and black video of work:

    You can download it here .
    Depends on: python-bluez, python-pyatspi, python-notify.

    Also popular now: