aboutsummaryrefslogtreecommitdiffstats
path: root/xenscreen.c
diff options
context:
space:
mode:
Diffstat (limited to 'xenscreen.c')
-rw-r--r--xenscreen.c57
1 files changed, 35 insertions, 22 deletions
diff --git a/xenscreen.c b/xenscreen.c
index 583d742..dab818d 100644
--- a/xenscreen.c
+++ b/xenscreen.c
@@ -28,7 +28,6 @@ static LIST_HEAD(doms);
static int domcnt;
static char *screenrc = "/etc/xen/xenscreenrc";
-//static char *screenrc = "/home/kraxel/projects/xenwatch/xenscreenrc";
static char *screen_session = "xencon";
static char *screen_title = "watch";
@@ -98,11 +97,13 @@ static void try_attach_screen(struct dom *dom, int boot)
rc = run_application(1, "screen", "screen",
"-X", "-S", screen_session,
- "screen", "-t", dom->name, dom->tty,
+ "screen", "-L", "-t", dom->name, dom->tty,
NULL);
#if 0
/*
- * Hmm, not exactly the most elegant way to do this.
+ * Hmm, not exactly the most elegant way to do this, has
+ * some ugly glitches too.
+ *
* Switches back from the new window to the previous one.
* Better would be to not switch in the first place,
* seems screen can't do that though :-(
@@ -130,6 +131,34 @@ static void try_release_domain(struct dom *dom)
free(dom);
}
+static void builtin_screen_setup(void)
+{
+ static char *config[] = {
+ "sorendition =s wb",
+ "hardstatus lastline \"%{=b bw} xen |%{-} %-w%{= yb} %50>%n* %t %{-}%+w%<\"",
+ "logfile /var/log/xenscreen.%t",
+ NULL /* EOF */,
+ };
+ char cmdline[256];
+ int line,try,rc;
+
+#if 1
+ /* FIXME: Hmm, doesn't work reliable without that one ... */
+ sleep(1);
+#endif
+
+ for (line = 0; config[line] != NULL; line++) {
+ for (try = 0; try < 5; try++) {
+ snprintf(cmdline, sizeof(cmdline), "screen -X -S %s %s",
+ screen_session, config[line]);
+ rc = run_cmdline(1,cmdline);
+ if (0 == rc)
+ break;
+ sleep(1);
+ }
+ }
+}
+
/* ------------------------------------------------------------- */
int main(int argc, char *argv[])
@@ -158,6 +187,7 @@ int main(int argc, char *argv[])
NULL);
if (0 == rc)
exit(0);
+
/* failing that, start a new screen session */
if (0 != access(screenrc, R_OK))
screenrc = "/dev/null";
@@ -170,25 +200,8 @@ int main(int argc, char *argv[])
exit(1);
} else if (0 != access(screenrc, R_OK)) {
- /* no screenrc: minimum setup (status line only) */
-#if 1
- /* Hmm, doesn't work without that one ... */
- sleep(1);
-#endif
- for (i = 0; i < 5; i++) {
- rc = run_application(1, "screen", "screen",
- "-X", "-S", screen_session,
- "sorendition", "=s", "wb",
- NULL);
- if (0 == rc)
- break;
- sleep(1);
- }
- rc = run_application(1, "screen", "screen",
- "-X", "-S", screen_session,
- "hardstatus", "lastline",
- "%{=b bw} xen |%{-} %-w%{= yb} %50>%n* %t %{-}%+w%<",
- NULL);
+ /* no screenrc: do mini setup */
+ builtin_screen_setup();
}
/* setup signal handler */