maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   SailfishOS (https://talk.maemo.org/forumdisplay.php?f=52)
-   -   [Announce] [SFOS] Volume/Camera Button Monitor (https://talk.maemo.org/showthread.php?t=100936)

wolke 2020-01-21 06:13

[Announce] [SFOS] Volume/Camera Button Monitor
 
so many years later, finally implemented a hardware button monitor for sailfish!

functionality is similar to n9-button-monitor.

you can use sf-button-monitor to run arbitrary commands while the phone is locked, or unlocked.

tested and working on Xperia X and Xperia X Compact, YMMV

NOTE: core functionality provided by simply reading from:
Code:

/dev/input/by-path/platform-gpio_keys.105-event
dependencies:
perl
dbus-send (for all CONDITIONS, and for all ACTIONS except cmd(SHELL_CMD))

the following unrelated hacks make this script more useful:
-dont unlock the screen when pressing volume/camera
-dont control media volume when screen is locked
-write window title to a file so window() condition can tell which program is running


https://github.com/teleshoes/sf-button-monitor

wolke 2020-01-21 06:16

Re: [Announce] [SFOS] Volume/Camera Button Monitor
 
ALSO: this script is only useful if you turn off display-unlock-with-volume/camera with mcetool:
Code:

mcetool --set-exception-length-volume=0
mcetool --set-exception-length-camera=0

and also if you modify lipstick to not modify media volume while screen is locked:
/usr/share/lipstick-jolla-home-qt5/volumecontrol/VolumeControl.qml
Code:

*** 473,478 ****
--- 473,481 ----
          }
          onVolumeChanged: restartHideTimerIfWindowVisibleAndWarningNotVisible()
          onVolumeKeyPressed: {
+            if (Lipstick.compositor.screenIsLocked) {
+              return
+            }
              if (keyRepeat.running || keyRepeatDelay.running) {
                  if (Lipstick.compositor.visible) {
                      screenshotTimer.restart()


Kabouik 2020-01-21 08:38

Re: [Announce] [SFOS] Volume/Camera Button Monitor
 
I'll be trying that soon on the Proš, it should be very useful, thanks!

Can this be used for events like the following (keyboard open/closed state)?

Code:

/dev/input/event2: 1579511420.010 - 0x05/EV_SW - 0x00a/SW_KEYPAD_SLIDE - 0
Code:

/dev/input/event2: 1579511420.010 - 0x05/EV_SW - 0x00a/SW_KEYPAD_SLIDE - 1

mosen 2020-01-21 10:04

Re: [Announce] [SFOS] Volume/Camera Button Monitor
 
Very Cool!
On Proš there are different files.

Code:

cat /dev/input/by-path/platform-c17a000.i2c-event-kbd
produces following output when hammering the harware kbd:
Code:

�&^S
�&^S
�&^��%�&^���&^�%�&^��&^��%�&^���&^B�%�&^B��&^�
                                              %�&^�
�&^����&^��^C^Z -�&^Z  �&^3C��&^3C�&^�7��&^�7�&^�v�&^

When i copy that path into your scripts $INPUT_DEV i get no output from your script however.

For kbd open/close, volume and powerbutton i get same formated values from

Code:

cat /dev/input/by-path/platform-soc\:gpio_keys-event
there is a 3rd file in that folder that i could not quench cat output from.
Code:

platform-1711a000.sound-tavil-event

wolke 2020-01-21 14:32

Re: [Announce] [SFOS] Volume/Camera Button Monitor
 
on x compact, SFOS 3.2.1.20, the key is in the 10th byte and the value (press/release) is in the 12th. (each key press/release produces 16 bytes)

just cat it to a file, press a single key, ctrl+c, and then read the bytes (with hexdump or something). do it 3x with the same key, and 3x with a different key and compare/contrast

mosen 2020-01-21 14:43

Re: [Announce] [SFOS] Volume/Camera Button Monitor
 
Will try. Thanks for the explanation!

But i have to correct, your script with adapted path to that of the Proš gives output on exactly one key of the hardware keyboard.

It is the w key on QWERTZ / q key on QWERTY that does that if pressed multiple times in a row:
Code:

EVENT: CAM_HALF => press              1239ms  (ch-press)
EVENT: CAM_HALF => release              87ms  (ch)
EVENT: CAM_HALF => press              197ms  (ch ch-press)
EVENT: CAM_HALF => release              86ms  (ch ch)
EVENT: CAM_HALF => press              148ms  (ch ch ch-press)
EVENT: CAM_HALF => release              62ms  (ch ch ch)
EVENT: CAM_HALF => press              119ms  (ch ch ch ch-press)
EVENT: CAM_HALF => release              61ms  (ch ch ch ch)
EVENT: CAM_HALF => press              103ms  (ch ch ch ch ch-press)
EVENT: CAM_HALF => release              81ms  (ch ch ch ch ch)
EVENT: CAM_HALF => press                94ms  (ch ch ch ch ch ch-press)
EVENT: CAM_HALF => release              76ms  (ch ch ch ch ch ch)
EVENT: CAM_HALF => press                99ms  (ch ch ch ch ch ch ch-press)
EVENT: CAM_HALF => release              89ms  (ch ch ch ch ch ch ch)

EDIT:
https://mosushi.de/misc/keyboard-single1.txt
Above link is cat > keyboard-single1.txt with only the "1" pressed once.

https://mosushi.de/misc/keyboard-3x1.txt
This is the cat > keyboard-3x1.txt if i press the "1" key three times followed by "2" key three times.
Trying to makes sense of the output, figure to still post it quick since you all are faster. lol.

wolke 2020-01-21 16:11

Re: [Announce] [SFOS] Volume/Camera Button Monitor
 
in that case: modify my script, adding this line after line 195:
print "$buttonId ($value)\n";

then run it, press those buttons you want to do, and then add lines around 112 like this:
Code:

  [qw(16  KEY_W kw)],

mosen 2020-01-21 17:02

Re: [Announce] [SFOS] Volume/Camera Button Monitor
 
Perfect, thank you.
Now i understand some more of the script.
I can print the assigned value to every key if i add them all in the block around line 115.

Specific to Proš:
"sym" is code 249.
"FX" is code 125.
"Yellow Mod" is code 100.
I guess the 100 is due to TheKits kernel mod to make it usable in sfos xkbd, right @kabouik?

wolke 2020-01-21 17:16

Re: [Announce] [SFOS] Volume/Camera Button Monitor
 
btw, if you get something cool working for you, please pull request your changes. i might not add them to master since i cannot test it in any way (i ONLY have xperias), but others might benefit from it, and i might buy an fxtec soon myself ;)

mosen 2020-01-21 17:42

Re: [Announce] [SFOS] Volume/Camera Button Monitor
 
Quote:

Originally Posted by wolke (Post 1564601)
btw, if you get something cool working for you, please pull request your changes. i might not add them to master since i cannot test it in any way (i ONLY have xperias), but others might benefit from it, and i might buy an fxtec soon myself ;)

Do you think it is possible to do a patchmanager3 patch from that script and execute code on Key events? Or is it a potential battery hog?

EDIT:
Now i have the script altered for gpio read out and found code 10 is the state of the Keyboard.
10 - release is opened
10 - pressed is closed

EDIT 2:
Now i am able to switch on the keyboard backlight when it opens with this action in sf-button-monitor.conf
Code:

action=cmd(echo 1 > /sys/class/leds/keyboard-backlight/brightness),kb,always
where "kb" is defined as following in the script:
Code:

  [qw(10  KBD_STATE kb)],
I have not quite figured out how to set the backlight back to 0 on kbd close. But that is done anyway when the display goes off.

EDIT 3:
I just created a .desktop file in /user/share/applications/ to start the script from app-grid.
Works for now :P


All times are GMT. The time now is 22:52.

vBulletin® Version 3.8.8