You are not logged in.

#1 2024-05-31 15:43

FlexQ4
Member
Registered: 2017-02-19
Posts: 160

Cannot start "htop" out of a small C-program

Hello,
out of a small C-program i tried to start the "htop" application:

#include <stdlib.h>

int main(int argc,char* argv[]) {

 // By calling fork(), a child process will be created:
    if (fork() == 0) { 
        // Child process will return 0 from fork()
        printf("I'm the child process.\n");
        int status = system(<app-name>);
        exit(0);
    } else {
        // Parent process gets a non-zero value from fork()
        printf("I'm the parent.\n");
    }
    return 0;
}

Now, with <app-name> = "kcalc", it does start the calculator, with <app-name> = "kwrite" it starts "KWrite", or with <app-name> = "gnome-system-monitor" the app starts as well.

But neither <app-name> = "htop", nor <app-name> = "/usr/bin/htop", nor <app-name> = "/bin/sh  /usr/bin/htop" nor anything else worked to start "Htop" on Q4OS 4.12!

Any suggestions?
Thank you!

Offline

#2 2024-05-31 16:05

q4osteam
Q4OS Team
Registered: 2015-12-06
Posts: 4,436
Website

Re: Cannot start "htop" out of a small C-program

You need to start htop in terminal, so app-name would be for example "konsole -e htop"

Offline

#3 2024-05-31 17:10

FlexQ4
Member
Registered: 2017-02-19
Posts: 160

Re: Cannot start "htop" out of a small C-program

Fantastic - that works!

I'm writing e natty small utility that runs in the tray-panel, showing the cpu-load grahically (much similarly to Sys-internals' process explorer). By clicking on it - as you know now - it does start "htop".
Is there a private channel by which i could send you a preliminary (but working!) version of it?
For now it runs nicely and stable in my TDE-Windows-like desktop - which i won't change, even temporarily - and it would be helpful to know how it looks and works on other (Plasma) desktops. And possibly, maybe, it would be even something to add to Q4OS...

Have a nice weekend!

Offline

#4 2024-05-31 17:58

q4osteam
Q4OS Team
Registered: 2015-12-06
Posts: 4,436
Website

Re: Cannot start "htop" out of a small C-program

smile You can send the project on our e-mail devteam@q4os.org , however a better way would be to start project on GitHub and share for us https://github.com/q4osteam

Offline

#5 2024-06-02 14:44

FlexQ4
Member
Registered: 2017-02-19
Posts: 160

Re: Cannot start "htop" out of a small C-program

Hello again, and thank you!
when creating a small menu with code like this:

#include <gtk/gtk.h>
#include <glib/gerror.h>
#include <gdk-pixbuf/gdk-pixbuf.h>

static void menu_Quit( GtkWidget *item, gpointer data) {
    exit (0);
}
static GtkWidget *make_menu_item (gchar *name, GCallback callback,
		                          gpointer data )
{   GtkWidget *item;
    item = gtk_image_menu_item_new_with_mnemonic (name);
    g_signal_connect (item, "activate", callback, (gpointer) data);
    gtk_widget_show (item);
    return item;
}
        ...
        GtkWidget *kmenu = gtk_menu_new();
        GtkWidget *sepline;
        GtkWidget *quititem;

        sepline = gtk_separator_menu_item_new();
        gtk_menu_shell_append (GTK_MENU_SHELL(kmenu), sepline);

        quititem = make_menu_item ("_Quit", G_CALLBACK (menu_Quit), NULL);
  	gtk_image_menu_item_set_image(
				GTK_IMAGE_MENU_ITEM (quititem),
			        gtk_image_new_from_icon_name ("application-exit",
				GTK_ICON_SIZE_MENU) );

        gtk_menu_shell_append (GTK_MENU_SHELL(kmenu), quititem);

        gtk_widget_show_all (kmenu);
        gtk_menu_popup (GTK_MENU(kmenu), NULL, NULL, NULL, NULL, 3, 0);

i noticed that the created menu differs (slightly) from those in standard apps like KMix, Klipper or Ksensors:
- the separator line is a simple line, without ,depth'
- no icon (red square, white circle and line within) appears left to the label

How can i create a standard-like menu?
Many thanks

Edit: i added some includes in the source and a call of  gtk_image_menu_item_set_image.
Now an icon is shown (left to the Quit-label) but it's a small opened door and a red arrow.
That differes (likewise the seperator line) from the look and the icons used in the other apps.

So, what can i do to make it look like ,standard' on my desktop? Is the GTK version wrong or do i have to load another iconset?

Last edited by FlexQ4 (2024-06-02 17:02)

Offline

#6 2024-06-03 09:27

seb3773
Member
Registered: 2023-11-01
Posts: 146

Re: Cannot start "htop" out of a small C-program

Maybe this can help/inspire you: https://github.com/seb3773/lxtask-mod

It's a fork of lxtask (GTK2 version); I added several options, including a system tray icon that indicates CPU usage (I used images for the icon).


My Q4OS scripts: win10/osx theming, perfs optimisation, laptop configuration, ...  for trinity users -->  https://github.com/seb3773/q4osXpack

Offline

#7 2024-06-03 11:53

FlexQ4
Member
Registered: 2017-02-19
Posts: 160

Re: Cannot start "htop" out of a small C-program

Well, with my code above i get this "stock exit" icon (beside "Quit"):
http://irtfweb.ifa.hawaii.edu/SoftwareD … xit_24.png

All other k-Apps (Klipper, KMix,...) have another icon: a red square with a White circle, like beside "Log Out..." in the lower left corner of this screenshot:
https://upload.wikimedia.org/wikipedia/ … opment.png

So, (how) is it possible to get the Standard TDE-Icons in my GTK program?

Offline

#8 2024-06-08 13:46

seb3773
Member
Registered: 2023-11-01
Posts: 146

Re: Cannot start "htop" out of a small C-program

maybe it has to do with the gtk icons theme ? TDE / GTK2 / GTK3 themes can have differents icons set


My Q4OS scripts: win10/osx theming, perfs optimisation, laptop configuration, ...  for trinity users -->  https://github.com/seb3773/q4osXpack

Offline

Board footer

Powered by FluxBB