maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Nokia N9 / N950 (https://talk.maemo.org/forumdisplay.php?f=51)
-   -   [Anounce] [N9] Volume/Power Button Monitor (https://talk.maemo.org/showthread.php?t=82538)

thedead1440 2012-10-20 18:26

Re: [Anounce] [N9] Volume/Power Button Monitor
 
Quote:

Originally Posted by wolke (Post 1283064)
quiksnap like take a picture with the camera from the lockscreen. like when the cat is being cute.

for screenshot, we could do long-click of volume down, but be aware that your phone would go into silent mode while we did...because of the problem#1 in the post above

i vote for both :D

The silent mode is a small price for the ease of access...

wolke 2012-10-20 18:31

Re: [Anounce] [N9] Volume/Power Button Monitor
 
Quote:

Originally Posted by thedead1440 (Post 1283067)
i vote for both :D

The silent mode is a small price for the ease of access...

im afraid i cant quite agree. i personally only use n9-button-monitor on the standby screen and specific apps where i can cancel the vol+/- button actions like FBReader.

the fact that the buttons also changes the profile {or the volume, or the camera zoom, or whatever weird fit takes their fancy} is a large detriment to n9bm's usability elsewhere.


you can do the screenshot bit yourself, btw, with n9-button-monitor as it stands.

make a script that will take a screenshot, and add an action with "cmd(that-script.sh)" and no condition, et voila

flopjoke 2012-10-20 18:45

Re: [Anounce] [N9] Volume/Power Button Monitor
 
My phone is always on silent anyway, so I'm not bothered by that..

But maybe to get past that, can we have two button presses at the same time? Like I said before - press volume up and down together to take screenshot. Or Press up and then down in rapid succession, so if your phone was in silent, it'll go to beep, then back to silent again and there will be no change. Is it possible to detect that by the button monitor?

HtheB 2012-10-20 18:49

Re: [Anounce] [N9] Volume/Power Button Monitor
 
Quote:

Originally Posted by wolke (Post 1283062)
lolololollololololololololololololol win98

htheb, youre aware of the two obstacles right?
1) we have to cancel ALL default actions in ALL apps. i dont know if this is possible without touching the apps themselves, which are mostly closed. {this needs to still let n9-button-monitor receive the events; disabling the buttons completely wont solve it, of course}
2) {and i HALF solved this one} we have to be able to programmatically control the volume. i can only do this with a mafw application running in the background, which i may be able to do as a daemon


solicit someone who has some experience with the mostly-closed-source guts of harmattan to do #1 for us, and i will deliver you your application. i personally cant fathom how to accomplish #1, and i spent awhile banging my head.

Yeah, the plan was to make some deamon running in the background to make the volume buttons work as media volume buttons. I haven't heard anything from it anymore, thats why im still waiting for it :)

make this and ull get your 3th donation ;)

wolke 2012-10-21 05:54

Re: [Anounce] [N9] Volume/Power Button Monitor
 
htheb
heh. actually thats the easy part, and i could get that working fairly easily.
the HARD part is in stopping the default actions like profile change and camera zoom. without THAT, a volume-change-key-daemon would obviously be useless.

flopjoke
actually, it USED to work like that, so that you could define arbitrary button press patterns, like "UpPress, DownPress, DownRelease, UpRelease".
everyone told me that the patterns were ridiculous, confusing to describe, hard to press, and fairly useless. they were quite right.


what you can do instead is simply bind the screenshot button to double-press up, and then double-press down on your own to compensate. or vice-versa, depending on whether you like silent mode on more often or not.

{what im describing here is still perfectly do-able without any change to n9bm}

wolke 2012-11-07 16:25

Re: [Anounce] [N9] Volume/Power Button Monitor
 
so i dont have an n9 anymore thanks to hurricane sandy.

turns out an empty condition is a parse error, so i did need to add a condition to support the feature flopjoke wanted. i added the screenshot action while i was there for convenience, with flopjoke compiling and testing it for me.

new version 0.4.5

1) condition=always
2) action=screenShot

note that the screen shot is always in portrait mode, like screenshotmee. screenshotmee lets you rotate the pic afterwards in a gui. n9bm just makes the file and lets you do what you want with it.

thedead1440 2012-11-07 18:44

Re: [Anounce] [N9] Volume/Power Button Monitor
 
wolke,

So you have now lost 2 n9s? :p

wolke 2012-11-07 20:35

Re: [Anounce] [N9] Volume/Power Button Monitor
 
oh, i see youve heard the phrase 'rubbing it in' and are a fan of it!

wolke 2013-01-06 18:30

Re: [Anounce] [N9] Volume/Power Button Monitor
 
im adding a dbus listener to get bluetooth speaker buttons.

i just finished testing a standalone python script. if anyone has a bluetooth thingie with media buttons, i would appreciate your testing this out.

i have a hipe shower speaker, and mine does this silly thing where it occasionally sends button clicks 8 times from a single click. im especially curious to know whether this is my fault, hipe's, or nokia's.

wolke 2013-01-06 18:34

Re: [Anounce] [N9] Volume/Power Button Monitor
 
heres the python script. you have to install some stuff.

apt-get install python-dbus python-pyside.qtcore


name it dbusbtn.py. copy it to MyDocs and run it like this:

Code:

user:~$ python /home/user/MyDocs/dbusbtn.py
button: previous-song
  ignored: previous-song
  ignored: previous-song
  ignored: previous-song
  ignored: previous-song
  ignored: previous-song
  ignored: previous-song
  ignored: previous-song
button: next-song
button: play-cd
button: stop-cd


Code:

#!/usr/bin/python
#N9 Button Monitor
#Copyright 2012 Elliot Wolk
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

import sys
import time
import signal
from traceback import print_exc
 
import dbus
from dbus.mainloop.glib import DBusGMainLoop
from PySide.QtCore import QCoreApplication

signal.signal(signal.SIGINT, signal.SIG_DFL)
dbus_service="org.freedesktop.Hal"
dbus_path="/org/freedesktop/Hal/devices/computer_logicaldev_input_0"
dbus_interface="org.freedesktop.Hal.Device"
dbus_member="Condition"

## for some horrible reason, i get 8 clicks sometimes
## this buffer ignores repeated clicks within a certain time
## set it to -1 to never ignore
repeat_buffer_millis=800

last_button_click_millis = dict()

def button_clicked(button, handler):
  now_millis = int(round(time.time() * 1000))
  if button in last_button_click_millis:
    then_millis = last_button_click_millis[button]
    if now_millis - then_millis < repeat_buffer_millis:
      print >> sys.stderr, "  ignored: " + button
      return

  last_button_click_millis[button] = now_millis
  handler(button)

def defaultHandler(button):
  print >> sys.stderr, "button: " + button

def connectButtonDbus(handler=defaultHandler):
  dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
  bus = dbus.SystemBus()
  try:
    obj = bus.get_object(dbus_service, dbus_path)
    iface = dbus.Interface(obj, dbus_interface)
  except dbus.DBusException:
    print_exc()
    sys.exit(1)
 
  iface.connect_to_signal(dbus_member,
    lambda cond, arg: button_clicked(arg, handler))

if __name__ == '__main__':
  app = QCoreApplication([])
  connectButtonDbus()
  app.exec_()


wolke 2013-01-06 18:50

Re: [Anounce] [N9] Volume/Power Button Monitor
 
sorry, i typoed in the previous post. if you grabbed it before my edit, please re-grab.

wolke 2013-01-07 17:19

Re: [Anounce] [N9] Volume/Power Button Monitor
 
new release with bluetooth speaker buttons. you set the button to "dbus" and the button-param to the name of the button as reported by hal. use "dbus-monitor --system" to get the name of the button; if that doesnt show anything, it wont work.

i currently use the buttons to control my music and audio books in the shower. i dont use the builtin media player, where the buttons presumably already work.

on the hipe shower speaker, the play/pause button is alternately "play-cd" and "pause-cd", holding it down is "stop-cd". back is always "previous-song" and forward is always "next-song".
the volume buttons are internal volume, power is internal, and the phone button does something weird through another interface
http://www.amazon.com/Hipe-Waterproo.../dp/B005Z3GINK

wolke 2013-01-16 21:29

Re: [Anounce] [N9] Volume/Power Button Monitor
 
version 0.5.1, quickSnap

add an action like:
action=quickSnap(auto),volumeUp,doubleClick,screen Locked

you double click vol+ on the lockscreen, and it focuses, takes the picture, processes it for like 3 seconds, and THEN makes a camera click noise using the file camera-ui uses. total time from press to pic saved is 6s.

the auto is the flash mode. valid flash modes are 'auto', 'on', and 'off'. note that 'torch' and 'manual' are also allowed and may or may not work.

i could have the shutter sound happen when it actually takes the pic, but then theres no guarantee that it made a file. if you hear a click now, it took a picture.


it puts it in DCIM with a filename like 1358370984758.jpg. {millis since epoch}.

it may or may not show up in gallery, i dont use the tracker so i wouldnt know.

HtheB 2013-01-18 20:05

Re: [Anounce] [N9] Volume/Power Button Monitor
 
wolke, still no ''control media volume only'' option... right? :(

wolke 2013-01-19 00:02

Re: [Anounce] [N9] Volume/Power Button Monitor
 
Quote:

Originally Posted by HtheB (Post 1315727)
wolke, still no ''control media volume only'' option... right? :(

correct. no one has yet figured out a way to:
1) stop the buttons from doing what they usually do
or
2) programmatically set volume when mfaw isnt running

I WISH SOMEONE WOULD

guillermorojaz 2013-01-19 01:38

Re: [Anounce] [N9] Volume/Power Button Monitor
 
Hello Wolke.

You can modify the action of a SingleClick, making faster response?

Thanks in advance for your answer.

wolke 2013-01-19 02:35

Re: [Anounce] [N9] Volume/Power Button Monitor
 
Quote:

Originally Posted by guillermorojaz (Post 1315776)
Hello Wolke.

You can modify the action of a SingleClick, making faster response?

Thanks in advance for your answer.

are you talking about quickSnap? if so, is your concern:
1) the amount of time it takes between pushing the button and capturing an image
2) the time it takes between pushing the button and saving the processed image

if youre worried that you will miss the cat being cute, be aware that the picture is taken a LONG time before the sound happens {picture is taken about 3 seconds after press. booting the camera takes some time, but also the autofocus takes time}. maybe i should make it make two sounds, one when the pic is actually being taken, and one when it is done.


P.S.: if youre taking about something other than quickSnap, lemme know

guillermorojaz 2013-01-19 03:32

Re: [Anounce] [N9] Volume/Power Button Monitor
 
Quote:

Originally Posted by wolke (Post 1315780)
are you talking about quickSnap? if so, is your concern:
1) the amount of time it takes between pushing the button and capturing an image
2) the time it takes between pushing the button and saving the processed image

if youre worried that you will miss the cat being cute, be aware that the picture is taken a LONG time before the sound happens {picture is taken about 3 seconds after press. booting the camera takes some time, but also the autofocus takes time}. maybe i should make it make two sounds, one when the pic is actually being taken, and one when it is done.


P.S.: if youre taking about something other than quickSnap, lemme know

actually is to turn the flashlight on the screen lock status, to just click on any of the volume keys, it takes some time to turn on the LED , could be shorter this time? and please excuse my English. :o

optimaxxx 2013-01-19 20:09

Re: [Anounce] [N9] Volume/Power Button Monitor
 
Brilliant idea with dual-sound quick snap functionality.

Might I ask why all the hate for almost every inbuilt function the N9 has?

Is there any chance you could add GPS position as another condition group?
Would be very cool to change my layout based on whether I'm at home, or out!

testing ATM, GUI really is dog's balls. Any way we could help with it?

optimaxxx 2013-01-19 20:10

Re: [Anounce] [N9] Volume/Power Button Monitor
 
Brilliant idea with dual-sound quick snap functionality.

Might I ask why all the hate for almost every inbuilt function the N9 has?

Is there any chance you could add GPS position as another condition group?
Would be very cool to change my layout based on whether I'm at home, or out!

testing ATM, GUI really is dog's balls. Any way we could help with it?

wolke 2013-01-20 19:19

Re: [Anounce] [N9] Volume/Power Button Monitor
 
Quote:

Originally Posted by optimaxxx (Post 1315972)
Brilliant idea with dual-sound quick snap functionality.

dunno whether to use the camera snap twice, or perhaps some other builtin sound file. opinion?

Quote:

Originally Posted by optimaxxx (Post 1315972)
Might I ask why all the hate for almost every inbuilt function the N9 has?

if you mean the default button actions in apps, its because you have to a have a sixth sense to know what the hell your buttons are going to do at any given time. i like consistency in my ux.

Quote:

Originally Posted by optimaxxx (Post 1315972)
Is there any chance you could add GPS position as another condition group?

n9bm runs 100% of the time, so it must be extremely low power. i dont want to risk accidentally killing someones battery to add features like this. i do not want to add features that cause radios to run more often, including bt, wifi, or gps.

however, i should probably make a shell-command-condition that lets folks do whatever they want. {for example, all you would do is write a script called gps-is-home that exits with 0 if you are home and 1 otherwise.}


Quote:

Originally Posted by optimaxxx (Post 1315972)
testing ATM, GUI really is dog's balls. Any way we could help with it?

in my opinion, the best gui for this app would be a nice text editor that opens the config file. the config is straighforward, and reloading is automatic. in fact, the gui literally just modifies the config file and exits.

i maintain the gui only because a LOT of folks are really averse to opening up a text editor. i certainly will never use it, and wouldnt ask anyone else to.

the only extra feature i would like a gui to have is to check the syntax and make sure there are no typos. perhaps ill take redak or something and repackage it with this feature some day.

all that being said, i would love for someone to write a nice qml gui for this so everyone would stop worrying about it already. {i do not think i will ever do this.}

wolke 2013-01-20 19:28

Re: [Anounce] [N9] Volume/Power Button Monitor
 
Quote:

Originally Posted by guillermorojaz (Post 1315788)
actually is to turn the flashlight on the screen lock status, to just click on any of the volume keys, it takes some time to turn on the LED , could be shorter this time? and please excuse my English. :o

no worries. unfortunely, no. the API for accessing the flashlist is QCamera and it has a cold initialization of 2-4 seconds.

if your flashlight is taking more than 2-4 seconds, you have some sort of performance problem with your phone. {perhaps you use dropcache, or you run many things at once}

sorry i cant help.

PIDk 2013-02-04 13:17

Re: [Anounce] [N9] Volume/Power Button Monitor
 
Hi, wolke!

When I launch n9-button-monitor.py it gives me the following error:
Quote:

ERROR:dbus.proxies:Introspect error on :1.2:/org/freedesktop/Hal/devices/computer_logicaldev_input_0: dbus.exceptions.DBusException: org.freedesktop.Hal.NoSuchDevice: No device with id /org/freedesktop/Hal/devices/computer_logicaldev_input_0
But besides this error it works ok. Though I can't test with bluetooth media buttons because I don't use bluetooth headset.

I'm using it on N9.

wolke 2013-02-04 17:02

Re: [Anounce] [N9] Volume/Power Button Monitor
 
Quote:

Originally Posted by PIDk (Post 1320706)
When I launch n9-button-monitor.py it gives me the following error:
But besides this error it works ok. Though I can't test with bluetooth media buttons because I don't use bluetooth headset.

thanks for the report!

yea, i saw that right after release. it happens only if you dont have a bt input device connected at startup. i saw also that everything works. in fact, bluetooth buttons still work when you then DO connect a bt device later, without restarting.

so its a harmless, if misleading, error message. i decided not to fix it, because actively hiding error messages that n9bm didnt actually generate seems wrong.

p.s.: as you probably know, you shouldnt have to start this on the CLI. it should startup all by itself about 90 seconds after boot, and it should reload your changes to the conf file automatically.

wolke 2013-02-12 18:25

Re: [Anounce] [N9] Volume/Power Button Monitor
 
added some features from lcferrum:
-n950 cambutton
-power button
-config option to turn off quicksnap and flashlight/torch
-on/off home icons {a .desktop that changes icons when you push it; these depend on sudo and openmode for now, and wont be in a deb. i will probably make a plugin for sysuid-mt-toggles someday, if anyone cares about turning it on/off nicely}

the next deb i build will have the buttons and the cam option; does anyone have a special interest in any of these features?

solbrit 2013-02-23 20:28

Re: [Anounce] [N9] Volume/Power Button Monitor
 
Have been reading the thread but I'm not clear on this: can you set a short press of the power button (from low power screen) to run an arbitrary command?

Thanks

wolke 2013-02-23 21:24

Re: [Anounce] [N9] Volume/Power Button Monitor
 
Quote:

Originally Posted by solbrit (Post 1324677)
Have been reading the thread but I'm not clear on this: can you set a short press of the power button (from low power screen) to run an arbitrary command?

Thanks

first, power button support is merged into github, but not in any release. {i can build a deb for you off of master if you like}

second, the biggest missing component in n9bm is the ability to cancel the button's default action. no one has any idea how to do this. this makes n9bm useless except in standby, and in apps that override the volume keys.

SO, technically, yes, but it probably wont work because the screen will unlock first and thus you will no longer be on lowpower screen.

however, double-clicking power should work, from any screen, and may even be useful.

solbrit 2013-02-23 23:43

Re: [Anounce] [N9] Volume/Power Button Monitor
 
Hmm... Then it seems that what I had in mind is more difficult than I thought...
My idea was to enable the security lock when trying to unlock the screen (from low power screen) by pressing the power button, whereas double tapping the screen would unlock it as normal. I always unlock the phone in the second manner, while someone who doesn't know how the N9 works (most people) would try to unlock it by hitting the power button if they, say, stole the phone.
An attempt to make the phone useless to your average pickpocket ;)

wolke 2013-02-23 23:52

Re: [Anounce] [N9] Volume/Power Button Monitor
 
clever. and yes, that may work, but not consistently.

however, i think double-tapping is the more obvious unlock method, because the buttons are so unlabeled.
usually friends and such who unlock my phone try to double-tap first {which doesnt work because i turned off double-tap-unlock}.


heres the best implementation i can think of. set the click delay to 2000 millis, and set the single-click-cmd to when the screen is NOT locked. that way, 2 seconds after you click it, the screen will either be locked like you wanted and nothing will run, or it will be unlocked and then suddenly security-locked.

solbrit 2013-02-24 01:59

Re: [Anounce] [N9] Volume/Power Button Monitor
 
Yes, that's a good idea. Can you implement that?

Edit: and you have smarter friends than the people I've come across, who all start looking for buttons as soon as the screen goes blank :D

wolke 2013-02-24 02:17

Re: [Anounce] [N9] Volume/Power Button Monitor
 
1 Attachment(s)
here ya go. this is NOT a release, as i havent tested it. literally havent even run it, sorry.

this deb has new conditions: screenUnlocked, appNotFocused
and new buttons: cameraButton {n950}, powerButton


all you do to configure n9bm how i said, is change /home/user/.config/n9-button-monitor.ini

Code:

doubleClickDelayMs=2000
trebleClickDelayMs=3000
action=cmd(SECURITY-LOCK-CMD),powerButton,singleClick,screenUnlocked

by the way, this assumes you HAVE a command that will enter security lock mode. i have no idea how to do that, and it has nothing to do with n9bm.

wolke 2013-02-24 02:30

Re: [Anounce] [N9] Volume/Power Button Monitor
 
ok, i tested it, and it works fine.

turns out double-click-power IS useful. it will work in lock, unlock, and different apps, where the volume buttons already have actions reserved.

it could, for instance, toggle power saving mode when locked, open my most recent pictures in meeseepics if im on the home screen, and toggle silent/ring everywhere else.

solbrit 2013-02-24 16:46

Re: [Anounce] [N9] Volume/Power Button Monitor
 
Thankyou!
I just installed the deb, although no /home/user/.config/n9-button-monitor.conf (or /home/user/.config/n9-button-monitor.ini) is created. Is this normal? Do i grab the one in OP and throw it in there (changing it according to your instrucions)?

Edit: ...you load the default config file from the ui, got it!

wolke 2013-02-24 19:05

Re: [Anounce] [N9] Volume/Power Button Monitor
 
Quote:

Originally Posted by solbrit (Post 1324831)
Thankyou!
I just installed the deb, although no /home/user/.config/n9-button-monitor.conf (or /home/user/.config/n9-button-monitor.ini) is created. Is this normal? Do i grab the one in OP and throw it in there (changing it according to your instrucions)?

Edit: ...you load the default config file from the ui, got it!

oh snap, i thought the default one got created when the file didnt exist. apparently not, so thats a bug i should fix. ;)

i wouldnt recommend using the gui for anything at all ever.

solbrit 2013-02-24 19:15

Re: [Anounce] [N9] Volume/Power Button Monitor
 
It works perfectly, thankyou! :D

Btw, the torch feature is really nice too. No more unlock-screen-locate-flashlight-app-in-the-app-menu-activate-flashlight...

wolke 2013-02-24 19:51

Re: [Anounce] [N9] Volume/Power Button Monitor
 
Quote:

Originally Posted by solbrit (Post 1324862)
It works perfectly, thankyou! :D

Btw, the torch feature is really nice too. No more unlock-screen-locate-flashlight-app-in-the-app-menu-activate-flashlight...

cool. glad you like it!

Hacker 2013-02-24 20:07

There is a great new open source camera app for the N9 located here: http://talk.maemo.org/showthread.php?t=89278

I think that this could be my new default camera app, but I don't want to lose the Button Monitor camera functions.

Could you set up Button Monitor so that this camera app can be a new condition name in the GUI? Is there an easy way I can make this happen?

wolke 2013-02-24 20:19

Re: [Anounce] [N9] Volume/Power Button Monitor
 
AWESOME! im so excited, i despise the n9 camera app. thanks for this news, ill be checking it out very soon.

now, its very easy to do the condition. you just do appFocused(window-class-name). default camera app is "camera-ui", and his is probably "camera-plus".

cameraFocused == appFocused(camera-ui)
both do exactly the same thing.


now as for the ACTIONS, theyre a little trickier.
what they really do is simulate dragging your finger to certain spots on the screen. if he moved the camera button a little, it will break.

so if he DID move the button, you will need to play with the "tap" action. again, clickCameraSnap and clickCameraFocus are just shorthand for the tap action with an argument.

these do exactly the same thing:
clickCameraSnap == tap(820x240,820x240)
clickCameraFocus == tap(820x240-820x100*200+5)

wolke 2013-02-24 20:31

Re: [Anounce] [N9] Volume/Power Button Monitor
 
i lied, its not class name, its WM_COMMAND.
so you dont even have to use xprop to find out, you can just use the executable name.

wolke 2013-02-25 16:03

Re: [Anounce] [N9] Volume/Power Button Monitor
 
btw, released 0.5.2
buttons: camera {n950}, power
conditions: screenUnlocked, appNotFocused
actions: tap {generic click}


All times are GMT. The time now is 11:07.

vBulletin® Version 3.8.8