Hi, nachdem ich mir jetzt so viel gebastelt habe um vdr-sxfe in verschiedenen Situationen komfortabel zu starten: Vielleicht kann es ja noch jemand brauchen.
Der Knackpunkt ist: Das Script nutzt automatisch den X-Server, auf dem kdm läuft, wenn es remote über SSH gestartet wird und keine KDE-Session aktiv ist. Kann man wahrscheinlich auch für Gnome anpassen. So kann man bequem den Desktop-PC zum Fernseher umfunktionieren und am Notebook fernbedienen.
Erstmal das Startscript:
/usr/local/bin/vdrc
#!/bin/bash
if ! ps x | egrep -q "[k]deinit"; then
if ! ps ax | egrep -q "[k]dm_greet"; then
echo "Neither KDE nor KDM running, giving up!" >&2
exit 1
fi
echo "KDE not running, using KDM screen for TV"
# sudo /usr/local/sbin/getkdmauth.sh >~/.Xauthority
getkdmauth >~/.Xauthority
DISPLAYOPT="--fullscreen"
HOST=$1
elif test "x$1" = "x-fs"; then
DISPLAYOPT="--fullscreen"
HOST=$2
else
DISPLAYOPT="--width=1024 --height=576"
HOST=$1
fi
exec \
vdr-sxfe --video=xv --audio=alsa \
${DISPLAYOPT} xvdr://${HOST:-127.0.0.1}
Alles anzeigen
In einer laufenden KDE-Session kann es so aufgerufen werden:
vdrc [-fs] [host]
(-fs startet im Vollbild, mit host kann ein entfernter Rechner angegeben werden, auf dem VDR mit xineliboutput läuft)
Damit auch die Anzeige auf dem KDM-Schirm funktioniert, ist noch ein Programm nötig, das das xauth-File von KDM "klaut". Entweder dieses Programm:
#include <sys/types.h>
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
char pathbuf[128];
char exebuf[128];
char buf[1024];
int main(void)
{
strcpy(pathbuf, "/proc");
struct dirent* entry;
DIR* proc = opendir(pathbuf);
pathbuf[5] = '/';
int num;
int found = 0;
if (!proc)
{
perror("Error opening /proc");
exit(1);
}
entry = readdir(proc);
while (entry)
{
if ((*entry->d_name > '0') && (*entry->d_name < '9'))
{
strncpy(pathbuf + 6, entry->d_name, 118);
strcat(pathbuf, "/exe");
num = readlink(pathbuf, exebuf, 127);
if ((num > 4) && (strncmp(exebuf + num - 5, "/Xorg", 5)) == 0)
{
strncpy(pathbuf + 6, entry->d_name, 115);
strcat(pathbuf, "/cmdline");
found = 1;
break;
}
}
entry = readdir(proc);
}
closedir(proc);
if (!found)
{
fprintf(stderr, "Couldn't find Xorg process.\n");
exit(1);
}
FILE* cmdline = fopen(pathbuf, "r");
if (!cmdline)
{
perror("Error opening cmdline file");
exit(1);
}
fread(buf, 1024, 1, cmdline);
fclose(cmdline);
buf[1023] = '\0';
char* part = buf;
found = 0;
while (part < buf + 1024 - 7)
{
if (strcmp(part, "-auth") == 0)
{
part += 6;
found = 1;
break;
}
part += strlen(part) + 1;
}
if (!found)
{
fprintf(stderr, "Couldn't find X11 auth-file in Xorg cmdline.\n");
exit(1);
}
FILE* auth = fopen(part, "r");
if (!auth)
{
perror("Error opening X11 auth file");
exit(1);
}
num = fread(buf, 1, 1023, auth);
fclose(auth);
fwrite(buf, 1, num, stdout);
return 0;
}
Alles anzeigen
compilieren und suid-root in /usr/local/bin ablegen, z.B. so:
Dann kann jeder in der Gruppe "staff" xauth von KDM "klauen".
Oder ewin wesentlich einfacheres (weniger elegantes) Shellscript zusammen mit sudo:
/usr/local/sbin/getkdmauth.sh
Das muss dann mit visudo so konfiguriert werden, dass entsprechende User es ohne Passwort ausführen dürfen.