Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Due to a bug in the kernel driver for the Apple Magic Trackpad, two finger right click doesn't work by default. However, you can fix the issue by running the following:

xinput set-prop $DEVICE_ID "Synaptics Click Action" 1 3 2

...where $DEVICE_ID is the device id given for the device in the output of xinput --list.

Due to the nature of the device (Bluetooth) it's not always connected. Can I run this fix script every time that xinput detects the device as connected?

share|improve this question
Did you find the answer to that? –  Mashimom Feb 28 '14 at 21:43

1 Answer 1

Here is a python script for monitoring all Bluetooth devices.

You could try running the scripts first. Then modify the command part with your own code, then autostart this script with your system. Refer to here and here for more infomation.

#!/usr/bin/env python

import sys
import signal
import logging
import dbus
import dbus.service
import dbus.mainloop.glib
import gobject

LOG_LEVEL = logging.INFO
#LOG_LEVEL = logging.DEBUG
LOG_FILE = "/dev/stdout"
#LOG_FILE = "/var/log/syslog"
LOG_FORMAT = "%(asctime)s %(levelname)s %(message)s"

def device_property_changed_cb(property_name, value, path, interface):
    device = dbus.Interface(bus.get_object("org.bluez", path), "org.bluez.Device")
    properties = device.GetProperties()

    if (property_name == "Connected"):
        action = "connected" if value else "disconnected"
# Replace with your code to write to the PiFace
        print("The device %s [%s] is %s " % (properties["Alias"], properties["Address"], action))

def shutdown(signum, frame):

if __name__ == "__main__":
    # shut down on a TERM signal
    signal.signal(signal.SIGTERM, shutdown)

    # start logging
    logging.basicConfig(filename=LOG_FILE, format=LOG_FORMAT, level=LOG_LEVEL)
    logging.info("Starting btminder to monitor Bluetooth connections")

    # Get the system bus
        bus = dbus.SystemBus()
    except Exception as ex:
        logging.error("Unable to get the system dbus: '{0}'. Exiting btminder. Is dbus running?".format(ex.message))

    # listen for signals on the Bluez bus
    bus.add_signal_receiver(device_property_changed_cb, bus_name="org.bluez", signal_name="PropertyChanged",
            dbus_interface="org.bluez.Device", path_keyword="path", interface_keyword="interface")

        mainloop = gobject.MainLoop()
    except KeyboardInterrupt:
        logging.error("Unable to run the gobject main loop")

    logging.info("Shutting down btminder")
share|improve this answer
And where is the answer? –  A.B. 7 hours ago

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.