We have moved to a new Sailfish OS Forum. Please start new discussions there.
1

Disable power button with mcetool

asked 2020-04-19 23:12:59 +0300

claustn gravatar image

Question:

Using mcetool (or anything else too!), is it possible to make Sailfish ignore the power button? Short press and long press. The only issue I see is the very long press used to reboot the device when stuck/freezed. Something similar to:

mcetool --set-volume-key-policy=default

Explanation:

I need some help to keep my nexus 5 alive. I already had the power button replaced one year ago, which was causing a boot loop. Since that day I rarely used that button, using instead the volume key to lock/unlock the screen. Combined with the sneak peek/LPM and double tap to unlock everything works quite well now.

Unfortunately it seems it is a crappy button, because now it starts to have the same problem without having used it much. Before it goes in a boot loop I would like to do something software wise, since the repair stores are closed and I don't have the tools to do it on my own.

Thanks to everyone in advance! Cheers

edit retag flag offensive close delete

Comments

hey take a look at coderus Powermenu, from storeman. I'm not 100% sure if possible, but in there you can remap the powerbutton, for both short-/long press and leave the function empty.

santeira ( 2020-04-20 00:53:58 +0300 )edit
1

How to simulate the power button press then? Using dbus? I'll have to check that the system ignores the power button without pressing it physically.

claustn ( 2020-04-20 13:40:32 +0300 )edit

1 Answer

Sort by » oldest newest most voted
3

answered 2020-04-20 19:12:12 +0300

spiiroin gravatar image

That "very long power key press to shutdown" is handled by dsme power key monitor plugin. There are no options / configuration entries related to it. But since the plugin does nothing else except watch over long power key presses, you can disable it altogether by renaming it to something that will be ignored - something like:

devel-su
cd /usr/lib/dsme
mv pwrkeymonitor.so pwrkeymonitor.so.disabled
systemctl restart dsme

Additionally you might configure e.g. one of the volume keys to function as power key for display blanking / unblanking purposes (to avoid needing to press the actual power key button that is prone to get stuck). Instructions / caveat info at: https://together.jolla.com/question/151086/intex-aqua-fish-power-key-broken-workaround/

edit flag offensive delete publish link more

Comments

1

Thanks! Yes, I am already using vol down to lock/unlock the screen. Do you also have a way to simulate the power key press and test the mod?

claustn ( 2020-04-20 22:26:31 +0300 )edit
1

@claustn Well, just pressing the power key and not having the device shutdown would be a simple test. But in case the power key button has also problems with correctly reporting long presses / just for the fun of it, you could also inject powerkey events into input device ... e.g.

Find out relevant input device

# device access requires root privileges
devel-su
# blank screen to avoid possible noise from sensor input devices etc
mcetool -n 
evdev_trace -t | head -4
(press power key)
/dev/input/event0: 1587450889.499 - 0x01/EV_KEY - 0x074/KEY_POWER - 1
/dev/input/event0: 1587450889.499 - 0x00/EV_SYN - 0x000/SYN_REPORT - 0
/dev/input/event0: 1587450889.626 - 0x01/EV_KEY - 0x074/KEY_POWER - 0
/dev/input/event0: 1587450889.626 - 0x00/EV_SYN - 0x000/SYN_REPORT - 0

-> /dev/input/event0 is what we want

Record such power key press + release sequence

dd bs=16 count=4 if=/dev/input/event0 of=press-and-release.dump
(press power key)
4+0 records in
4+0 records out
64 bytes (64B) copied, 2.898492 seconds, 22B/s

Simulate power key press that is long enough to trigger top menu

# turn display on
mcetool -U
# press - wait 3 secs - release
dd bs=16 count=2 if=press-and-release.dump of=/dev/input/event0 ; sleep 3 ; dd bs=16 skip=2 count=2 if=press-and-release.dump of=/dev/input/event0

If that works, simulate power key press without release

# turn display on
mcetool -U
# press - and leave pressed
dd bs=16 count=2 if=press-and-release.dump of=/dev/input/event0

With pwrkeymonitor.so plugin in place -> top menu pops up, followed by shutdown couple of seconds later.

With renamed pwrkeymonitor.so plugin -> top menu pops up but device should not shut down.

Caveat: Some devices can trigger reboot / cutting power without involving sw components on long enough power key press -> config/plugin modifications would not stop it from happening and simulated events would not trigger it.

spiiroin ( 2020-04-21 10:02:16 +0300 )edit
1

"Caveat: Some devices can trigger reboot / cutting power without involving sw components on long enough power key press -> config/plugin modifications would not stop it from happening and simulated events would not trigger it." I guess this is the real obstacle, if the button would be stuck in the pressed state there won't be any software trick that saves the phone from a boot loop. Thanks for the support, I learned something new!

claustn ( 2020-04-21 11:59:50 +0300 )edit
Login/Signup to Answer

Question tools

Follow
3 followers

Stats

Asked: 2020-04-19 23:12:59 +0300

Seen: 287 times

Last updated: Apr 20 '20