Xperia 10 iii: make Google assistant button a camera trigger

The latest version includes experimental sequential triggers. There is one caveat though, the initial trigger seq = 1; will always be executed. This is a flaw in the design. I intended to resolve this later by refactoring and maybe moving the project to Python instead of C. I only released it as is since I too am suffering from Bluetooth issues that require both bluetooth and bluebinder to be restarted.

Pressing the assist button twice really fast will launch seq = 1; and seq = 2; pressing it once will only launch seq = 1;

hereā€™s an example cfg for camera as seq = 1; and restarting the fingerprint service as seq = 2;

// Not recommended to run keymapper as root,
// Provide full correct-cmdline e.g /usr/bin/invoker -s -n -d 5 --type=silica-media,silica-qt5 -A -- /usr/bin/jolla-camera
// Otherwise the process will never die
// seq is the order of operation. If pressed once, then seq 1 will exec. If pressed twice very fast then seq 2 will exec after seq 1

name = "TEST CONFING";
keymap = {
        assist_button_1 = {
        	    seq = 1;
                proc = "Camera Starting...";
                trigger = 457;
                process_name = "/usr/bin/jolla-camera";
                cmd = "/usr/bin/invoker -s -n -d 5 --type=silica-media,silica-qt5 -A -- /usr/bin/jolla-camera";
        };
        assist_button_2 = {
        	    seq = 2;
                proc = "";
                trigger = 457;
                process_name = "";
                cmd = "systemctl restart sailfish-fpd";
        };
};

2 Likes

Hey,
this is awesome! Could you do a config for enabling /disabling screen rotation?
i dont know which one would be the best way, but maybe using the dconf method would be an option.
because i hate it when the screen just randomly rotates on me and i always have it turned off. Sometimes i need it tho. Then its always so fiddly to do it on the screen.

best case scenario imo would be if you could rotate the phone, doesnt matter. If you press the button, the screen rotates in the direction youre holding it in and then its disabled again.

is there maybe a way to read out the sensors for the orientation and then setting the dconf key accordingly?

I wouldnā€™t suggest disabling screen rotation/orientation. I would rather have it as dynamic or maybe something along the lines of your suggestion.

You can get the current orientation position using dbus-send --system --type=method_call --print-reply --dest=com.nokia.SensorService /SensorManager/orientationsensor local.OrientationSensor.orientation

It has 6 positions.

#1: speaker facing right, landscape
#2: speaker facing left, landscape
#3: speaker facing down, portrait
#4: speaker facing up, portrait
#5: screen is facing is down
#6: screen is facing up

You can create a script and simply call it from the config. Something likeā€¦

#!/bin/bash

OrientationSensorPosition="$(dbus-send --system --type=method_call --print-reply --dest=com.nokia.SensorService /SensorManager/orientationsensor local.OrientationSensor.orientation | awk '/uint32/{ print $2 }')"

if [[ "$OrientationSensorPosition" == 1 ]] || [[ $OrientationSensorPosition == 2 ]]; then
        dconf write /lipstick/orientationLock \'landscape\'
else
        dconf write /lipstick/orientationLock \'portrait\'

fi

Then in cfg:

name = "TEST CONFING";
keymap = {
        assist_button_1 = {
                seq = 1;
                proc = "";
                trigger = 457;
                process_name = "";
                cmd = "/home/defaultuser/orientationStateSwitcher.sh";
        };
};

Where orientationStateSwitcher.sh is the script. Dont forget to chmod it.

3 Likes

Thank you so much!
this works flawlessly!

1 Like

Has anyone been successful in making a systemd service out of keymapper -s /dev/input/event3 ?

This doesnā€™t work for me (on Xperia 10 III with 4.5.0.21).

With the default config (start camera) i launch: keymapper -s /dev/input/event3
After pressing the assistant button the response in shell is:

(uint32 26,)
1690508216ā€“1690508212ā€“0.000036
(uint32 27,)
Keymapper:Notification:Sent - Camera Startingā€¦
Keymapper:Excecuting:Command - /usr/bin/invoker -s -n -d 5 --type=silica-media,silica-qt5 -A ā€“ /usr/bin/jolla-camera, -1
invoker: error: XDG_RUNTIME_DIR is not defined.
invoker: error: XDG_RUNTIME_DIR is not defined.
invoker: error: XDG_RUNTIME_DIR is not defined.
invoker: warning: Launch failed, application specific booster is not available.
Keymapper:Command:Done - /usr/bin/invoker -s -n -d 5 --type=silica-media,silica-qt5 -A ā€“ /usr/bin/jolla-camera, -1

Also tried to use suggested config for flashlight, but pressing the button only gives:

(uint32 28,)
1690508591ā€“1690508584ā€“0.000097

And nothing happens. Maybe iā€™m doing something wrong, or is this not compatible with 4.5.0.21?

Iā€™m hoping to get this working, since i think this is a great idea and a promising project. Cheers.

If you just want the button working, you might consider the patched mce.

Thank you for the tip. Maybe iā€™ll look into that if this keymapper doesnā€™t work. :beers:

1 Like