[SOLVED] How to launch a gui-app from a command line app.

Post Reply
Sebas_Ledesma
Posts: 120
Joined: Thu Jun 08, 2017 2:49 am
languages_spoken: english
ODROIDs: c2
Has thanked: 8 times
Been thanked: 6 times
Contact:

[SOLVED] How to launch a gui-app from a command line app.

Post by Sebas_Ledesma » Sat Jan 25, 2020 10:30 am

Hi;

My system uses a combo of command line apps and a big gui app.
I start the majority of command line apps from /etc/rc.local

I will like to close the gui_app from one command line app (done) and re-start again .
But so far with no success.

Extra info: My gui_app needs to run as sudo and I'm launching from a $/.config/autostart/mygui_app.desktop file.

Any suggestion it¿s welcomed.
Thanks in advance.

Sebas
Last edited by Sebas_Ledesma on Tue May 19, 2020 5:45 am, edited 2 times in total.

User avatar
mad_ady
Posts: 8155
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 568 times
Been thanked: 404 times
Contact:

Re: How to launch a gui-app from a command line app.

Post by mad_ady » Sat Jan 25, 2020 3:02 pm

You should be able to start gui apps with systemd provided that they run with the same user as x11 and you set DISPLAY=:0

Sebas_Ledesma
Posts: 120
Joined: Thu Jun 08, 2017 2:49 am
languages_spoken: english
ODROIDs: c2
Has thanked: 8 times
Been thanked: 6 times
Contact:

Re: How to launch a gui-app from a command line app.

Post by Sebas_Ledesma » Tue May 19, 2020 3:35 am

Thanks!
With your help and other info I've solved this way:

Code: Select all

//Closes / Launch myApp
	if (checkProgramRunning("myApp")) {
		system("pkill myApp");
	}
	else {
		system("export DISPLAY=:0; myApp &");
	}
Sebas
These users thanked the author Sebas_Ledesma for the post:
odroid (Tue May 19, 2020 9:41 am)

Sebas_Ledesma
Posts: 120
Joined: Thu Jun 08, 2017 2:49 am
languages_spoken: english
ODROIDs: c2
Has thanked: 8 times
Been thanked: 6 times
Contact:

Re: [SOLVED] How to launch a gui-app from a command line app.

Post by Sebas_Ledesma » Thu Jun 25, 2020 4:41 am

Just for forward reference.
As alterntive, specify the user with su command:

Code: Select all

//Closes / Launch myApp
	if (checkProgramRunning("myApp")) {
		system("pkill myApp");
	}
	else {
		system("export DISPLAY=:0; su odroid -c 'myApp' &");
	}
Sebas
These users thanked the author Sebas_Ledesma for the post:
odroid (Thu Jun 25, 2020 8:41 am)

Post Reply

Return to “Ubuntu”

Who is online

Users browsing this forum: No registered users and 0 guests