Reply
Thread Tools
Posts: 2 | Thanked: 3 times | Joined on Nov 2011
#1
Hey all,

I'm trying to write a script (using dbus, but if other options are better, please let me know) to programmatically show the lock screen, simulating a power button press when the n900 is locked. Is there any way to do this?

I've tried monitoring dbus for the power button press, and came up with this dbus command:
Code:
dbus-send --type=signal --system --print-reply --dest=org.freedesktop.Hal /org/freedesktop/Hal/devices/computer_logicaldev_input org.freedesktop.Hal.Device.Condition string:'ButtonPressed' string:'power'
Alas, it doesn't work (nothing happens). Just for the record, the n900 was locked when I tried this (over SSH), and when I pressed the actual power button, the lock screen appeared.

Any help is much appreciated.
 
nicolai's Avatar
Posts: 1,637 | Thanked: 4,424 times | Joined on Apr 2009 @ Germany
#2
shell script (taken from
http://meego.gitorious.org/meego-mid...sts/mcetorture)

Code:
#!/bin/sh

EVENT_POWER_KEY="\x74\x00"
POWERBUTTON_EVENT_FILE=/dev/input/pwrbutton
EVENT_TIMESTAMP="\x48\x67\x98\x45\x5f\x16\x0b\x00"
EVENT_KEY_TYPE="\x01\x00"
EVENT_PRESS_VALUE="\x01\x00\x00\x00"
EVENT_RELEASE_VALUE="\x00\x00\x00\x00"

printf "$EVENT_TIMESTAMP$EVENT_KEY_TYPE$EVENT_POWER_KEY$EVENT_PRESS_VALUE$EVENT_TIMESTAMP$EVENT_KEY_TYPE$EVENT_POWER_KEY$EVENT_RELEASE_VALUE" > $POWERBUTTON_EVENT_FILE
For what is that good for?
 

The Following 4 Users Say Thank You to nicolai For This Useful Post:
Posts: 2 | Thanked: 3 times | Joined on Nov 2011
#3
Holly sh*t man, I'd never have got that in a million years. Thank you so much. For that torture script also, gonna study it carefully later, I'm sure it'll come in handy later on.

The purpose of this is I'm trying to do something about the problem others and myself are having of, the phone being locked and receiving a call, it getting unlocked and you accidentally pressing the touchscreen buttons (either answering or rejecting the call).

I've already managed to, when the incoming call rings, if the phone was locked, lock it again. But the screen just stays black, although it plays the ringing tone. I wanted a visual warning that it was actually ringing, specially for when I put it in silent. So I thought of showing the lock screen. I also plan to flash the led in a diferent color and rhythm, maybe a violet or orange tone, to distinguish it form the "missed call" and "full battery" ones, which are more common.

Now my next step is to try to get the calling number or contact name and write it on the lock screen. Wish me luck, and if you have any ideas that you care to share, they're more than welcome. You're apparently the local wizard

Cheers,

Heliton
 

The Following 3 Users Say Thank You to hfilho For This Useful Post:
moudy91's Avatar
Posts: 165 | Thanked: 18 times | Joined on Jun 2010
#4
Originally Posted by nicolai View Post
shell script (taken from
http://meego.gitorious.org/meego-mid...sts/mcetorture)

Code:
#!/bin/sh

EVENT_POWER_KEY="\x74\x00"
POWERBUTTON_EVENT_FILE=/dev/input/pwrbutton
EVENT_TIMESTAMP="\x48\x67\x98\x45\x5f\x16\x0b\x00"
EVENT_KEY_TYPE="\x01\x00"
EVENT_PRESS_VALUE="\x01\x00\x00\x00"
EVENT_RELEASE_VALUE="\x00\x00\x00\x00"

printf "$EVENT_TIMESTAMP$EVENT_KEY_TYPE$EVENT_POWER_KEY$EVENT_PRESS_VALUE$EVENT_TIMESTAMP$EVENT_KEY_TYPE$EVENT_POWER_KEY$EVENT_RELEASE_VALUE" > $POWERBUTTON_EVENT_FILE
For what is that good for?
Dear nicolai
correct me if am wrong that script will open the power button? because really i want a script to open the power button because mine is damage
 
moudy91's Avatar
Posts: 165 | Thanked: 18 times | Joined on Jun 2010
#5
Originally Posted by nicolai View Post
shell script (taken from
http://meego.gitorious.org/meego-mid...sts/mcetorture)

Code:
#!/bin/sh

EVENT_POWER_KEY="\x74\x00"
POWERBUTTON_EVENT_FILE=/dev/input/pwrbutton
EVENT_TIMESTAMP="\x48\x67\x98\x45\x5f\x16\x0b\x00"
EVENT_KEY_TYPE="\x01\x00"
EVENT_PRESS_VALUE="\x01\x00\x00\x00"
EVENT_RELEASE_VALUE="\x00\x00\x00\x00"

printf "$EVENT_TIMESTAMP$EVENT_KEY_TYPE$EVENT_POWER_KEY$EVENT_PRESS_VALUE$EVENT_TIMESTAMP$EVENT_KEY_TYPE$EVENT_POWER_KEY$EVENT_RELEASE_VALUE" > $POWERBUTTON_EVENT_FILE
For what is that good for?
can this script be done on a qbw command, and how???
because it most be a root.
thank you
 
nicolai's Avatar
Posts: 1,637 | Thanked: 4,424 times | Joined on Apr 2009 @ Germany
#6
 
moudy91's Avatar
Posts: 165 | Thanked: 18 times | Joined on Jun 2010
#7
Originally Posted by nicolai View Post
Does it work with
sudo <scriptname>
you mean save the script .sh then sudo that .sh file?? because i did that and nothing happens.
 
JonWW's Avatar
Posts: 623 | Thanked: 289 times | Joined on Jan 2010 @ UK
#8
Originally Posted by moudy91 View Post
you mean save the script .sh then sudo that .sh file?? because i did that and nothing happens.
Correct, save script to file, but use this code to run it:
Code:
echo "/full/path/to/script"|root
 
moudy91's Avatar
Posts: 165 | Thanked: 18 times | Joined on Jun 2010
#9
Originally Posted by JonWW View Post
Correct, save script to file, but use this code to run it:
Code:
echo "/full/path/to/script"|root
i did copy the scipt to a txt file then save it to .sh
on a qbw i did put
Code:
echo "/home/user/MyDocs/Power.sh"|root
but nothing happens
 
JonWW's Avatar
Posts: 623 | Thanked: 289 times | Joined on Jan 2010 @ UK
#10
Originally Posted by moudy91 View Post
i did copy the scipt to a txt file then save it to .sh
on a qbw i did put
Code:
echo "/home/user/MyDocs/Power.sh"|root
but nothing happens
Code should have been:
Code:
echo "sh /home/user/MyDocs/Power.sh"|root
 

The Following User Says Thank You to JonWW For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 01:27.