source: pkg/main/restartx-parsix/trunk/restartx @ 2411

Revision 2411, 2.4 KB checked in by alanbach-guest, 6 years ago (diff)
  • Minor fixes to be more parsix-native
Line 
1#!/bin/bash +x
2# restartx - restart desktop in KNOPPIX
3# (C) Klaus Knopper Mar 2004
4
5PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/local/bin"
6export PATH
7
8XDIALOG_HIGH_DIALOG_COMPAT=1
9export XDIALOG_HIGH_DIALOG_COMPAT
10
11# Get root
12[ "`id -u`" != "0" ] && exec sudo "$0" "$@"
13
14TMP="/tmp/restartx.tmp$$"
15
16bailout(){
17rm -f "$TMP"
18exit 0
19}
20
21DIALOG="dialog"
22[ -n "$DISPLAY" ] && [ -x /usr/bin/Xdialog ] && DIALOG="Xdialog"
23
24trap bailout 1 2 3 15
25
26# LANGUAGE etc.
27[ -f /etc/sysconfig/parsix ] && . /etc/sysconfig/parsix
28[ -z "$LANG" ] && export LANG
29[ -z "$LANGUAGE" ] && export LANGUAGE
30[ -z "$CHARSET" ] && export CHARSET
31[ -f /etc/sysconfig/desktop ] && . /etc/sysconfig/desktop
32
33# Shortcut desktop description selected
34DESKTOPS=(kde "KDE - The K Desktop Environment" on \
35gnome "GNOME - The object-oriented desktop" off \
36wmaker "Window Maker" off \
37icewm "Ice WM" off \
38xfce "XFCE 3" off \
39xfce4 "XFCE 4" off \
40fluxbox "FluxBox" off \
41larswm "LarsWM" off \
42lg3d "Looking Glass" off \
43openbox "OpenBox" off \
44ratpoison "RatPoison" off \
45twm "TWM" off)
46# Corresponding commands for "which"
47COMMANDS=(startkde gnome-session wmaker icewm-session xfce xfce4-session fluxbox larswm lg3d openbox ratpoison twm)
48
49# Language-dependent Messages
50case "$LANGUAGE" in
51de*|at*|ch*)
52TITLE1="Parsix X-Restart"
53MESSAGE1="Bitte gewünschten Desktop/Windowmanager auswählen:"
54MESSAGE2="
55Wollen Sie jetzt wirklich den X-Server neu starten? Alle laufenden Programme mit Grafikausgabe werden beendet!"
56;;
57*)
58TITLE1="Parsix X-Restart"
59MESSAGE1="Please chose Desktop/Windowmanager"
60MESSAGE2="
61Do you REALLY want to restart the X-Server now? All running programs with graphics output will be terminated!"
62;;
63esac
64
65num=${#COMMANDS[@]}
66for ((i=0; i<$num; i++)); do
67# Remove non-existing desktops/descriptions from list
68d0="$(($i * 3))"
69d1="$(($i * 3 + 1))"
70d2="$(($i * 3 + 2))"
71if type "${COMMANDS[$i]}" >/dev/null 2>&1; then
72[ "$DESKTOP" = "${DESKTOPS[$(($i * 3))]}" ] && DESKTOPS[$(($i * 3 + 2))]="on" || DESKTOPS[$(($i * 3 + 2))]="off"
73else
74unset DESKTOPS[$d0]
75unset DESKTOPS[$d1]
76unset DESKTOPS[$d2]
77unset COMMANDS[$i]
78fi
79done
80
81rm -f "$TMP"
82$DIALOG --clear --title "$TITLE1" --radiolist "$MESSAGE1" 18 75 9 "${DESKTOPS[@]}" 2>"$TMP" || bailout
83
84echo "DESKTOP=\"$(<$TMP)\"" >>/etc/sysconfig/desktop
85echo "DESKTOP=\"$(<$TMP)\"" >>/etc/sysconfig/parsix
86
87rm -f "$TMP"
88
89$DIALOG --title "$TITLE1" --yesno "$MESSAGE2" 8 65 || bailout
90
91/etc/init.d/xsession restart
92
93exit $?
Note: See TracBrowser for help on using the repository browser.