aboutsummaryrefslogtreecommitdiff
path: root/src/runscript.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/runscript.c')
-rw-r--r--src/runscript.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/runscript.c b/src/runscript.c
index 94df6fcc..dd0acb37 100644
--- a/src/runscript.c
+++ b/src/runscript.c
@@ -299,7 +299,6 @@ static void cleanup (void)
static int write_prefix (int fd, const char *buffer, size_t bytes, bool *prefixed) {
unsigned int i;
- int j;
const char *ec;
const char *ec_normal = ecolor (ecolor_normal);
ssize_t ret = 0;
@@ -316,11 +315,9 @@ static int write_prefix (int fd, const char *buffer, size_t bytes, bool *prefixe
if (! *prefixed) {
ret += write (fd, ec, strlen (ec));
- ret += write (fd, applet, strlen (applet));
- for (j = strlen (applet); j < 11; j++)
- ret += write (fd, " ", 1);
+ ret += write (fd, prefix, strlen (prefix));
ret += write (fd, ec_normal, strlen (ec_normal));
- ret += write (fd, " |", 2);
+ ret += write (fd, "|", 2);
*prefixed = true;
}
@@ -1082,11 +1079,23 @@ int main (int argc, char **argv)
/* eprefix is kinda klunky, but it works for our purposes */
if (rc_is_env ("RC_PREFIX", "yes")) {
- int l = strlen (applet);
- if (l < 13)
- l = 13;
- prefix = rc_xmalloc (sizeof (char *) * l);
- snprintf (prefix, l, "%s%s", applet, " ");
+ int l = 0;
+ char *svc;
+
+ /* Get the longest service name */
+ services = rc_services_in_runlevel (NULL);
+ STRLIST_FOREACH (services, svc, i) {
+ int ll = strlen (svc);
+ if (ll > l)
+ l = ll;
+ }
+ // rc_strlist_free (services);
+
+ svc = prefix = rc_xmalloc (sizeof (char *) * l);
+ svc += strlcpy (prefix, applet, l);
+ i = l - strlen (prefix);
+ memset (svc, ' ', i);
+ memset (svc + i, 0, 1);
eprefix (prefix);
}