# HG changeset patch # User Christophe Lincoln # Date 1395582752 -3600 # Node ID 72c0e329d62ff8ff87a1085e6c69096d3502912c # Parent a4f64dd9b359f01bb09eb0cdd6d3830dbdda7f53 Add slitaz-config and clean tazx diff -r a4f64dd9b359 -r 72c0e329d62f tinyutils/slitaz-config --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tinyutils/slitaz-config Sun Mar 23 14:52:32 2014 +0100 @@ -0,0 +1,88 @@ +#!/bin/sh +# +# SliTaz Config - A tool with all SliTaz Ncurses configs in one place for +# text mode systems (server, ARM devices) +# +# Copyright (C) 2014 SliTaz ARM - BSD License +# Author: Christophe Lincoln +# +. /lib/libtaz.sh +check_root + +title="{ SliTaz Config }" +tmpdir="/tmp/$(basename $0)" +tmp="$tmpdir/$$" +height="20" +width="72" + +# Use a tmp directory +mkdir -p ${tmpdir} + +# +# GUI Functions +# + +# Set root passwd +root_passwd() { + dialog \ + --inputbox "Enter new root password:" \ + 10 ${width} 2>${tmp} + passwd=$(cat $tmp) + [ "$passwd" == "" ] && return 0 + echo "root:$passwd" | chpasswd --md5 +} + +set_date() { + clear && newline + echo -n "Old date:"; date + rdate -s 203.129.68.14 2>/dev/null + echo -n "New date:"; date + sleep 4 +} + +# Main Dialog menu +main_box() { + dialog \ + --clear --title "$title" \ + --ok-label "Exec" --cancel-label "Quit" \ + --menu "" ${height} ${width} 14 \ +"keyboard" "$(gettext 'System keyboard setting')" \ +"locale" "$(gettext 'System language setting')" \ +"root-passwd" "$(gettext 'Change root password')" \ +"set-date" "$(gettext 'Set system date from the web')" \ +"quit" "$(gettext 'Exit from SliTaz Config')" 2>${tmp} + + # Handle options + opt=${?} + case "$opt" in + 1|255) rm -rf ${tmpdir} && exit 0 ;; + esac + + # Handle actions + action=$(cat $tmp) + case "$action" in + keyboard) tazkeymap ;; + locale) tazlocale ;; + root-passwd) root_passwd ;; + set-date) set_date ;; + quit) rm -rf ${tmpdir} && exit 0 ;; + esac +} + +# +# Handle commands +# + +case "$1" in + *_*) + # Execute functions + $@ ;; + *) + while true; do + main_box + done ;; +esac + +# Clean exit +rm -rf ${tmpdir} +exit 0 diff -r a4f64dd9b359 -r 72c0e329d62f tinyutils/tazx --- a/tinyutils/tazx Wed Mar 19 19:27:02 2014 +0100 +++ b/tinyutils/tazx Sun Mar 23 14:52:32 2014 +0100 @@ -10,18 +10,21 @@ # # 20140317: most xsession, xinitrc are obsolete, provided system files -# are in /etc/skel and WM config files are no longer copied by tazx -# to user home. If some configs are needed by WMs they should be set -# by a /usr/bin/wmname-session script. +# are in /etc/skel and WM config files should no longer be copied by +# tazx to user home. If some configs are needed by WMs they should +# be set by a /usr/bin/wmname-session script I guess. - Pankso . /lib/libtaz.sh . /etc/slitaz/slitaz.conf +. /etc/slitaz/applications.conf + +installed="$PKGS_DB/installed" + export TEXTDOMAIN='slitaz-tools' #i18n - : ${DIALOG=dialog} # Default value. -WM=lxde-session +WM=${WINDOW_MANAGER} # Default user for config files in Live mode, id is 1000 since it is # created by /etc/init.d/bootopts.sh. @@ -144,10 +147,9 @@ case $value in quit) exit 0 ;; *) - installed=/var/lib/tazpkg/installed/ - [ -d "$installed/xorg-server" ] || tazpkg get-install xorg-server + [ -d "$installed/xorg-server" ] || tazpkg -gi xorg-server [ -d "$installed/xorg-xf86-video-$value" ] || \ - tazpkg get-install xorg-xf86-video-$value + tazpkg -gi xorg-xf86-video-$value xorg_conf_d ;; esac } @@ -158,13 +160,11 @@ exec 3>&1 value=$($DIALOG \ --clear --colors \ - --title " $(_n 'Configure X') " \ - --menu "\ -$(_n 'Tazx dialog helps you to configure your Xorg server.')\n\n\ -$(_n 'Window Manager:') \Z2$WM\Zn \n\ -$(_n 'X server:') \Z2Xorg\Zn" 16 70 3 \ - "xorg" "$(_n 'Install or reconfigure Xorg')" \ - "quit" "$(_n 'Quit Tazx utility')" \ + --title "{ $(_n 'SliTaz Xorg config') }" \ + --menu "" 16 72 10 \ + "xorg" "$(_n 'Install or reconfigure Xorg')" \ + "xorg-light" "$(_n 'Install Xorg server (light version)')" \ + "quit" "$(_n 'Quit Tazx utility')" \ 2>&1 1>&3) retval=$? exec 3>&- @@ -176,141 +176,50 @@ esac # Set selected value. - case $value in - xorg) + case "$value" in + xorg) install_xorg ;; - *) exit 0 ;; + xorg-light) + [ -d "$installed/xorg-server-light" ] || \ + tazpkg -gi xorg-server-light + [ -d "$installed/xorg-xf86-video-fbdev" ] || \ + tazpkg -gi xorg-xf86-video-fbdev + xorg_conf_d ;; + *) + exit 0 ;; esac } -# Window manager specific configuration. -wm_config() { - case $WM in - ob|openbox) - WM=openbox-session - # Check if a personal autostart script exists if OB is installed. - if [ -d "$INSTALLED/openbox" ]; then - if [ ! -f "$HOME/.config/openbox/autostart.sh" ]; then - mkdir -p $HOME/.config/openbox - cp /etc/xdg/openbox/autostart.sh $HOME/.config/openbox - fi - # Script for default user (uid=1000). - if [ ! -f "/home/$USER/.config/openbox/autostart.sh" ]; then - mkdir -p /home/$USER/.config/openbox - cp /etc/xdg/openbox/autostart.sh /home/$USER/.config/openbox - fi - if [ ! -f "/home/$USER/.config/openbox/menu.xml" ]; then - mkdir -p /home/$USER/.config/openbox - cp /etc/xdg/openbox/menu.xml /home/$USER/.config/openbox - fi - chown -R $USER.users /home/$USER/.config - fi ;; - jwm) - WM=jwm - JWM_CONFIG=$HOME/.jwmrc - if [ -d "$INSTALLED/jwm" ]; then - if [ ! -f "$JWM_CONFIG" ]; then - cp /etc/jwm/system.jwmrc $JWM_CONFIG - fi - # In Live mode default user/root JWM config does not exist and - # $HOME is not set, this is because tazx is executed by boot - # scripts. - if [ ! -f "/home/$USER/.jwmrc" ]; then - cp /etc/jwm/system.jwmrc /home/$USER/.jwmrc - chown $USER.users /home/$USER/.jwmrc - fi - if [ ! -f "/root/.jwmrc" -a $(id -u) = 0 ]; then - cp /etc/jwm/system.jwmrc /root/.jwmrc - fi - fi ;; - pekwm) - WM=pekwm - if [ -d "$INSTALLED/pekwm" ]; then - if [ -d "$HOME/.pekwm" ]; then - cp -R /etc/pekwm $HOME/.pekwm - fi - # In Live mode we want config before starting pekwm the first time. - if [ ! -d "/home/$USER/.pekwm" ]; then - cp -R /etc/pekwm /home/$USER/.pekwm - chown -R $USER.users /home/$USER/.pekwm - chmod +x /home/$USER/.pekwm/start - fi - if [ ! -d "/root/.pekwm" -a `id -u` = 0 ]; then - cp -R /etc/pekwm /root/.pekwm - chmod +x /root/.pekwm/start - fi - fi ;; - e17|enlightenment) - WM=enlightenment_start ;; - fluxbox) - WM=startfluxbox ;; - dwm|karmen) - WM=$WM-session ;; - awesome) - WM=awesome ;; - xfce|xfce4) - WM=xfce4-session ;; - esac -} - -# Sample xinitrc for user (WM can be specified with F1 at slim login). -xinitrc_sample() { - cat > $1 << "EOF" -# ~/.xinitrc: Executed by slim login manager to startx X session. -# You can use F1 with Slim to change your window manager or configure -# it permanently with your personal applications.conf file. -# -. $HOME/.config/slitaz/applications.conf - -case $1 in - e17|enlightenment*) exec enlightenment_start ;; - openbox|openbox-session|ob) exec openbox-session ;; - dwm|dwm-session) exec dwm-session ;; - fluxbox|startfluxbox) exec startfluxbox ;; - awesome) exec awesome ;; - pekwm) exec pekwm ;; - karmen|karmen-session) exec karmen-session ;; - jwm) lxpanel & exec jwm ;; - xfce|xfce4|xfce4-session) xfce4-session ;; - *) exec $WINDOW_MANAGER ;; -esac -EOF - # Set default WM in applications.conf user file. Default WM can be - # configured graphically with 'desktopbox tazapps' - . $CONFIG - sed -i 's|WINDOW_MANAGER=.*|WINDOW_MANAGER="'$WM'"|' $CONFIG -} - # ~/.xinitrc for X login from a DM. creat_xinitrc() { - local APCONF=/etc/slitaz/applications.conf - - CONFIG=$HOME/.config/slitaz/applications.conf - if [ ! -f $CONFIG ]; then - mkdir -p $(dirname $CONFIG); cp $APCONF $CONFIG + apps_conf=/etc/slitaz/applications.conf + user_conf="$HOME/.config/slitaz/applications.conf" + xinitrc="$HOME/.xinitrc" + if [ ! -f "$user_conf" ]; then + mkdir -p $(dirname $user_conf); cp ${apps_conf} ${user_conf} fi - xinitrc_sample $HOME/.xinitrc + if [ ! -f "$xinitrc" ]; then + cp /etc/skel/.xinitrc ${xinitrc} + fi # Make .xinitrc and config for /etc/skel so new added user will get # a working X session. if test $(id -u) = 0; then - CONFIG=/etc/skel/.config/slitaz/applications.conf - mkdir -p $(dirname $CONFIG); cp -f $APCONF $CONFIG - xinitrc_sample /etc/skel/.xinitrc + user_conf="/etc/skel/.config/slitaz/applications.conf" + mkdir -p $(dirname $user_conf); cp -f ${apps_conf} ${user_conf} fi - # In Live mode default user needs a xinitrc, since tazx - # is executed only by root. - CONFIG=/home/$USER/.config/slitaz/applications.conf - if [ ! -f $CONFIG ]; then - mkdir -p $(dirname $CONFIG); cp $APCONF $CONFIG + # In Live mode default user needs a xinitrc, since tazx is executed + # only by root. + user_conf="/home/$USER/.config/slitaz/applications.conf" + xinitrc="/home/$USER/.xinitrc" + if [ ! -f "$user_conf" ]; then + mkdir -p $(dirname $user_conf); cp ${apps_conf} ${user_conf} + chown -R $USER.users $(dirname $user_conf) fi - chown -R $USER.users /home/$USER/.config/slitaz - - FILE=/home/$USER/.xinitrc - if [ ! -f $FILE ]; then - xinitrc_sample $FILE - chown $USER.users $FILE + if [ ! -f "$xinitrc" ]; then + cp -f /etc/skel/.xinitrc ${xinitrc} + chown $USER.users ${xinitrc} fi } @@ -318,60 +227,44 @@ # only by startx, Slim login manager uses .xinitrc). creat_xsession() { local xsession=$HOME/.xsession - [ -f $xsession ] && cp -f $xsession $HOME/.previous_xsession - cat > $xsession << _EOF_ -# ~/.xsession: Start X window session manually on your system (startx). + [ -f "$xsession" ] && cp -f ${xsession} ${xsession}.bak + cat > ${xsession} << EOT +# ~/.xsession: Start X session manually on your system with: startx # Xorg & #xterm & -_EOF_ - # LXpanel by default with JWM. - if [ "$WM" = "jwm" ]; then - echo 'lxpanel &' >> $xsession - fi - echo "exec $WM" >> $xsession - chmod 700 $xsession +exec $WM +EOT + chmod 700 ${xsession} } - -# Commands - WM can be specified on cmdline. +# Commands case "$1" in install-xorg) - check_root $@ - if [ -n "$2" ]; then - WM=$2 - fi - echo "xorg" > /etc/X11/screen.conf + check_root install_xorg - wm_config creat_xinitrc creat_xsession ;; + config-xorg) - check_root $@ - if [ -n "$2" ]; then - WM=$2 - fi - echo "xorg" > /etc/X11/screen.conf - wm_config + check_root creat_xinitrc creat_xsession - xorg_conf_d + xorg_conf_d + # Handle live option: screen= if grep -qs screen= /proc/cmdline ; then MODE="$(sed 's/.*screen=\([0-9]*x[0-9]*\).*/\1/' < /proc/cmdline)" sed -i "s/.*EndSubSection.*/\\t\\tModes\\t\"$MODE\"\\n&/" \ /etc/X11/xorg.conf.d/70-Screen.conf fi ;; + + *help) + echo "Usage: $(basename $0) [install-xorg|config-xorg|]" ;; + *) # User can get a new .xinitrc with tazx from cmdline. - if [ -n "$1" ]; then - WM=$1 - fi - if test $(id -u) = 0; then - echo "xorg" > /etc/X11/screen.conf - config_dialog - fi - wm_config + [ $(id -u) == 0 ] && config_dialog creat_xinitrc creat_xsession ;; esac