#!/bin/bash # "Sleepmode" 2008 Markus Schmidt # # Sleepmode shuts down Backlight, generates a randomized Playlist from a specified folder, # sets up Volumes and shuts down the computer after a desired duration # # needs /usr/bin/randomize with uncommented content below: # ##!/bin/bash # author: # Phil Jackson (phil@shellarchive.co.uk) ## prepend RANDOM, sort then cut the random number #function do_randomisation { # while read line; do # first=`echo $line | cut -c 1` # if test "$first" != "#" ; then # echo "$RANDOM $line" # fi; # done | sort -n | cut -d ' ' -f '2-' #} # ## process stdin over files #if [ -t 0 ]; then # if [ ${#} -lt 1 ]; then # echo "Please supply some input/filenames" >&2 # exit 1 # fi # cat "${@}" | do_randomisation #else # do_randomisation #fi # CONFIG # absolute path to mp3-folder or empty for playlist-mode (no trailing slash) MP3_DIRECTORY="/media/space/Musik/Drop Zone" # absolute path to mp3-playlist or empty for folder-mode MP3_PLAYLIST="" # path to generated Playlist (writeable for the user) MP3_WORKLIST="/media/space/Musik/Drop Zone/sleepmode.m3u" # time until shutdown in minutes DURATION=60 # time per zenity (alternative) #DURATION=`zenity --list --title="Sleepmode" --text="Wie lange soll der Sleepmode dauern?" --radiolist --column="" --column Punkt --column Beschreibung \"\" 30 "Eine halbe Stunde Laufzeit" \"\" 45 "45 Minuten Laufzeit" \"\" 60 "Eine Stunde Laufzeit"` # random-play on or off RANDOM=TRUE # TRUE or FALSE # volume in ALSA ALSA_VOL="80%" # volume for VLC VLC_VOL=8 # END OF CONFIG ############################################################################################ # kill processes sudo killall -9 shutdown sudo killall -9 vlc # mixer-setup amixer -c 0 set PCM $ALSA_VOL & # generate playlist from folder if test "$MP3_PLAYLIST" = "" -a "$MP3_DIRECTORY" != "" ; then if test $RANDOM ; then find "$MP3_DIRECTORY" -name *.mp3 | /usr/bin/randomize > "$MP3_WORKLIST" VLC_RAND="--random" else find "$MP3_DIRECTORY" -name *.mp3 > "$MP3_WORKLIST" VLC_RAND="" fi fi #generate random playlist from playlist if test "$MP3_PLAYLIST" != "" -a $RANDOM ; then cat "$MP3_PLAYLIST" | /usr/bin/randomize > "$MP3_WORKLIST" elif test "$MP3_PLAYLIST" != "" ; then cat "$MP3_PLAYLIST" > "$MP3_WORKLIST" fi # VLC starten vlc --loop $VLC_RAND --volume 8 "$MP3_WORKLIST" & # Monitor aus xset dpms force off # Rechner runter in 60 Minuten sudo shutdown -h +60