Reply
Thread Tools
Posts: 25 | Thanked: 59 times | Joined on Jun 2010 @ Finland
#1
Hi!

Noticed this topic has been handled in some threads but to keep it readable, decided to start a new one dedicated to this. Good tips, ideas and more information about using systemui and d-bus welcome! These might also work with N770/8x0, haven't tried yet.

While playing with the power button menu configuration files at /etc/systemui/, I noticed there's an entry for "Top in XTerm" that starts XTerm with top running. If that is possible then starting any command should be possible, let's add some frequently used tools there. Also noticed some of the entries had icons so those could be added as well. I'm biking a lot and my biggest gripe for the N900 has been awkward access to anything unless you have two hands available, stable environment and full concentration. The power button menu allows starting, or focusing, anything with just a press of the power button and one touch of the large power menu items, easy even when biking.



Seems that all the *.xml files under /etc/systemui folder are loaded when systemui is restarted (see below). The basic structure of these files is:

Code:
<powerkeymenu path="/">
  <menuitem 
    priority="[Sort order, lowest first]" 
    name="[Name shown in the menu]">
    <icon>[Icon name, same as in *.desktop]</icon>
  [Actions]
  </menuitem>

  <menuitem priority="9" name="Another entry">
    ..
  </menuitem>  
</powerkeymenu>
Doesn't matter how entries are divided between files, maybe would be good to have the default ones in systemui.xml and add another for own entries or one for each entry.

Don't worry about the priorities at first, just create the buttons and plan on paper how would you like them arranged, then assign priority numbers from lower to higher numbers starting from top left.

I have disabled the shutdown and screen lock entries as those can be accessed by long press and double press anyway. Reboot I might disable too as that's easy enough to do in XTerm, considering that's not needed even every day.

In landscape mode, 14 entries fit the menu nicely, more than that will leave some outside the screen and it doesn't scroll. In portrait mode, 13 entries would (almost) fit, but even with 12 it's difficult to leave the menu without selecting something so a dummy entry might be handy.

My entries:
End task, just icon added:
Code:
  <menuitem priority="600" 
    name="powerup_memain_endcurrenttask">
    <icon>general_close</icon>
    <return>10</return>
    <po>osso-powerup-shutdown</po>
  </menuitem>
Reboot (icon from somewhere):
Code:
  <menuitem priority="500" name="Reboot">
    <icon>reboot</icon>
    <return>6</return>
    <po>osso-powerup-shutdown</po>
  </menuitem>
Top (icon from somewhere):
Code:
  <menuitem priority="4" name="Top">
    <icon>dashboard</icon>
      <callback service="com.nokia.xterm" 
        path="/com/nokia/xterm" interface="com.nokia.xterm" 
        method="run_command" bus="session" autostart="true">
      <argument type="string">/usr/bin/top</argument>
     </callback>
  </menuitem>
Nethack (whenever have some spare minutes:):
Code:
  <menuitem priority="6" name="Nethack">
    <icon>nethack</icon>
      <callback service="com.nokia.xterm" 
        path="/com/nokia/xterm" 
        interface="com.nokia.xterm" method="run_command" 
        bus="session" autostart="true">
      <argument type="string">/usr/games/nethack</argument>
    </callback>
  </menuitem>
SSH server access (using for IM, e-mail etc):
Code:
  <menuitem priority="5" name="Server">
    <icon>im-icq</icon>
      <callback service="com.nokia.xterm" 
        path="/com/nokia/xterm" 
        interface="com.nokia.xterm" method="run_command" 
        bus="session" autostart="true">
      <argument type="string">ssh user@server</argument>
    </callback>
  </menuitem>
Direct access without password using SSH public key (discussed elsewhere).

Plain XTerm (could be root as well but thought this is more general):
Code:
  <menuitem priority="3" name="X-Term">
    <icon>terminal</icon>
      <callback service="com.nokia.xterm" 
        path="/com/nokia/xterm" 
        interface="com.nokia.xterm" method="run_command" 
        bus="session" autostart="true">
      <argument type="string">sh</argument>
    </callback>
  </menuitem>
Panucci the audio player (which I use daily when biking to/from work):
Code:
  <menuitem priority="3" name="Panucci">
    <icon>panucci</icon>
    <callback service="com.nokia.HildonDesktop.AppMgr" 
      path="/com/nokia/HildonDesktop/AppMgr" 
      interface="com.nokia.HildonDesktop.AppMgr" 
      method="LaunchApplication" bus="session" 
      autostart="true">
      <argument type="string">panucci</argument>
    </callback>
  </menuitem>
There might be cleaner ways to start it, this seems to be better than with XTerm anyway.

Calendar:
Code:
  <menuitem priority="2" name="Calendar">
    <po>rtcom-calendar</po>
    <icon>general_calendar</icon>
    <callback service="com.nokia.calendar"
      path="/com/nokia/calendar"
      interface="com.nokia.calendar" method="top_application"
      bus="session" autostart="true">
    <argument type="boolean">true</argument>
    </callback>
  </menuitem>
Phone number shortcut:
Code:
 <menuitem priority="1" name="PhoneHome">
  <po>rtcom-call-ui</po>
  <icon>general_application_call</icon>
  <callback service="com.nokia.csd.Call"
	    path="/com/nokia/csd/call"
	    interface="com.nokia.csd.Call" method="CreateWith"
	    bus="system" autostart="true">
    <argument type="string">+xxxyyyzzzzzz</argument>
    <argument type="uint32">0</argument>
  </callback>
 </menuitem>
Some more ringing profiles I intend to add.

Editing instructions:
- Enable root access. If you don't know what is that, please do some homework or wait for someone write a nice tool for editing the power menu. You might brick your device by editing these files as they are loaded in the startup sequence.
- cd /etc/systemui
- cp systemui.xml systemui.xml_backup
- vi systemui.xml (or whatever editor you like)
or
- cp callui.xml mypowermenu.xml;
- vi mypowermenu.xml

Existing icons can be found in /usr/share/icons/hicolor/48x48/hildon (or other folders below 48x48). Own 48x48 icons can be put there as well.

Here's my icon for Nethack:



The new menu can be taken in use by rebooting but a quick way is to restart systemui. Here is a script for that, save somewhere and run when the menu needs to be refreshed:

Code:
systemui_restart.sh
#!/bin/sh
/usr/sbin/dsmetool -k /usr/bin/systemui
sleep 1
/usr/sbin/dsmetool -n -l -t /usr/bin/systemui

Some questions waiting for answers:
- Are those <title> and <po> in the beginning of systemui.xml (but not callui.xml) used for something?
- What's the <po> tag anyway?
- How exactly does this <callback> work, what do the parameters mean?

I have used Linux for >15 years but am a complete newbie in Maemo, trying to learn quick:)

Edit 2010-06-11:Added systemui restart instructions/script, info about number of entries, how to start apps without xterm.
Edit 2010-06-11:Added info about portrait mode power menu.
Edit 2010-06-17: Added phone shortcut entry.

Last edited by x-rated; 2010-06-17 at 13:33. Reason: Added phone shortcut entry.
 

The Following 45 Users Say Thank You to x-rated For This Useful Post:
Posts: 7 | Thanked: 0 times | Joined on Mar 2010
#2
Awesome! But somehow X-term is opened twice and I have no idea how to fix this..
 
Posts: 25 | Thanked: 59 times | Joined on Jun 2010 @ Finland
#3
Originally Posted by patrickl View Post
Awesome! But somehow X-term is opened twice and I have no idea how to fix this..
What exactly were you trying to run? X-Term as above? If you are doing "interface=com.nokia.xterm method=run_command" and as the argument an application that will open a new window,you will get X-Term and then the whatever new window as requested.

However, if you have a command line app like "sh" as the argument of X-Term, or use com.nokia.HildonDesktop.AppMgr->LaunchApplication to run commands, there should be only one window.
 

The Following User Says Thank You to x-rated For This Useful Post:
Posts: 7 | Thanked: 0 times | Joined on Mar 2010
#4
yeah, when I run it with com.nokia.HildonDesktop.AppMgr->LaunchApplication it works just great. I've noticed that every program, installed on the N900 can run with this algorithm, which makes using the device much more easier. You did a really great job! Once again, thank you very much
 
Posts: 5 | Thanked: 0 times | Joined on Mar 2010 @ Bogotá Colombia
#5
Hi! How do I can add Task Switcher to this menu? Thanks in advance! So long.
 
dscobsct's Avatar
Posts: 263 | Thanked: 231 times | Joined on Feb 2010 @ wales
#6
any chance you can give me an example entry with the above code to only open the one window. not sure where to put it.
__________________
my home on the net is symbian-freak/maemo-freak dot com.
come and visit
 
dscobsct's Avatar
Posts: 263 | Thanked: 231 times | Joined on Feb 2010 @ wales
#7
right ignore my earlier question, com.nokia.HildonDesktop.AppMgr->LaunchApplication works great but doesnt work for python apps
can someone show me how an example entry for starting one?

also is there a way of using com.nokia.HildonDesktop.AppMgr->LaunchApplication to launch settings other than com.nokia.controlpanel
__________________
my home on the net is symbian-freak/maemo-freak dot com.
come and visit
 
quingu's Avatar
Posts: 271 | Thanked: 124 times | Joined on May 2006 @ Aperture Science, Inc.
#8
Hi, I'm trying to run a commandline directly from systemui.xml.

Code:
sudo gainroot
echo 2 > /sys/class/backlight/acx565akm/brightness
This command can be shortened to one line:
Code:
echo "echo 2 > /sys/class/backlight/acx565akm/brightness" | sudo gainroot
So what I put in my systemui.xml was basically this:
Code:
  <menuitem priority="3" name="Brightness">
    <icon>terminal</icon>
      <callback service="com.nokia.xterm" 
        path="/com/nokia/xterm" 
        interface="com.nokia.xterm" method="run_command" 
        bus="session" autostart="true">
      <argument type="string">echo "echo 2 > /sys/class/backlight/acx565akm/brightness" | sudo gainroot</argument>
    </callback>
  </menuitem>
But this only gives me an empty xterm window (content is the same as if you started xterm via app menu).
What to do?
__________________
Handcrafted Ambient / Chillout Music, free to download: nomoton
 

The Following User Says Thank You to quingu For This Useful Post:
Posts: 55 | Thanked: 72 times | Joined on Nov 2009
#9
Originally Posted by quingu View Post
Hi, I'm trying to run a commandline directly from systemui.xml.

Code:
sudo gainroot
echo 2 > /sys/class/backlight/acx565akm/brightness
First of all, I highly recommend editing /etc/sudoers and adding the following line:

Code:
user ALL = (ALL) NOPASSWD: ALL
This will allow you to run any command as root using sudo, not just gainroot.

Now, because you want to redirect into a file, you need the shell itself to run as root, so you can run the command you want like this:

sudo sh -c 'echo 2 > /sys/class/backlight/acx565akm/brightness'

In any case, wrapping that up in a script seems like a good idea.

You really don't want to run that by way of xterm, though, because then you'll end up with an xterm.

You might try making a .desktop file for it in /usr/share/applications/hildon/ , with NoDisplay=true so that it doesn't actually show up in the menu. You can then add a power-button menu entry similar to the sample one for panucci given in the original post.
 

The Following 3 Users Say Thank You to josh For This Useful Post:
Posts: 55 | Thanked: 72 times | Joined on Nov 2009
#10
Originally Posted by x-rated View Post
- What's the <po> tag anyway?
The <po> tag specifies a gettext translation domain. Software that provides support for multiple languages needs some way to look up the correct strings to use for specific messages in the current language. gettext represents one of the most popular such systems (by far the most popular in the Linux and FOSS world, and on other UNIX systems). gettext can take a string like "powerup_memainmenu_poweroff" (which appears in the "name" attribute of one of the default menuitem entries) and turn it into "Switch off!" in English. <po>osso-powerup-shutdown</po> tells systemui to go look in the osso-powerup-shutdown translation files, such as /usr/share/locale/en_US/LC_MESSAGES/osso-powerup-shutdown.mo . The abbreviation "po" comes from the file extension .po used as the source of the translation files; the .mo files represent a compressed format used to minimize storage space and make string lookups fast. For an example of a .po file, you can look at the osso-powerup-shutdown.po file that the systemui strings come from. For more information on gettext, check out the gettext manual.

Originally Posted by x-rated View Post
- Are those <title> and <po> in the beginning of systemui.xml (but not callui.xml) used for something?
I wondered that myself. powerup_application_title doesn't appear in any .mo file on my N900.

Originally Posted by x-rated View Post
- How exactly does this <callback> work, what do the parameters mean?
<callback> makes a D-Bus call. The attributes on that tag specify the interface to use and the method to call on that interface, and the <argument> child elements of <callback> specify the arguments of that method. For more information on D-Bus, take a look at http://dbus.freedesktop.org/doc/dbus-tutorial.html , and for some examples of some of the D-Bus methods supported by the phone, look at http://wiki.maemo.org/Phone_control .

For another example of <callback>, and a worked example of creating a menu item that uses most of the systemui features, take a look at my thread about adding an "End call" item.

I'll probably end up creating a wiki page documenting the systemui XML format, unless someone points out some existing documentation that we've both failed to find (on display in the bottom of a locked filing cabinet stuck in a disused lavatory with a sign on the door saying "Beware of The Leopard" ).
 

The Following 5 Users Say Thank You to josh For This Useful Post:
Reply


 
Forum Jump


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