OnBoard show and hide with Terminal

Asked by Julian on 2016-09-28

Hello,
is there a way to show and hide onBoard from Terminal?
Cause I want it to show from Programm and also Hide?
Something like "onBoard -show" and "onBoard-hide"?

Best Regards

Julian

Question information

Language:
English Edit question
Status:
Answered
For:
Onboard Edit question
Assignee:
No assignee Edit question
Last query:
2016-10-06
Last reply:
2016-10-08

This question was reopened

Francesco Fumanti (frafu) said : #1

Hi,

Thanks for your interest in Onboard.

It is possible to show and hide Onboard by using the terminal. You can find examples in the README:
http://bazaar.launchpad.net/~onboard/onboard/1.3/view/head:/README

Have a nice day.

Francesco

Julian (7husky) said : #3

Thanks Francesco Fumanti, that solved my question.

Julian (7husky) said : #4

Thanks it solved my problem. I still have onBoard 1.2 but with the 1.3 extensions

Francesco Fumanti (frafu) said : #5

Hi Julian,

Considering that you are running a system based on Ubuntu 16.04, you should be able to install Onboard 1.3 from our Stable PPA:
https://launchpad.net/~onboard/+archive/ubuntu/stable

Cheers,

Francesco

Julian (7husky) said : #6

Hi Francesco,
I get it worked with the terminal. But now I have another problem, when I tried to call it from C#.
I write

public static void ExecuteCommand(string command)
        {
            Process proc = new System.Diagnostics.Process();
            proc.StartInfo.FileName = "/bin/bash";
            proc.StartInfo.Arguments = "-c \" " + command + " \"";
            proc.StartInfo.UseShellExecute = false;
            proc.StartInfo.RedirectStandardOutput = true;
            proc.Start();

            while (!proc.StandardOutput.EndOfStream)
            {
                Console.WriteLine(proc.StandardOutput.ReadLine());
            }
        }

int main(){
 ExecuteCommand("exec dbus-send --type=method_call --print-reply --dest=org.onboard.Onboard /org/onboard/Onboard/Keyboard org.onboard.Onboard.Keyboard.Show");
}

And then an Error appeared:

org.freedesktop.Dbus.Error.ServiceUnknown: The name org.onboard.Onboard was not provided by any .service files

Do you have any suggestions?

Best regards,

Julian

Francesco Fumanti (frafu) said : #7

Hi marmuta,

I hope that everything is fine for you.

Could you please reply to this question? I guess that the problem is a file that is missing, but as I said, it is a guess.

Thanks in advance.

Francesco

On 2016-09-30 13:37, Julian wrote:
> Question #402422 on Onboard changed:
> https://answers.launchpad.net/onboard/+question/402422
>
> Status: Solved => Open
>
> Julian is still having a problem:
> Hi Francesco,
> I get it worked with the terminal. But now I have another problem, when I tried to call it from C#.
> I write
>
> public static void ExecuteCommand(string command)
> {
> Process proc = new System.Diagnostics.Process();
> proc.StartInfo.FileName = "/bin/bash";
> proc.StartInfo.Arguments = "-c \" " + command + " \"";
> proc.StartInfo.UseShellExecute = false;
> proc.StartInfo.RedirectStandardOutput = true;
> proc.Start();
>
> while (!proc.StandardOutput.EndOfStream)
> {
> Console.WriteLine(proc.StandardOutput.ReadLine());
> }
> }
>
> int main(){
> ExecuteCommand("exec dbus-send --type=method_call --print-reply --dest=org.onboard.Onboard /org/onboard/Onboard/Keyboard org.onboard.Onboard.Keyboard.Show");
> }
>
> And then an Error appeared:
>
> org.freedesktop.Dbus.Error.ServiceUnknown: The name org.onboard.Onboard
> was not provided by any .service files
>
> Do you have any suggestions?
>
> Best regards,
>
> Julian
>

marmuta (marmuta) said : #8

Julian, could you provide a complete example and build instructions? I tried
mcs onboard-dbus.cs
but that fails with
onboard-dbus.cs(3,14): error CS1525: Unexpected symbol `void', expecting `class', `delegate', `enum', `interface', `partial', or `struct'

Julian (7husky) said : #9

you must open it with mono. But i get the same error if I want to send this command via c++ to commandline. Maybe my Code is wrong ist there an example to open this ommands with any programming language?

marmuta (marmuta) said : #10

> you must open it with mono
mono onboard-dbus.cs
Cannot open assembly 'onboard-dbus.cs': File does not contain a valid CIL image.

I suppose it has to be built with mcs before. I'd appreciate detailed build instructions. Sorry, I don't know much about mono. There might be a problem with the environment of that particular ExecuteCommand call, but it's hard to tell if I can't even run it.

Usually programming languages don't need to launch dbus-send, since they have more direct support of D-Bus readily available. That's the benefit of having a D-Bus interface in Onboard after all. You're supposed to be able to use it from any language of your choosing. Don't know about mono/C#, though.

marmuta (marmuta) said : #11

Python:
file: onboard-dbus.py

import dbus

bus = dbus.SessionBus()
proxy = bus.get_object("org.onboard.Onboard", "/org/onboard/Onboard/Keyboard")
keyboard = dbus.Interface(proxy, "org.onboard.Onboard.Keyboard")
keyboard.Show()

Run:
python3 onboard-dbus.py

marmuta (marmuta) said : #12

C++ with Qt5:
file onboard-dbus-qt5.pro:

TEMPLATE = app
TARGET = onboard-dbus-qt5
INCLUDEPATH += .
QT += dbus

# Input
SOURCES += onboard-dbus-qt.cpp

file onboard-dbus-qt.cpp:

#include <QtCore>
#include <QDBusInterface>

int main() {
    QDBusInterface iface( "org.onboard.Onboard",
                          "/org/onboard/Onboard/Keyboard",
                          "org.onboard.Onboard.Keyboard",
                          QDBusConnection::sessionBus(), 0 );
    QDBusMessage reply = iface.call( "Show" );
    return 0;
}

Build with:
export QT_SELECT=5
qmake
make

Run:
./onboard-dbus-qt5

marmuta (marmuta) said : #13

C with GIO (GTK):

file onboard-dbus-gio.c:

#include <gio/gio.h>

int
main (int argc, char *argv[])
{
    GError *error = NULL;
    GDBusProxy *proxy = NULL;

    proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
                                           G_DBUS_PROXY_FLAGS_NONE,
                                           NULL, /* GDBusInterfaceInfo */
                                           "org.onboard.Onboard",
                                           "/org/onboard/Onboard/Keyboard",
                                           "org.onboard.Onboard.Keyboard",
                                           NULL, /* GCancellable */
                                           &error);
    if (proxy)
    {
        g_dbus_proxy_call_sync (proxy,
                                "Show",
                                NULL,
                                G_DBUS_CALL_FLAGS_NONE,
                                -1,
                                NULL,
                                &error);
    }

    if (proxy)
      g_object_unref (proxy);
    if (error)
      g_error_free (error);

  return 0;
}

Build with:
gcc -o onboard-dbus-gio onboard-dbus-gio.c $(pkg-config --cflags --libs gtk+-3.0)

Run:
./onboard-dbus-gio

Julian (7husky) said : #14

Thanks for this fast answers. I will try it Out tomorrow.

Julian (7husky) said : #15

It works, thanks!

Julian (7husky) said : #16

My Solution to run it in C# is. I create with Monodevelop a .so File in C. There I create a Function with the GTK C Code in it. And then I can import this C funktion in C# over this .so File. But now there is another Problem. I must run this Application as root. And then it doesn't work, cause of the Session Bus. I fixed this problem by replace "sudo *Applicationname*" with "sudo -u *username* *Applicationname*. But now there is my Question, is there another Way to manage this problem? I allready added "<allow user ="*"/> to the session.conf file in /usr/share/dbus-1, but it doesn't fix the Problem.

Do you have any suggestions?

Best regards
Julian

marmuta (marmuta) said : #17

Don't know, sorry. I haven't tried to use a session bus as root yet. I'd imagine that would be possible somehow, but I haven't done it yet. Onboard is not prepared to be run as root, though, this much I can tell.

Can you help with this problem?

Provide an answer of your own, or ask Julian for more information if necessary.

To post a message you must log in.