Xperia 10 iii: make Google assistant button a camera trigger

Not sure it’s worth the time to lower the size by 300 kB, but if you know how to feel free to create a pull request.

The problem is that for now I actually don’t know how to :wink: as I am totally not familiar with all these online tools. Anyway, the non-stripped binary seems to work perfectly fine, so maybe indeed it’s not worth the hassle…

As mentioned above, there is a PR, and some discussion has happened, and the groundwork of a solution has been laid.

That solution does not need/use MCE, and it can be done on a running device by editing and replacing three files.

After that you have a Camera button, like proposed in the original post.

2 Likes

UPDATE 2: Added process_name in cfg to handle a pid check to avoid duplicate processes from running. Requires correct cmdline; cfg updated below.

UPDATE: Fixed issue where command will launch immediately after closing if the button was pressed. requires full cmdline.

Here’s a ‘test’ solution that doesn’t require having a holder and could be run as an independent service: GitHub - Logic-gate/Keymapper at testing. You will need to build libconfig yourself.

Demo: One Time File

Assist button config; keymap.conf
command; keymapper -s /dev/input/event3

// 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

name = "TEST CONFING";
keymap = {
        assist_button = {
                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";
        };
};
2 Likes

Here’s an arch64 build of libconfig: 295.8 KB folder on MEGA I am just waiting for @pamoedo to respond before pushing it openrepos.

2 Likes

Here’s the official package: Keymapper | OpenRepos.net — Community Repository System.
Libconfig has also been added to openrepos here: libconfig – C/C++ Configuration File Library | OpenRepos.net — Community Repository System

3 Likes

It works
By the way, how to start flashlight with the button?

You could try something like this

// 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

name = "TEST CONFING";
keymap = {
        assist_button = {
                proc = "";
                trigger = 457;
                process_name = ""
                cmd = "dbus-send --type=method_call --print-reply --dest=com.jolla.settings.system.flashlight /com/jolla/settings/system/flashlight com.jolla.settings.system.flashlight.toggleFlashlight";
        };
};

Keep in mind that you need to state the process_name if you want to launch applications; the example I used with camera has /usr/bin/jolla-camera as the process_name yet the actual command to run is from .desktop. The reason being that we want to block duplicate processes from starting based on the process_name. As for dbus-calls I am not entirely sure.

2 Likes

Nice!!
Also would be good to have systemd .service file ready to enable.

Yeah. I just wanted more people to test it first. I also thought of adding some sort of gui to set the config.

btw, an idea - react to multiple (e.g. 3) subsequent presses in 2-3 seconds (kind of 2nd function for the button)

PS I imagine lots of people would want to have it binded to fingerprint daemon restart.

Time and sequential based triggers are already in TODO :slightly_smiling_face:

1 Like

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