#!/bin/bash
################################################################################
# Fichier : icewm.sh
# Auteur : Sebastien Beaugrand
# Date : 05/05/2009
# Url : http://beaugrand.chez.com/
################################################################################
# user
user=`whoami`
if [ $user != "root" ]; then
echo "you must be root"
exit -1
fi
echo -n "user ? "
read user
cd /home/$user
mkdir -p .icewm
cd .icewm
cat > toolbar << EOF
prog Terminal terminals_section.png konsole
prog Firefox web_browser_section.png firefox
prog "Internet ON" remote_access_section.png sudo ifup eth0
prog "Internet OFF" remote_access_section.png sudo ifdown eth0
prog XMMS xmms.png xmms
EOF
if ! grep ifup /etc/sudoers >/dev/null; then
echo -e "$user\tALL=/sbin/ifup eth0, /sbin/ifdown eth0, /sbin/ifconfig"
fi
cat > keys << EOF
# Menu : Ctrl+Esc
# Bureaux : Ctrl+Alt+Fleche droite ou gauche
key "XF86AudioMedia" /home/$user/install/bin/mp3term.sh -x
key "XF86AudioPrev" xmms-shell -e previous
key "XF86AudioNext" xmms-shell -e next
key "XF86AudioMute" /home/$user/install/bin/mute.sh
key "XF86AudioPlay" /home/$user/install/bin/playpause.sh
key "XF86AudioStop" xmms-shell -e stop
key "XF86AudioLowerVolume" aumix-text -w-1
key "XF86AudioRaiseVolume" aumix-text -w+1
EOF
cd ..
chown -R $user.$user .icewm
mkdir -p /home/$user/install/bin
file=/home/$user/install/bin/mute.sh
if [ ! -x $file ]; then
cat > $file << EOF
vol=\`aumix-text -vq | cut -d " " -f 2 | cut -d "," -f 1\`
if [ \$vol = 0 ]; then
aumix-text -v100
else
aumix-text -v0
fi
EOF
chown $user.$user $file
chmod 755 $file
fi
file=/home/$user/install/bin/playpause.sh
if [ ! -x $file ]; then
cat > $file << EOF
status=\`xmms-shell -e status 2>/dev/null | head -n 1 | cut -c-7\`
if [ "\$status" = "Playing" ]; then
xmms-shell -e pause
else
xmms-shell -e play
fi
EOF
chown $user.$user $file
chmod 755 $file
fi
# Fin du fichier icewm.sh