Opened 9 years ago

Closed 6 years ago

#461 closed enhancement/feature request (fixed)

osd button to run arbitrary command

Reported by: zoff99 Owned by: number6
Priority: minor Milestone: want patch / contribution
Component: core Version: git master
Severity: Keywords: osd user definable commands
Cc: nick@…, heinold@…

Description

it would be cool (and almost no work i think) to have an OSD button with icon, that runs a shell command or program.
it would allow for cool customization without recompiling!

sample idea:

<osd enabled="yes" type="shell_button" x="-96" y="-126" align="0" command="/usr/bin/do_something.sh" src="my_cool_button.png" />

you could put buttons in navit to switch stuff on and off on your device. or start agps download. whatever ...

Attachments (7)

sys_cmd.diff (4.3 KB) - added by perepujal 8 years ago.
GDB_Dump.txt (14.3 KB) - added by number6 8 years ago.
Dump from gdb on opensuse 11.3
navit.diff.works.on.opensuse.c (3.6 KB) - added by number6 8 years ago.
Proper diff
spawn.diff (2.7 KB) - added by tryagain 8 years ago.
New version of external command patch. It seems to work on WinCE and Linux. Idea what functions to use is stolen from speech_cmdline.c. Example for linux: <osd enabled="yes" type="button" x="0" y="-96" command='spawn("/bin/echo","Hi")' src="zoom_out.svg"/>.
spawn.2.diff (4.0 KB) - added by tryagain 8 years ago.
Now using attr_to_text function to get textual representation so attributes of virtually any type can be used as parameter for spawn. Also internal command joinstr(separator, arg1, arg2, arg3, ...) added - it joins several strings into one, adding separator between them.
spawn_process.diff (10.2 KB) - added by tryagain 8 years ago.
Alpha version of spawn_process.
spawn_fix.diff (1.3 KB) - added by tryagain 8 years ago.
Fixes spawn() command (for OSD button) and speech_cmdline on desktop Windows. I've got it compiling and working on desktop Windows with built-in glib, compiled with MSYS/mingw.

Download all attachments as: .zip

Change History (17)

comment:1 Changed 9 years ago by kazer

  • Milestone set to version 0.3.0

comment:2 Changed 9 years ago by mvglasow (2)

A slightly different implementation idea: implement a command like "shell" for the navit object. That way the functionality is available regardless of the GUI (as far as I know, the QML GUI also provides a way to call Navit commands; not sure about the others).

The button would then be defined as

<osd enabled="yes" type="button" x="-96" y="-126" align="0" command="navit.shell_('/usr/bin/do_something.sh')" src="my_cool_button.png" />

Should be fairly easy (once you've gotten into the inner workings of commands in navit), the only "open issue" is how to pass string arguments (single quotes? double quotes? escaped quotes?), but even that should be resolvable.

Changed 8 years ago by perepujal

comment:3 Changed 8 years ago by perepujal

Attaching a patch against navit.c, it works for me, but it is really meant to get feedback. Call it with <osd enabled="yes" type="button" command='sys_cmd("full_path", "parm1", "parm2")' ...

Changed 8 years ago by number6

Dump from gdb on opensuse 11.3

comment:4 Changed 8 years ago by number6

  • Cc nick@… added
  • Owner changed from KaZeR to number6

GDB dump for my own personal edification. Unless someone else can see what's wrong?

N

comment:5 follow-up: Changed 8 years ago by number6

  • Keywords osd user definable commands added
  • Milestone changed from version 0.5.0 to want patch / contribution

Attached is a modified diff.

It looks like a valid position is needed for the original patch to work.

If someone could make this code portable for Win32 and WinCE, you'll win a gold star.

Good work, perepujal. You've laid the ground-work for greater things.

comment:6 in reply to: ↑ 5 Changed 8 years ago by perepujal

Replying to http://wiki.navit-project.org/index.php/user:number6:

Attached is a modified diff.

It looks like a valid position is needed for the original patch to work.

Yep, I need geo data for a custom script I made, not sure if I will reach to pass geo data as a parameter in the xml file or if this belongs to a different thing than sys command.

If someone could make this code portable for Win32 and WinCE, you'll win a gold star.

After the wikipedia, the solution would be an #ifdef and spawn: int spawnv(int mode, char *path, char argv); http://en.wikipedia.org/wiki/Spawn_(computing)

Changed 8 years ago by number6

Proper diff

Changed 8 years ago by tryagain

New version of external command patch. It seems to work on WinCE and Linux. Idea what functions to use is stolen from speech_cmdline.c. Example for linux: <osd enabled="yes" type="button" x="0" y="-96" command='spawn("/bin/echo","Hi")' src="zoom_out.svg"/>.

Changed 8 years ago by tryagain

Now using attr_to_text function to get textual representation so attributes of virtually any type can be used as parameter for spawn. Also internal command joinstr(separator, arg1, arg2, arg3, ...) added - it joins several strings into one, adding separator between them.

Changed 8 years ago by tryagain

Alpha version of spawn_process.

comment:7 Changed 8 years ago by tryagain

With spawn_process.diff I have currently following questions:

  • It is not tested on desktop Windows (but I hope, it should work)
  • spawn_process_check_status behaves strangely on linux with block=0. It always report that child is terminated by signal 191.
  • spawn_process seems to do improper quoting on WinCE. I'm going to remove quoting for this platform in next release.

Testing sample for navit.xml: <osd enabled="yes" type="button" x="0" y="-196" command='spawn("/bin/sleep", "5" )' src="zoom_out.svg"/>

I'd like to have any feedback on the above problems and on the patch as a whole.

Changed 8 years ago by tryagain

Fixes spawn() command (for OSD button) and speech_cmdline on desktop Windows. I've got it compiling and working on desktop Windows with built-in glib, compiled with MSYS/mingw.

comment:8 Changed 8 years ago by woglinde

  • Cc heinold@… added

Modified version of spawn_process.diff was apllied in revision http://navit.svn.sourceforge.net/viewvc/navit?view=revision&revision=4459

comment:9 Changed 8 years ago by woglinde

Hi,

spwan_fix.diff was applied with revision http://navit.svn.sourceforge.net/viewvc/navit?view=revision&revision=4503

Bye Henning

comment:10 Changed 6 years ago by tryagain

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.