maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   OS2008 / Maemo 4 / Chinook - Diablo (https://talk.maemo.org/forumdisplay.php?f=29)
-   -   MCE stop and start (https://talk.maemo.org/showthread.php?t=72220)

Addison 2011-04-16 09:19

MCE stop and start
 
I have a script that runs
/etc/init.d/mce stop
so I can use more of the hardware keys to do different junk.

After I'm done using this I then
sudo /etc/init.d/mce start

The thing is, my original screen brightness and screen blanking timeout numbers are different afterwards.

I then have to go to the Control panel, Display, then click on Okay for them to restore back to their original settings.

Is there any command that I can add to the script so it will do this for me?

I'm using Advanced-Backlight by the way.

Thanks.

auouymous 2011-04-17 06:26

Re: MCE stop and start
 
Not sure why your timeout would be different but MCE does set brightness back to its 1-5 value. You can read the value adv-brightness uses from gconf and write it to /sys/devices/platform/omapfb/panel/backlight_level (multiply it by 2 and add 1). Install gconf-editor to find the gconf value, each app has its own folder.

What are you using the hardware keys for? You can get the power button from a HAL dbus signal and the home key can be used by current app if you grab the keyboard with X. The other keys are all sent to current app.

Addison 2011-04-17 09:21

Re: MCE stop and start
 
I'm currently using this script with ADOM.

Since I only have an N800, it just gives me three extra hardware keys that I can bind for the game, but for me, it's worth it.

I also use this with some of the emulators like DrNokSnes.

But yeah, as far as I know, the only way to get control of these three keys (Escape, Menu, and Home buttons) is to stop MCE.

Once MCE starts again, all of the display settings are thrown completely off unless I go to the Control Panel, Display and then click on Okay.

All of my scripts are mostly copies and pastes from other users here with a simple twist.

I can't program a single thing.

I was hoping for something I could add to my script to do this instead of doing the whole App Manager garbage manually.

Hope this makes sense. :)

auouymous 2011-04-18 13:54

Re: MCE stop and start
 
Do you know how to create shell scripts and execute them from icons?

This code will open the display control panel. You could put it in a shell script after the MCE start command so the display control panel always opens immediately after restarting MCE.
Code:

run-standalone.sh dbus-send --system --type=method_call -dest=com.nokia.controlpanel /com/nokia/controlpanel/rpc com.nokia.controlpanel.run_applet string:libcpdisplay.so boolean:true
Or you could put the following code after the MCE start command and it should read the current values from gconf and write them back to gconf maybe causing MCE to see the correct values.
Code:

restore_value()
{
  gconftool-2 --type $1 --set $2 `gconftool-2 --get $2`
}
restore_value int /system/osso/dsm/display/display_blank_timeout
restore_value int /system/osso/dsm/display/display_dim_timeout
restore_value bool /system/osso/dsm/locks/touchscreen_keypad_autolock_enabled
restore_value bool /system/osso/dsm/display/display_on_with_charger

And this code should update the brightness but you will need to use gconf-editor to find the key used by adv-brightness to store the value and replace XXX.
Code:

value=`gconftool-2 --get XXX`
echo `expr $value \* 2 + 1` > /sys/devices/platform/omapfb/panel/backlight_level


vi_ 2011-04-18 14:03

Re: MCE stop and start
 
This guy talks about steeing screen dim/timeouts form the cli.

Addison 2011-04-19 00:38

Re: MCE stop and start
 
Thank you!

I'll give this a try later tonight I hope.

Before, at the end of my script, I had this...
/usr/bin/controlpanel

And then just redid the settings manually.

I like your ideas so much better. :)

Addison 2011-04-23 01:07

Re: MCE stop and start
 
Quote:

run-standalone.sh dbus-send --system --type=method_call -dest=com.nokia.controlpanel /com/nokia/controlpanel/rpc com.nokia.controlpanel.run_applet string:libcpdisplay.so boolean:true

Usage: dbus-send [--help] [--system | --session] [--dest=NAME] [--type=TYPE] [--print-reply=(literal)] [--reply-timeout=MSEC] <destination object path> <message name> [contents ...]
[1|user@Nokia-N800-43-7|~]
This wouldn't open the Control Panel.


Quote:

restore_value()
{
gconftool-2 --type $1 --set $2 `gconftool-2 --get $2`
}
restore_value int /system/osso/dsm/display/display_blank_timeout
restore_value int /system/osso/dsm/display/display_dim_timeout
restore_value bool /system/osso/dsm/locks/touchscreen_keypad_autolock_enabled
restore_value bool /system/osso/dsm/display/display_on_with_charger
This doesn't work either.

I have
Brightness period: 30 secs.
Switch off display: 30 secs.

However, once MCE starts again, even with your script, it dims at 90 secs. then blanks at 2 minutes.

I believe it also reloads the brightness value from the control panel and not Advanced Backlight.

Quote:

value=`gconftool-2 --get XXX`
echo `expr $value \* 2 + 1` > /sys/devices/platform/omapfb/panel/backlight_level
I'm not sure how to get the value of XXX using g-conf.

Please don't give up on me with this. :)

auouymous 2011-04-23 05:55

Re: MCE stop and start
 
Quote:

Originally Posted by Addison (Post 993951)
This doesn't work either.

I'm not sure how to get the value of XXX using g-conf.

Does it produce an error?

You need to install the "gconf-editor" package, run it, open the apps folder and find adv-backlight's folder. Inside this folder there will be a key that sounds like it holds the brightness level. Replace XXX with the full path (folders and key name) to that key.

Addison 2011-04-23 06:02

Re: MCE stop and start
 
Quote:

Does it produce an error?
Nope, no error at all.

Do you have Advanced Backlight?

I thought that came with the SSU because it best supports the whole screen rotation thing?

And I'll try your gconf-editor suggestion right now. :)

Thanks!

Addison 2011-04-23 06:10

Re: MCE stop and start
 
Okay. It looks like I can't see the entire address because it's grayed out.

http://img854.imageshack.us/img854/8...1042302085.png

auouymous 2011-04-24 06:21

Re: MCE stop and start
 
Quote:

Originally Posted by Addison (Post 994000)
Do you have Advanced Backlight?

I thought that came with the SSU because it best supports the whole screen rotation thing?

No it doesn't come with SSU. I had adv-backlight installed until I wrote advanced-systemui which replaces all the features in adv-backlight. Couple weeks ago I was forced to format and now have a clean gconf database so I wasn't able to lookup the key for you but knew it was there.

Quote:

Originally Posted by Addison (Post 994002)
It looks like I can't see the entire address because it's grayed out.

The full key name is in the right pane above the dialog.

Replace XXX with /apps/adv-backlight/brightness

Addison 2011-04-24 07:07

Re: MCE stop and start
 
Quote:

Replace XXX with /apps/adv-backlight/brightness
Hey!

Yeah, that actually works!

Only for one second though and then it immediately reverts back to the Control Panel -> Display -> Brightness setting it seems like.

I've tried it 5 times now.

Poops. :(

Okay. If you were to run this from Xterm:
/etc/init.d/mce stop
sudo /etc/init.d/mce start

I just would like the Brightness, Brightness period and Switch off display numbers to be the exact same and functioning as they were before entering those two command lines.

I hope that makes sense and thank you so much for sticking with me on this.

You rock dude! :)

Addison 2011-04-24 07:23

Re: MCE stop and start
 
Eep! :D

I added this at the end of my script:
gconftool-2 -s "/system/osso/dsm/display/display_dim_timeout" 30 -t INT
gconftool-2 -s "/system/osso/dsm/display/display_blank_timeout" 30 -t INT

Now after I've restarted MCE again, the dim and blank times remain the same like they were before (30 seconds each). :)

Is there a way to catch what these two values are at the beginning of the script and then enter them back in afterward?

Like using variables or whatever?

All that's left is to get a better handle on the brightness setting, which goes weird after MCE restart, and then I'm gold. :)

auouymous 2011-04-24 15:17

Re: MCE stop and start
 
Quote:

Originally Posted by Addison (Post 994422)
Eep! :D

I added this at the end of my script:
gconftool-2 -s "/system/osso/dsm/display/display_dim_timeout" 30 -t INT
gconftool-2 -s "/system/osso/dsm/display/display_blank_timeout" 30 -t INT

Now after I've restarted MCE again, the dim and blank times remain the same like they were before (30 seconds each). :)

Is there a way to catch what these two values are at the beginning of the script and then enter them back in afterward?

Like using variables or whatever?

All that's left is to get a better handle on the brightness setting, which goes weird after MCE restart, and then I'm gold. :)


The restore_value code should have worked, try changing the function to:

Code:

restore_value()
{
  value=`gconftool-2 --get "$2"`
  gconftool-2 --type $1 --set "$2" $value
}

And then put the lines that call it after.

Oops! I forgot about DSME when setting the brightness, you can change the value with that file but DSME restores it. The /etc/mce.conf file has a line that loads a filter-brightness-als module, should only work on n810 but maybe if you remove it by commenting out the line and making a copy without that module it might stop reseting brightness. I'll try to write some real code to set DSME brightness when I wake up, poke me if I forget. :)

Addison 2011-05-13 14:56

Re: MCE stop and start
 
Okay, here's the poke you wanted. *lol*

Is there just a simple way to read all of these values before the script and then return them back afterward?


gconftool-2 --type int --set /apps/osso/applet/osso-applet-display/turn_off_display ?
gconftool-2 --type int --set /apps/osso/applet/osso-applet-display/brightness_period ?
gconftool-2 --type int --set /system/osso/dsm/display/display_dim_timeout ?
gconftool-2 --type int --set /system/osso/dsm/display/display_blank_timeout ?

auouymous 2011-05-13 22:20

Re: MCE stop and start
 
Quote:

Originally Posted by Addison (Post 1005565)
Is there just a simple way to read all of these values before the script and then return them back afterward?
gconftool-2 --type int --set /apps/osso/applet/osso-applet-display/turn_off_display ?
gconftool-2 --type int --set /apps/osso/applet/osso-applet-display/brightness_period ?
gconftool-2 --type int --set /system/osso/dsm/display/display_dim_timeout ?
gconftool-2 --type int --set /system/osso/dsm/display/display_blank_timeout ?

I thought the values were correct and just need to be OK'd to restore them? You should have to read and write them to get MCE's attention.

I put together a small program to set the backlight, download it here http://asui.garage.maemo.org/download.html . You don't need to download the source file.

Code:

# advanced backlight
set-brightness `gconftool-2 --get /apps/adv-backlight/brightness`

# ASUI
set-brightness `gconftool-2 --get /apps/asui_state/brightness_level`

Second command is for anyone wanting to do this with ASUI.

Addison 2011-05-21 16:15

Re: MCE stop and start
 
I'm so bad at coding that I'm going to be shameless and ask if you could edit my current script that I'm using with your new backlight app thingy. :)



#! /bin/sh

gconftool-2 --set -t bool /system/osso/af/keyboard-attached true
/etc/init.d/mce stop
killall xbindkeys
xbindkeys -f /home/user/.xbindkeysrc_adom
xmodmap ~/.Xmodmap_adom
xkbd -geometry +65536+65992 -k /media/mmc2/N800/Keyboards/Flat2.xkbd & xkbd -geometry +725+360 -k /media/mmc2/N800/Keyboards/Keypad.xkbd & ssh -l james ancardius.ath.cx
gconftool-2 --set -t bool /system/osso/af/keyboard-attached false
killall xbindkeys
killall xkbd
setxkbmap
sudo /etc/init.d/mce start
gconftool-2 -s "/system/osso/dsm/display/display_brightness_level_step" 1 -t INT
gconftool-2 -s "/system/osso/dsm/display/max_display_brightness_levels" 127 -t INT
gconftool-2 -s "/system/osso/dsm/display/display_brightness" 16 -t INT
gconftool-2 -s "/system/osso/dsm/display/display_dim_timeout" 30 -t INT
gconftool-2 -s "/system/osso/dsm/display/display_blank_timeout" 30 -t INT
gconftool-2 -s "/system/osso/dsm/display/display_brightness_level_step" 1 -t INT
gconftool-2 -s "/system/osso/dsm/display/max_display_brightness_levels" 5 -t INT
xbindkeys
killall roxterm

auouymous 2011-05-21 23:18

Re: MCE stop and start
 
Code:

/FULL/PATH/set-brightness `gconftool-2 --get /apps/adv-backlight/brightness`
Just add that to the bottom and change /FULL/PATH/ to the directory path where you placed the set-brightness binary, /root/bin/ is a good location. And chmod 755 set-brightness so you can execute it.

Addison 2011-05-31 21:48

Re: MCE stop and start
 
Awesome!

That works!

Eeeeeeeee! :D

The correct argument though is
/usr/bin/set-backlight `gconftool-2 --get /apps/adv-backlight/brightness`

I'm still unsure how to use these with variables.

gconftool-2 -s "/system/osso/dsm/display/display_brightness_level_step" 1 -t INT
gconftool-2 -s "/system/osso/dsm/display/max_display_brightness_levels" 127 -t INT
gconftool-2 -s "/system/osso/dsm/display/display_brightness" 16 -t INT
gconftool-2 -s "/system/osso/dsm/display/display_dim_timeout" 30 -t INT
gconftool-2 -s "/system/osso/dsm/display/display_blank_timeout" 30 -t INT

I'd like to use variables to restore the settings back to how they were rather than force something that's always static like how I'm currently doing this.

Thanks chief! :)

JonWW 2011-05-31 22:08

Re: MCE stop and start
 
On the N900 this resets the back light to what ever level it was set to after MCE restarts:
Code:

sleep2
gconftool -s /system/osso/dsm/display/display_brightness \
 `gconftool -g /system/osso/dsm/display/display_brightness` -t int

I have never noticed if the timeout get changed, but in theory the same thing could be done with it

Addison 2011-05-31 22:58

Re: MCE stop and start
 
^ Thanks but that didn't work even though it didn't give me any errors.

Addison 2011-05-31 23:17

Re: MCE stop and start
 
I have the blank timeout set at 30 seconds.

After restarting mce and running this...
gconftool -s /system/osso/dsm/display/display_blank_timeout \ `gconftool -g /system/osso/dsm/display/display_blank_timeout` -t int

It doesn't reset. It blanks after 2 minutes now.

Should there be quotes or something in that command line?

auouymous 2011-06-01 01:18

Re: MCE stop and start
 
Quote:

Originally Posted by Addison (Post 1019768)
The correct argument though is
/usr/bin/set-backlight `gconftool-2 --get /apps/adv-backlight/brightness`

You shouldn't place user programs in system directories. Use /root/bin or /home/user/bin instead. Also makes it easier to backup scripts and binaries you've written or downloaded and might be hard to find again.

Quote:

Originally Posted by Addison (Post 1019768)
I'm still unsure how to use these with variables.

gconftool-2 -s "/system/osso/dsm/display/display_brightness_level_step" 1 -t INT

Anything instead `` is executed and passed to the command as an argument, so you just `gconftool-2 -g /path/to/a/key` would be used in place of the static value.

If you scroll back to my second post you will see that I wrote a nice little function that automates this for you. You just have to pass it the key and type and it handles getting and setting.

@ jonww, that key is for the default brightness, he is using adv-backlight which has its own key.

Addison 2011-06-01 03:24

Re: MCE stop and start
 
I wasn't trying to be a punk. *lol*

I was simply pointing out that
/usr/bin/set-backlight `gconftool-2 --get /apps/adv-backlight/brightness`
and not
/FULL/PATH/set-brightness `gconftool-2 --get /apps/adv-backlight/brightness`
the way you wrote it was correct. :)

Anyway, I'll look over your post one more time and see if I can't get your other junk to work as well.

Cheers buddy. :)

Addison 2011-06-01 21:29

Re: MCE stop and start
 
Sorry.

What am I doing wrong here?



#! /bin/sh

gconftool-2 --set -t bool /system/osso/af/keyboard-attached true
/etc/init.d/mce stop
killall xbindkeys
xbindkeys -f /home/user/.xbindkeysrc_adom
xmodmap ~/.Xmodmap_adom
xkbd -geometry +65536+65992 -k /media/mmc2/N800/Keyboards/Flat2.xkbd & xkbd -geometry +725+360 -k /media/mmc2/N800/Keyboards/Keypad.xkbd & filterm ascii-ascii cp437-utf8 telnet becksbbs.synchro.net
gconftool-2 --set -t bool /system/osso/af/keyboard-attached false
killall xbindkeys
killall xkbd
setxkbmap
sudo /etc/init.d/mce start
/usr/bin/set-backlight `gconftool-2 --get /apps/adv-backlight/brightness`
restore_value()
{
gconftool-2 --type $1 --set $2 `gconftool-2 --get $2`
}
restore_value int /system/osso/dsm/display/display_blank_timeout
restore_value int /system/osso/dsm/display/display_dim_timeout
restore_value bool /system/osso/dsm/locks/touchscreen_keypad_autolock_enabled
restore_value bool /system/osso/dsm/display/display_on_with_charger

xbindkeys
killall roxterm

auouymous 2011-06-02 11:46

Re: MCE stop and start
 
Quote:

Originally Posted by Addison (Post 1020472)
What am I doing wrong here?

Does it produce an error? Does it not restore the settings?

Addison 2011-06-03 20:29

Re: MCE stop and start
 
It appears that there is no error to anything you wrote.

Everything seems to go back to their original settings (brightness, brightness period).

The one that doesn't restore is the switch off display timer.

Other than that, it looks like I'm all good. :)

auouymous 2011-06-03 21:28

Re: MCE stop and start
 
Look at turn_off_display and brightness_period in /apps/osso/applet/osso-applet-display.

Addison 2011-06-03 22:09

Re: MCE stop and start
 
Are you referring to
/usr/share/osso-applet-display/RX-34.schemas ?

That's all I'm really finding that's close to what you wrote.

auouymous 2011-06-03 22:40

Re: MCE stop and start
 
The gconf keys /apps/osso/applet/osso-applet-display/turn_off_display and /apps/osso/applet/osso-applet-display/brightness_period, add restore_value lines for them and see if that works.

Addison 2011-06-04 00:40

Re: MCE stop and start
 
Okay. So do you mean this?

restore_value()
{
gconftool-2 --type $1 --set $2 `gconftool-2 --get $2`
}
restore_value int /system/osso/dsm/display/display_blank_timeout
restore_value int /system/osso/dsm/display/display_dim_timeout
restore_value int /apps/osso/applet/osso-applet-display/turn_off_display
restore_value int /apps/osso/applet/osso-applet-display/brightness_period
restore_value bool /system/osso/dsm/locks/touchscreen_keypad_autolock_enabled
restore_value bool /system/osso/dsm/display/display_on_with_charger


No errors on any of this but it's not restoring the Switch off Display setting thingy still.

Thanks again for your patience with me. :)

auouymous 2011-06-04 04:36

Re: MCE stop and start
 
Try switching the order so the two system keys are below the two apps keys. Dunno what else to try if that doesn't work.

Addison 2011-06-05 22:19

Re: MCE stop and start
 
I did change the order like you mentioned.

No such luck though.

So either I need to force it back with a static number, which works, or somehow use a variable setting instead, which I don't know how to do.

It's weird that the blank timeout is the only setting that doesn't take.

auouymous 2011-06-05 23:32

Re: MCE stop and start
 
Quote:

Originally Posted by Addison (Post 1022913)
So either I need to force it back with a static number, which works, or somehow use a variable setting instead, which I don't know how to do.

So what happens if you set it to some high static value and then restore it using the following code?
Code:

blank=`gconftool-2 -g /system/osso/dsm/display/display_blank_timeout`
gconftool-2 -t int -s /system/osso/dsm/display/display_blank_timeout 300
gconftool-2 -t int -s /system/osso/dsm/display/display_blank_timeout $blank


Addison 2011-06-06 00:40

Re: MCE stop and start
 
So like this?


#! /bin/sh

gconftool-2 --set -t bool /system/osso/af/keyboard-attached true
blank=`gconftool-2 -g /system/osso/dsm/display/display_blank_timeout`
/etc/init.d/mce stop
killall xbindkeys
xbindkeys -f /home/user/.xbindkeysrc_adom
xmodmap ~/.Xmodmap_adom
xkbd -geometry +65536+65992 -k /media/mmc2/N800/Keyboards/Flat2.xkbd & xkbd -geometry +725+360 -k /media/mmc2/N800/Keyboards/Keypad.xkbd & filterm ascii-ascii cp437-utf8 telnet becksbbs.synchro.net
gconftool-2 --set -t bool /system/osso/af/keyboard-attached false
killall xbindkeys
killall xkbd
setxkbmap
sudo /etc/init.d/mce start
/usr/bin/set-backlight `gconftool-2 --get /apps/adv-backlight/brightness`
restore_value()
{
gconftool-2 --type $1 --set $2 `gconftool-2 --get $2`
}
restore_value int /apps/osso/applet/osso-applet-display/turn_off_display
restore_value int /apps/osso/applet/osso-applet-display/brightness_period
gconftool-2 -t int -s /system/osso/dsm/display/display_blank_timeout 300
gconftool-2 -t int -s /system/osso/dsm/display/display_blank_timeout $blank

restore_value int /system/osso/dsm/display/display_dim_timeout
restore_value bool /system/osso/dsm/locks/touchscreen_keypad_autolock_enabled
restore_value bool /system/osso/dsm/display/display_on_with_charger
xbindkeys
killall roxterm



Before this runs:
Brightness period - 30 seconds
Switch off display - 30 seconds

After:
Brightness period - 30 seconds
Switch off display - 5 minutes

auouymous 2011-06-06 02:18

Re: MCE stop and start
 
Quote:

Originally Posted by Addison (Post 1022954)
blank=`gconftool-2 -g /system/osso/dsm/display/display_blank_timeout`
/etc/init.d/mce stop
...
sudo /etc/init.d/mce start
...
restore_value int /apps/osso/applet/osso-applet-display/turn_off_display
restore_value int /apps/osso/applet/osso-applet-display/brightness_period
gconftool-2 -t int -s /system/osso/dsm/display/display_blank_timeout 300
gconftool-2 -t int -s /system/osso/dsm/display/display_blank_timeout $blank

restore_value int /system/osso/dsm/display/display_dim_timeout

Before this runs:
Brightness period - 30 seconds
Switch off display - 30 seconds

After:
Brightness period - 30 seconds
Switch off display - 5 minutes

Without the new code does control panel show the correct value? And it just blanks at the wrong time or not at all? The line that sets 'blank' can sit right before the line that sets the key using it if control reports correct value but blanks at 2 minutes or something.

It doesn't make sense why the line that sets 300 works but the line after doesn't. Try putting this line in the code after the MCE start line and see what it prints out when you run the script.
Code:

echo `gconftool-2 -g /system/osso/dsm/display/display_blank_timeout`
You can remove the two /apps/osso/applet/osso-applet-display/* keys if they didn't change anything, unless the brightness_period key fixed the dim timeout.

Why do you sudo to start MCE but not to stop?

Addison 2011-06-06 02:41

Re: MCE stop and start
 
Quote:

Why do you sudo to start MCE but not to stop?
I'm sure there's a reason but I forgot.

I've been working on this script for 18 months now so it's been awhile. *lol*

In the control panel, the switch off display says one thing (30 seconds) but the timer is something else (5 minutes). It defaults to 2 minutes when MCE restarts without your script thingy.

That's why I used to bring up the display panel and just click Okay since that seemed to restore all the values correctly.

Addison 2011-07-05 05:47

Re: MCE stop and start
 
Last question, is there a way to map the power button when MCE has stopped?

In Xterm:
xbindkeys -k
It's not recognizing anything when I depress that hardware button.

How is advanced-systemui picking up when this key is being pressed?

auouymous 2011-07-05 06:37

Re: MCE stop and start
 
Quote:

Originally Posted by Addison (Post 1044875)
Last question, is there a way to map the power button when MCE has stopped?

Nope.

HAL sends a signal over dbus when power button is pressed or you can listen to /dev/input/event0(n800) or 1(n810) like ASUI does. It's not a normal key like the others, so no easy way to bind it.

Addison 2011-07-05 06:39

Re: MCE stop and start
 
^ Thank you so much for everything you put into this thread.

I surely appreciate your great efforts to provide answers for me. :)


All times are GMT. The time now is 20:16.

vBulletin® Version 3.8.8