3 * This file is part of LCDd, the lcdproc server.
5 * This file is released under the GNU General Public License. Refer to the
6 * COPYING file distributed with this package.
8 * Copyright (c) 1999, William Ferrell, Scott Scriven
12 * Implements the serverscreens
24 #include "shared/report.h"
25 #include "shared/configfile.h"
27 #include "drivers/lcd.h"
31 #include "screenlist.h"
34 #include "serverscreens.h"
38 #define MAX_SERVERSCREEN_WIDTH 40
41 Screen
*server_screen
;
42 int rotate_server_screen
= UNSET_INT
;
46 server_screen_init(void)
51 debug(RPT_DEBUG
, "server_screen_init");
53 /* Create the screen */
54 server_screen
= screen_create("_server_screen", NULL
);
56 report(RPT_ERR
, "server_screen_init: Error allocating screen");
59 server_screen
->name
= "Server screen";
60 server_screen
->duration
= RENDER_FREQ
; /* 1 second, instead of 4...*/
62 if ((rotate_server_screen
== UNSET_INT
) || (rotate_server_screen
== 1)) {
63 server_screen
->priority
= PRI_INFO
;
65 server_screen
->priority
= PRI_BACKGROUND
;
68 /* Create all the widgets...*/
69 for (line
= 1; line
<= 4; line
++) {
71 sprintf(id
, "line%d", line
);
73 w
= widget_create(id
, WID_STRING
, server_screen
);
75 report(RPT_ERR
, "server_screen_init: Can't create a widget");
78 screen_add_widget(server_screen
, w
);
81 w
->text
= malloc(MAX_SERVERSCREEN_WIDTH
+1);
84 strncpy(w
->text
, "LCDproc Server", MAX_SERVERSCREEN_WIDTH
);
90 /* And enqueue the screen*/
91 screenlist_add(server_screen
);
93 debug(RPT_DEBUG
, "server_screen_init done");
99 server_screen_shutdown(void)
104 screenlist_remove(server_screen
);
105 screen_destroy(server_screen
);
110 update_server_screen(void)
117 /* Now get info on the number of connected clients...*/
118 num_clients
= clients_client_count();
120 /* ... and screens */
122 for (c
= clients_getfirst(); c
!= NULL
; c
= clients_getnext()) {
123 num_screens
+= client_screen_count(c
);
126 /* Format strings for the appropriate size display... */
127 if (display_props
->height
>= 3) {
128 w
= screen_find_widget(server_screen
, "line2");
129 snprintf(w
->text
, MAX_SERVERSCREEN_WIDTH
,
130 "Clients: %i", num_clients
);
131 w
= screen_find_widget(server_screen
, "line3");
132 snprintf(w
->text
, MAX_SERVERSCREEN_WIDTH
,
133 "Screens: %i", num_screens
);
135 w
= screen_find_widget(server_screen
, "line2");
136 snprintf(w
->text
, MAX_SERVERSCREEN_WIDTH
,
137 ((display_props
->width
>= 16)
140 num_clients
, num_screens
);
153 if (config_has_key("Server", "GoodBye")) { /* custom GoodBye */
156 /* loop over all display lines to read config & display message */
157 for (i
= 0; i
< display_props
->height
; i
++) {
158 const char *line
= config_get_string("Server", "GoodBye", i
, "");
160 drivers_string(1, 1+i
, line
);
163 else { /* default GoodBye */
164 if ((display_props
->height
>= 2) && (display_props
->width
>= 16)) {
165 int xoffs
= (display_props
->width
- 16) / 2;
166 int yoffs
= (display_props
->height
- 2) / 2;
168 char *top
= "Thanks for using";
170 char *low
= "LCDproc & Linux!";
172 char *low
= " LCDproc! ";
175 drivers_string(1+xoffs
, 1+yoffs
, top
);
176 drivers_string(1+xoffs
, 2+yoffs
, low
);
180 drivers_cursor(1, 1, CURSOR_OFF
);