Browse Source

Reconfigure font-server and start it when conditions are appropriate

K. Lange 4 years ago
parent
commit
120f95c584
2 changed files with 20 additions and 3 deletions
  1. 12 3
      apps/font-server.c
  2. 8 0
      base/etc/startup.d/91_font_server.sh

+ 12 - 3
apps/font-server.c

@@ -16,8 +16,12 @@
 #include <unistd.h>
 #include <syscall.h>
 
+#if 0
 #include <toaru/trace.h>
 #define TRACE_APP_NAME "font-server"
+#else
+#define TRACE(...)
+#endif
 
 #define FONT_PATH "/usr/share/fonts/"
 #define FONT(a,b) {a, FONT_PATH b}
@@ -78,10 +82,15 @@ static void load_fonts(char * server) {
 
 int main(int argc, char * argv[]) {
 
-	load_fonts(getenv("DISPLAY"));
+	/* Daemonize */
+	if (!fork()) {
+		load_fonts("fonts");
 
-	while (1) {
-		usleep(100000);
+		while (1) {
+			usleep(100000);
+		}
+
+		return 0;
 	}
 
 	return 0;

+ 8 - 0
base/etc/startup.d/91_font_server.sh

@@ -0,0 +1,8 @@
+#!/bin/sh
+
+# Only start if we're likely to be running a GUI
+export-cmd START kcmdline -g start
+if equals? "$START" "--vga" then exit
+if equals? "$START" "--headless" then exit
+
+if stat -Lq /usr/share/fonts/DejaVuSansMono.ttf then font-server