44 lines
673 B
Bash
Executable file
44 lines
673 B
Bash
Executable file
#!/bin/bash
|
||
|
||
# 1: Temps en minutes
|
||
# 2: Type d’extinction
|
||
|
||
#reset-dpms() {
|
||
# xset dpms 600 600 600
|
||
# exit
|
||
#}
|
||
|
||
trap 'exit' INT TERM
|
||
|
||
touch /dev/shm/mccount
|
||
|
||
#xset dpms 10 10 10
|
||
#xset dpms force standby
|
||
|
||
while true
|
||
do
|
||
|
||
mcpid="$(pgrep -nu minecraft java)"
|
||
mcstatus="$(ps -q "${mcpid}" -o state --no-headers 2>/dev/null)"
|
||
|
||
if [[ "$mcstatus" == "T" || -z "$mcstatus" ]]
|
||
then
|
||
echo . >> /dev/shm/mccount
|
||
else
|
||
echo "Joueur(s) connecté(s), réinitialisation du compteur"
|
||
> /dev/shm/mccount
|
||
fi
|
||
|
||
time=$(wc -l /dev/shm/mccount | cut -d" " -f1)
|
||
|
||
echo "$time"/"${1:-5}"
|
||
|
||
if [[ "$time" -ge "${1:-5}" ]]
|
||
then
|
||
> /dev/shm/mccount
|
||
systemctl "${2:-suspend}"
|
||
fi
|
||
|
||
sleepcount -c 60
|
||
|
||
done
|