Skip to content
Permalink
Browse files

Always pulse status bar while spawning processes synchronously

  • Loading branch information...
lpereira committed Jul 16, 2019
1 parent 0133e9f commit 3c83737fa488281f20030b5b36d7e1d4ba4313c9
@@ -202,7 +202,7 @@ char *dmi_get_str_abs(const char *id_str) {

/* try dmidecode, but may require root */
snprintf(full_path, PATH_MAX, "dmidecode -s %s", id_str);
spawned = g_spawn_command_line_sync(full_path,
spawned = hardinfo_spawn_command_line_sync(full_path,
&out, &err, &i, NULL);
if (spawned) {
if (i == 0)
@@ -303,7 +303,7 @@ char *dmidecode_read(const dmi_type *type) {
snprintf(full_path, PATH_MAX, "dmidecode");
}

spawned = g_spawn_command_line_sync(full_path,
spawned = hardinfo_spawn_command_line_sync(full_path,
&out, &err, &i, NULL);
if (spawned) {
if (i == 0)
@@ -99,9 +99,7 @@ static gboolean pci_fill_details(pcid *s) {
gchar *pci_loc = pci_address_str(s->domain, s->bus, s->device, s->function);
gchar *lspci_cmd = g_strdup_printf("lspci -D -s %s -vvv", pci_loc);

shell_status_pulse();

spawned = g_spawn_command_line_sync(lspci_cmd,
spawned = hardinfo_spawn_command_line_sync(lspci_cmd,
&out, &err, NULL, NULL);
g_free(lspci_cmd);
g_free(pci_loc);
@@ -213,9 +211,7 @@ static gboolean pci_get_device_lspci(uint32_t dom, uint32_t bus, uint32_t dev, u
s->device = dev;
s->function = func;

shell_status_pulse();

spawned = g_spawn_command_line_sync(lspci_cmd,
spawned = hardinfo_spawn_command_line_sync(lspci_cmd,
&out, &err, NULL, NULL);
g_free(lspci_cmd);
if (spawned) {
@@ -274,7 +270,7 @@ static pcid *pci_get_device_list_lspci(uint32_t class_min, uint32_t class_max) {

if (class_max == 0) class_max = 0xffff;

spawned = g_spawn_command_line_sync("lspci -D -mn",
spawned = hardinfo_spawn_command_line_sync("lspci -D -mn",
&out, &err, NULL, NULL);
if (spawned) {
p = out;
@@ -173,7 +173,7 @@ static gboolean usb_get_device_lsusb(int bus, int dev, usbd *s) {
s->bus = bus;
s->dev = dev;

spawned = g_spawn_command_line_sync(lsusb_cmd,
spawned = hardinfo_spawn_command_line_sync(lsusb_cmd,
&out, &err, NULL, NULL);
g_free(lsusb_cmd);
if (spawned) {
@@ -447,7 +447,7 @@ static usbd *usb_get_device_list_lsusb() {
usbd *head = NULL, *nd;
int bus, dev, vend, prod, ec;

spawned = g_spawn_command_line_sync("lsusb",
spawned = hardinfo_spawn_command_line_sync("lsusb",
&out, &err, NULL, NULL);
if (spawned) {
p = out;
@@ -1386,3 +1386,14 @@ gchar *hardinfo_clean_value(const gchar *v, int replacing) {
g_free((gpointer)v);
return clean;
}

gboolean hardinfo_spawn_command_line_sync(const gchar *command_line,
gchar **standard_output,
gchar **standard_error,
gint *exit_status,
GError **error)
{
shell_status_pulse();
return g_spawn_command_line_sync(command_line, standard_output,
standard_error, exit_status, error);
}
@@ -60,7 +60,7 @@ gboolean fill_glx_info(glx_info *glx) {
#define GLX_MATCH_LINE(prefix_str, struct_member) \
if (l = simple_line_value(p, prefix_str)) { glx->struct_member = g_strdup(l); goto glx_next_line; }

spawned = g_spawn_command_line_sync(glx_cmd,
spawned = hardinfo_spawn_command_line_sync(glx_cmd,
&out, &err, NULL, NULL);
g_free(glx_cmd);
if (spawned) {
@@ -124,7 +124,7 @@ gboolean fill_xinfo(xinfo *xi) {
#define XI_MATCH_LINE(prefix_str, struct_member) \
if (l = simple_line_value(p, prefix_str)) { xi->struct_member = g_strdup(l); goto xi_next_line; }

spawned = g_spawn_command_line_sync(xi_cmd,
spawned = hardinfo_spawn_command_line_sync(xi_cmd,
&out, &err, NULL, NULL);
g_free(xi_cmd);
if (spawned) {
@@ -166,7 +166,7 @@ gboolean fill_xrr_info(xrr_info *xrr) {
memset(status, 0, 128);
memset(alist, 0, 128);

spawned = g_spawn_command_line_sync(xrr_cmd,
spawned = hardinfo_spawn_command_line_sync(xrr_cmd,
&out, &err, NULL, NULL);
g_free(xrr_cmd);
if (spawned) {
@@ -193,4 +193,12 @@ gchar *hardinfo_clean_label(const gchar *v, int replacing);
/* hardinfo uses the values as {ht,x}ml, apparently */
gchar *hardinfo_clean_value(const gchar *v, int replacing);

/* Same as hardinfo_spawn_command_line_sync(), but calls shell_status_pulse()
* before. */
gboolean hardinfo_spawn_command_line_sync(const gchar *command_line,
gchar **standard_output,
gchar **standard_error,
gint *exit_status,
GError **error);

#endif /* __HARDINFO_H__ */
@@ -301,9 +301,9 @@ void scan_dev(gboolean reload)
}

if (detect_lang[i].stdout) {
found = g_spawn_command_line_sync(detect_lang[i].version_command, &output, &ignored, NULL, NULL);
found = hardinfo_spawn_command_line_sync(detect_lang[i].version_command, &output, &ignored, NULL, NULL);
} else {
found = g_spawn_command_line_sync(detect_lang[i].version_command, &ignored, &output, NULL, NULL);
found = hardinfo_spawn_command_line_sync(detect_lang[i].version_command, &ignored, &output, NULL, NULL);
}
g_free(ignored);

@@ -35,7 +35,7 @@ scan_boots_real(void)
else
return;

spawned = g_spawn_command_line_sync("last",
spawned = hardinfo_spawn_command_line_sync("last",
&out, &err, NULL, NULL);
if (spawned && out != NULL) {
p = out;
@@ -124,7 +124,7 @@ scan_languages(OperatingSystem * os)
locale_info *curr = NULL;
int last = 0;

spawned = g_spawn_command_line_sync("locale -va",
spawned = hardinfo_spawn_command_line_sync("locale -va",
&out, &err, NULL, NULL);
if (spawned) {
ret = g_strdup("");
@@ -47,7 +47,7 @@ get_libc_version(void)
gboolean spawned;
gchar *out, *err, *p;

spawned = g_spawn_command_line_sync(libs[i].test_cmd,
spawned = hardinfo_spawn_command_line_sync(libs[i].test_cmd,
&out, &err, NULL, NULL);
if (!spawned)
continue;
@@ -92,7 +92,7 @@ static gchar *detect_kde_version(void)
cmd = "kcontrol --version";
}

spawned = g_spawn_command_line_sync(cmd, &out, NULL, NULL, NULL);
spawned = hardinfo_spawn_command_line_sync(cmd, &out, NULL, NULL, NULL);
if (!spawned)
return NULL;

@@ -107,7 +107,7 @@ detect_gnome_version(void)
gchar *out;
gboolean spawned;

spawned = g_spawn_command_line_sync(
spawned = hardinfo_spawn_command_line_sync(
"gnome-shell --version", &out, NULL, NULL, NULL);
if (spawned) {
tmp = strstr(idle_free(out), _("GNOME Shell "));
@@ -118,7 +118,7 @@ detect_gnome_version(void)
}
}

spawned = g_spawn_command_line_sync(
spawned = hardinfo_spawn_command_line_sync(
"gnome-about --gnome-version", &out, NULL, NULL, NULL);
if (spawned) {
tmp = strstr(idle_free(out), _("Version: "));
@@ -140,7 +140,7 @@ detect_mate_version(void)
gchar *out;
gboolean spawned;

spawned = g_spawn_command_line_sync(
spawned = hardinfo_spawn_command_line_sync(
"mate-about --version", &out, NULL, NULL, NULL);
if (spawned) {
tmp = strstr(idle_free(out), _("MATE Desktop Environment "));
@@ -268,7 +268,7 @@ computer_get_dmesg_status(void)
{
gchar *out = NULL, *err = NULL;
int ex = 1, result = 0;
g_spawn_command_line_sync("dmesg", &out, &err, &ex, NULL);
hardinfo_spawn_command_line_sync("dmesg", &out, &err, &ex, NULL);
g_free(out);
g_free(err);
result += (getuid() == 0) ? 2 : 0;
@@ -388,7 +388,7 @@ parse_lsb_release(void)
gchar *id = NULL;
gchar **split, *contents, **line;

if (!g_spawn_command_line_sync("/usr/bin/lsb_release -di", &contents, NULL, NULL, NULL))
if (!hardinfo_spawn_command_line_sync("/usr/bin/lsb_release -di", &contents, NULL, NULL, NULL))
return (Distro) {};

split = g_strsplit(idle_free(contents), "\n", 0);
@@ -548,7 +548,7 @@ const gchar *
computer_get_selinux(void)
{
int r;
gboolean spawned = g_spawn_command_line_sync("selinuxenabled",
gboolean spawned = hardinfo_spawn_command_line_sync("selinuxenabled",
NULL, NULL, &r, NULL);

if (!spawned)
@@ -62,7 +62,7 @@ GSList *ubuntu_flavors_scan(void) {
if (!i)
return NULL;

spawned = g_spawn_command_line_sync(cmd_line,
spawned = hardinfo_spawn_command_line_sync(cmd_line,
&out, &err, &exit_status, NULL);
if (spawned) {
p = out;
@@ -161,7 +161,6 @@ void scan_dns(gboolean reload)
__nameservers = h_strdup_cprintf("%s=%s\n",
__nameservers,
ip, hbuf);

}

shell_status_pulse();
@@ -57,7 +57,7 @@ scan_samba_usershares(void)
gchar *usershare, *cmdline;
gsize length;

spawned = g_spawn_command_line_sync("net usershare list",
spawned = hardinfo_spawn_command_line_sync("net usershare list",
&out, &err, &status, NULL);

if (spawned && status == 0 && out != NULL) {
@@ -66,15 +66,14 @@ scan_samba_usershares(void)
while(next_nl = strchr(p, '\n')) {
cmdline = g_strdup_printf("net usershare info '%s'",
strend(p, '\n'));
if (g_spawn_command_line_sync(cmdline,
if (hardinfo_spawn_command_line_sync(cmdline,
&usershare, NULL, NULL, NULL)) {
length = strlen(usershare);
scan_samba_from_string(usershare, length);
g_free(usershare);
}
g_free(cmdline);

shell_status_pulse();
p = next_nl + 1;
}
g_free(out);
@@ -105,8 +104,6 @@ scan_samba_from_string(gchar *str, gsize length)

groups = g_key_file_get_groups(keyfile, NULL);
while (groups[i]) {
shell_status_pulse();

if (g_key_file_has_key(keyfile, groups[i], "path", NULL)) {
gchar *path = g_key_file_get_string(keyfile, groups[i], "path", NULL);
smb_shares_list = h_strdup_cprintf("%s=%s\n",

0 comments on commit 3c83737

Please sign in to comment.
You can’t perform that action at this time.