Xperia 10 iii: make Google assistant button a camera trigger

About Lipstick, you can see it listens for that event on the mce dbus, you probably can copy that code somewhere else to do more things (but need to disable the original handler).

2 Likes

EDIT: I managed to make it work as mpris PlayPause by making this simple patch:

--- /usr/share/lipstick-jolla-home-qt5/compositor.qml	2022-08-06 22:26:20.000000000 +0200
+++ /usr/share/lipstick-jolla-home-qt5/compositor.qml	2022-08-06 22:48:32.000000000 +0200
@@ -21,6 +21,7 @@
 import Sailfish.Silica.private 1.0
 import Sailfish.Lipstick 1.0
 import com.jolla.lipstick 0.1
+import org.nemomobile.mpris 1.0
 
 import "layers"
 import "launcher"
@@ -310,6 +311,8 @@
             alarmLayerItem.parent = alarmApplicationForeground
         }
     }
+    
+    MprisManager { id: mprisManager }
 
     FileWatcher {
         id: initDoneFile
@@ -1761,7 +1764,7 @@
                 root.showUnlockScreen()
             } else if (argument === "home-key") {
                 if (!root.systemGesturesDisabled) {
-                    root.goToSwitcher(true)
+                  mprisManager.playPause() //  root.goToSwitcher(true)
                 }
             }
         }

Hurray!

One sad thing, though, is that the button is no longer read when the phone goes to sleep. So it takes waking up the device (e.g. by pressing one of the remaining buttons or using the fingerprint sensor) in order to use it. Which kind of contradicts its purpose.

Iā€™d say that in this case Jolla is trying to save power not where they should. How much power draw can be saved by disabling button click monitoring? Microamperes?

3 Likes

Just had another idea how to use that.

As we have the Guest user function, make the button switch that account on long press.

That would enable you to hand the phone to someone, and sneakily hold that button while doing so.

They will have a functional but empty environment to examine, even though they just saw you using it. Magic!

I call it the Secret Agent Magic button, SAM.

6 Likes

Do you know what other arguments nokia.com.mce.signal provides? Compositor.qml uses ā€œhome-keyā€ and ā€œdouble-power-keyā€. So maybe thereā€™s more, e.g. ā€œdouble-home-keyā€, or some ā€œlong-press-home-keyā€ā€¦

If someoneā€™s interested, the following is a patch to use that button as flashlight toggle. Iā€™ve also added some vibration effect when the button is pressed. Same restrictions apply as above, i.e. when the phone goes to sleep the button becomes inactive, so you need to wake the the device up first.

--- a/usr/share/lipstick-jolla-home-qt5/compositor.qml	Sun Aug  7 21:53:14 2022
+++ b/usr/share/lipstick-jolla-home-qt5/compositor.qml	Sun Aug  7 23:00:04 2022
@@ -21,6 +21,7 @@
 import Sailfish.Silica.private 1.0
 import Sailfish.Lipstick 1.0
 import com.jolla.lipstick 0.1
+import QtFeedback 5.0
 
 import "layers"
 import "launcher"
@@ -310,6 +311,11 @@
             alarmLayerItem.parent = alarmApplicationForeground
         }
     }
+    
+    ThemeEffect {
+      id: vibraEffect
+      effect: ThemeEffect.PressWeak
+    }
 
     FileWatcher {
         id: initDoneFile
@@ -1738,6 +1744,13 @@
             root.PeekFilter.keyboardHeight = keyboardHeight
         }
     }
+    
+    NemoDBus.DBusInterface {
+        id: flashlightInterface
+        iface: "com.jolla.settings.system.flashlight"
+        service: "com.jolla.settings.system.flashlight"
+        path: "/com/jolla/settings/system/flashlight"
+    }
 
     NemoDBus.DBusInterface {
         bus: NemoDBus.DBus.SystemBus
@@ -1761,7 +1774,8 @@
                 root.showUnlockScreen()
             } else if (argument === "home-key") {
                 if (!root.systemGesturesDisabled) {
-                    root.goToSwitcher(true)
+                   vibraEffect.play()
+                   flashlightInterface.call("toggleFlashlight", undefined)
                 }
             }
         }
4 Likes

@nephros The .72 OS update contains a new version of mce. Would it be possible for you please patch this new version for support of the 10 IIIā€™s third button, and share the resulting RPM with me? I do not have a build.merproject.org account to build it myself and currently no access to the computer with build toolsā€¦ So Iā€™d be extremely grateful for you help in this regardā€¦

1 Like

Done! :slight_smile:

I repeat my warning to any readers though:

https://build.merproject.org/package/show/home:nephros:sailfishos/mce

FAT WARNING: this is a crucial system package. Do NOT just download an RPM from a random dude on a forum and install it.

2 Likes

What is the easiest way to apply such patch? Apart from editing manually or using patch command? Could we use patchmanager for it?

Done, too! :slight_smile:
Iā€™ve got that button working again and Iā€™m happy as hell! Thank you so much @nephros!

Itā€™s a binary, so after patching the sources you need to compile itā€¦

No, I know the MCE is a binary and I need to install it. But then you need to patch compositor.qml for the desired function. And is the only way to manually edit it, or use patch, or could we somehow use patchmanager?

1 Like

If someone upload it to online catalog then yes.
Here you have instructions how to do it GitHub - sailfishos-patches/patchmanager: Patchmanager for SailfishOS

I do use Patchmanager for that. My patch (to make that button work as flashlight toggle) is as follows:

--- a/usr/share/lipstick-jolla-home-qt5/compositor.qml	Sun Aug  7 21:53:14 2022
+++ b/usr/share/lipstick-jolla-home-qt5/compositor.qml	Sun Aug  7 23:00:04 2022
@@ -21,6 +21,7 @@
 import Sailfish.Silica.private 1.0
 import Sailfish.Lipstick 1.0
 import com.jolla.lipstick 0.1
+import QtFeedback 5.0
 
 import "layers"
 import "launcher"
@@ -310,6 +311,11 @@
             alarmLayerItem.parent = alarmApplicationForeground
         }
     }
+    
+    ThemeEffect {
+      id: vibraEffect
+      effect: ThemeEffect.PressWeak
+    }
 
     FileWatcher {
         id: initDoneFile
@@ -1738,6 +1744,13 @@
             root.PeekFilter.keyboardHeight = keyboardHeight
         }
     }
+    
+    NemoDBus.DBusInterface {
+        id: flashlightInterface
+        iface: "com.jolla.settings.system.flashlight"
+        service: "com.jolla.settings.system.flashlight"
+        path: "/com/jolla/settings/system/flashlight"
+    }
 
     NemoDBus.DBusInterface {
         bus: NemoDBus.DBus.SystemBus
@@ -1761,7 +1774,8 @@
                 root.showUnlockScreen()
             } else if (argument === "home-key") {
                 if (!root.systemGesturesDisabled) {
-                    root.goToSwitcher(true)
+                   vibraEffect.play()
+                   flashlightInterface.call("toggleFlashlight", undefined)
                 }
             }
         }
2 Likes

Couldnā€™t make patchmanager approach work, but I just used patch and it worked! Such a cool feature, hope Jolla will introduce it at some point!

An alternative way to achieve this is to write a service for it. Basically something that listens for EV_KEY codes and values and then runs a command if a condition is met. I am currently using Keymapper which I wrote for the pro1. I dont recommend it since youā€™ll need to build libconfig locally and it works on a holder and trigger principle which is usefull if you have a keyboard. Meaning that for any given trigger(ev_code) to function, a holder(ev_code) needs to be registered. For example, the volume down button as the holder(114) needs to pressed, then the assist button as the trigger(457) is pressed to run a command defined in the config file.
I am slowly easing my back to community after a long absence; I might rework this as a stand alone application/service for the 10 III.

6 Likes

Hello Iā€™ve only been using Sailfish for a few days and one thing is the biggest flaw that bothers me. (I switched from the previous Xperia XZ1c directly to the 10 III with Sailfish)

I noticed that button on side of phone is not used on Sailfish.

Is it possible to make it work like on older Xperias (with android) as a camera button, so it launches camera ready to take a photo (even if phone is lockedā€¦)?

Lightning fast photo taking without having to unlock first, open the camera, is really the best feature on xperia phones.

2 Likes

You can launch the camera direcrtly from the lock screen by swiping up down.

3 Likes

Is there easy way to get that flashlight code installed? I read the whole thread but I have no idea where to start after installing the patch manager. There is nothing ready related to this in the ā€œweb catalogā€.

Before the patchmanager part, youā€™d first need to build (or download from @nephros) and install patched mce binary replacing the original /usr/sbin/mce executable (lacking support for that button) with the one patched by @nephros. Only then the patchmanager part can do anything.

The patched mce is here: Show home:nephros:sailfishos / mce - SailfishOS Open Build Service

Then, for the patchmanager part, youā€™d need to copy the patch code I posted earlier in this thread to a file called unified_diff.patch and then create another file called patch.json with the following content:

{"description": "Maps Xperia 10 III's Google Assistant button (unused in SFOS) to Flashlight toggle", "name": "Google Button as Flashlight", "display_name": "Google Button as Flashlight", "category": "other", "author": "whoever", "version": "1.0.0", "compatible": ["4.4.0.72"]}

then create a folder called e.g. google_button_flashlight in /usr/share/patchmanager/patches/ and copy both unified_diff.patch and patch.json files there. After that the patch should be visible in Patchmanagerā€¦

I canā€™t submit it to the Patchmanagerā€™s web catalog for easy installation, because without the mce part it wouldnā€™t work anyway.

1 Like

Iā€™m sorry everyone, but I have taken down the downloadable RPMs.

As mentioned above, this modification is potentially dangerous, and if you want it, you must build the package yourself. I realize that is a nuisance, but I do not want to take responsibility for things that break when people do not heed warnings.

All the things you need are there in the OBS repository (i.e. the patch itself, source tarball and .spec file).

All those years studiously ignoring the winblows button only to witness the coming of the google button. Sigh.

5 Likes