Nowe posty

xx Problem ze sterownikami. (5)
2024-04-13, 21:25:16
xx Instalacja xfce4 (2)
2024-04-13, 16:20:17
xx Serie kompilacji bez instalacji dla “emerge” w Gentoo (2)
2024-04-08, 18:40:04
xx Plasma 6 w Neonie ssie trochę mniej ... (17)
2024-04-05, 10:03:46
xx Problem z Linux Lite po instalacji (3)
2024-04-03, 14:23:40
xx Jak właczyć num locka przy starcie systemu debian 12? (12)
2024-04-02, 17:43:54
xx Brak dźwieku w systemie. (5)
2024-04-02, 16:13:41
xx Dystrybucja pod HP Omen (7)
2024-03-29, 11:33:05
xx [Poradnik] Wyszukiwanie Sterowników (2)
2024-03-27, 21:08:23
xx Ile pingwinów? (1)
2024-03-27, 08:59:24

Autor Wątek: Skrypt wyłączający komputer...  (Przeczytany 4445 razy)

Offline

  • Users
  • Prawie jak Guru
  • ****
  • Wiadomości: 287
    • Zobacz profil
Skrypt wyłączający komputer...
« dnia: 2014-02-09, 15:18:29 »
Czasami korzystałem ze skryptu timend z http://www.linuxone.pl/
Skrypt sprawował się znakomicie na dystrybucjach Fedora, Ubuntu... do póki nie zmieniłem systemu na oparty o archa Manjaro.
Zastanawiam się w czym jest problem ponieważ mam monit że komputer zostanie za chwilę wyłączony... pasek stanu dochodzi do końca, skrypt się kończy a komp idzie dalej :/
Poniżej podaję jak napisany jest skrypt:
#!/bin/bash
# Timend dla Linuksa
# Opis: Prosty skrypt do automatycznego wyłączania, resetowania, usypiania lub hibernowania komputera
# Licencja: GPLv3
# Autor: empitt
# E-mail/XMPP: empitt@o2.pl
# Strona www: http://www.linuxone.pl/
##    Timend
##    Copyright (C) 2012  Piotr Miros "empitt"
##
##    This program is free software: you can redistribute it and/or modify
##    it under the terms of the GNU General Public License as published by
##    the Free Software Foundation, either version 3 of the License, or
##    (at your option) any later version.
##
##    This program is distributed in the hope that it will be useful,
##    but WITHOUT ANY WARRANTY; without even the implied warranty of
##    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
##    GNU General Public License for more details.
##
##    You should have received a copy of the GNU General Public License
##    along with this program.  If not, see .
{
if [ "`locale -a | sed '/pl_PL.utf8/!d'`" ] ; then
LANG=pl_PL.utf8
elif [ "`locale -a | sed '/pl_PL.UTF-8/!d'`" ] ; then
LANG=pl_PL.UTF-8
else
LANG=C
fi
lt=()
for tr in dbus-send sed zenity ; do
[ ! -x "`which $tr`" ] \\
&& lt="${lt[@]} $tr"
done
er=`echo Nie znaleziono/zainstaluj:${lt[@]} | sed 's/-send//'`
if [ "`echo ${lt[@]}`" ] ; then
if [ -x /usr/bin/zenity ] ; then
zenity --error --title Timend --text "$er"
elif [ -x /usr/bin/kdialog ] ; then
kdialog --title Timend --error "$er"
else
echo $er
fi
exit 0
fi
while : ; do
st=`zenity --width 200 --height 202 --list --title Timend --text 'Automatyczne zamykanie\\nsystemu' --hide-column 2 --radiolist --column '' --column '' --column 'Wybierz opcję' \\
TRUE 1 Wyłącz \\
FALSE 2 Zresetuj \\
FALSE 3 Uśpij \\
FALSE 4 Zahibernuj \\
FALSE 5 'O skrypcie'`
case $st in
1 )
to=wyłączony
;;
2 )
to=zresetowany
;;
3 )
to=uśpiony
;;
4 )
to=zahibernowany
;;
5 )
zenity --info --title Timend --text 'Timend dla Linuksa\\n\\nLicencja: GPLv3\\nAutor: empitt\\nE-mail/XMPP: empitt@o2.pl\\nStrona www: http://www.linuxone.pl/'
continue
;;
* )
exit 0
;;
esac
while : ; do
hm=`zenity --entry --title Timend --text "Za ile minut lub godzin ma zostać $to komputer, np.:\\n00:15, 01:45, 05:00, 23:59, 55:59 itd." --entry-text hh:mm`
if [ $? = 0 ] ; then
if [ "`echo $hm | sed '/^[0-9]\\+:[0-9]\\+$/'\\!d`" ] ; then
exec 3> >(zenity --notification --window-icon info --listen)
echo tooltip: `date +"Komputer zostanie $to o %H:%M:%S %d-%m-%Y" -d "$(echo $hm | sed 's/\\([0-9]\\+\\):\\([0-9]\\+\\)/\\1 hour \\2 minute/')"` >&3
sleep `echo $hm | sed 's/\\([0-9]\\+\\):\\([0-9]\\+\\)/\\1h \\2m/'`
exec 3>&-
(
for (( i=90 ; i>=0 ; i-=10 )) ; do
echo $i
sleep 1
done
) | zenity --width 500 --progress --title Timend --text "Za chwilę komputer zostanie $to" --auto-close
[ $? = 1 ] \\
&& exit 0
case $st in
1 )
if [ -s /etc/dbus-1/system.d/ConsoleKit.conf ] ; then
dbus-send --system --print-reply --dest=org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop
elif [ -x /usr/bin/systemctl ] ; then
systemctl halt
fi
;;
2 )
if [ -s /etc/dbus-1/system.d/ConsoleKit.conf ] ; then
dbus-send --system --print-reply --dest=org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart
elif [ -x /usr/bin/systemctl ] ; then
systemctl reboot
fi
;;
3 )
dbus-send --system --print-reply --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Suspend
;;
4 )
dbus-send --system --print-reply --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Hibernate
;;
esac
exit 0
else
zenity --error --title Timend --text 'Błędna wartość'
fi
else
break
fi
done
done
} 2> /dev/null
Mile widziane sugestie :)