WordClock – basierend auf raspberry – Installation

25. November 2013 at 22:52
Print Friendly, PDF & Email

Update 2017: die aktuelle Version liegt hier: https://github.com/Snapstromegon/wordclock

Step 1) Browser erzeugen & installieren

Die Wordclock benötigt einen browser, der webkit unterstützt

Chromium frisst zu viele Resourcen und Midori hat nicht das geboten, was ich wollte.

Es gibt einen einfachen Browser: kiosk-browser von Peter Schultz auf github.

apt-get install libwebkit-devc
cd
nano browser.c
#include "stdio.h"
#include "signal.h"
 
#include "gtk/gtk.h"
#include "gdk/gdkkeysyms.h"
#include "webkit/webkit.h"
 
gboolean on_key_press(GtkWidget*, GdkEventKey*, gpointer);
 
void reload_browser(int);
void toggle_fullscreen(int);
void maximize();
void unmaximize();
 
static WebKitWebView* web_view;
static GtkWidget *window;
gchar* default_url = "https://www.google.de";
 
int main(int argc, char** argv) {
  gtk_init(&argc, &argv);
 
  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
 
  gtk_window_set_default_size(GTK_WINDOW(window), 1280, 1024);
  gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER_ALWAYS);
  g_signal_connect(window, "key-press-event", G_CALLBACK(on_key_press), NULL);
  g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
 
  web_view = WEBKIT_WEB_VIEW(webkit_web_view_new());
 
  signal(SIGHUP, reload_browser);
  signal(SIGUSR1, toggle_fullscreen);
 
  gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(web_view));
 
  if(argc > 1) {
    webkit_web_view_load_uri(web_view, argv[1]);
  }
  else {
    webkit_web_view_load_uri(web_view, default_url);
  }
 
  maximize();
  gtk_widget_show_all(window);
  gtk_main();
 
  return 0;
}
gboolean on_key_press(GtkWidget* window, GdkEventKey* key, gpointer userdata) {
  if(key->type == GDK_KEY_PRESS && key->keyval == GDK_F5) {
    reload_browser(0);
  }
  else if(key->type == GDK_KEY_PRESS && key->keyval == GDK_F11) {
    toggle_fullscreen(0);
  }
 
  return FALSE;
}
 
void reload_browser(int signum) {
  webkit_web_view_reload_bypass_cache(web_view);
}
 
void toggle_fullscreen(int signum) {
  if(gtk_window_get_decorated(GTK_WINDOW(window))) {
    maximize();
  }
  else {
    unmaximize();
  }
}
 
void maximize() {
  gtk_window_maximize(GTK_WINDOW(window));
  gtk_window_fullscreen(GTK_WINDOW(window));
  gtk_window_set_decorated(GTK_WINDOW(window), FALSE);
}
void unmaximize() {
  gtk_window_unmaximize(GTK_WINDOW(window));
  gtk_window_unfullscreen(GTK_WINDOW(window));
  gtk_window_set_decorated(GTK_WINDOW(window), TRUE);
  gtk_window_resize(GTK_WINDOW(window), 1280, 768);
}
<code>gcc -o browser browser.c $(pkg-config --libs --cflags gtk+-2.0 webkit-1.0) sudo cp browser /usr/local/bin</code>

Step 2) Setup & install xorg adn nodm; Siehe auch Anleitung von nexxylove befolgt.

sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install xorg nodm

Step 3) Create your kiosk user, add it to any relevant groups (www-data?).

sudo useradd -g www-data kiosk
passwd kiosk
sudo usermod -a -G www-data kiosk
cd /home
sudo mkdir kiosk
sudo chown kiosk kiosk

Step 5) Log in as your kiosk user.

Step 6) Create ~/.xsession, add the following;

#!/bin/bash
/usr/local/bin/browser  file:///var/www/clock.html

Step 7) Edit sudo /etc/default/nodm

NODM_ENABLED=true
NODM_USER=kiosk;
NODM_X_OPTIONS='-nolisten tcp -s 0 dpms'

Step 6) Edit sudo nano /etc/X11/default-display-manager
Dann wird noch in /etc/X11/default-display-manager statt /usr/sbin/lightdm einfach /usr/sbin/nodm  eingetragen

/usr/sbin/nodm

Step 8) Auto login

sudo nano /etc/inittab

Disable the getty program.
Navigate to the following line in inittab

1:2345:respawn:/sbin/getty 115200 tty1

And add a # at the beginning of the line to comment it out

#1:2345:respawn:/sbin/getty 115200 tty1

Add the following line just below the commented line

1:2345:respawn:/bin/login -f kiosk tty1 &lt;/dev/tty1 &gt;/dev/tty1 2&gt;&amp;1

Step 9) create clock.html file in /var/www/ and set permissions

sudo mkdir -p /var/www
sudo chown www-data:www-data /var/www
sudo chmod 775 /var/www
Tags: