Wer von euch schon ein Mal die Sabayon Live-DVD gestartet hat, kennt es sicherlich, dort kommt ein Lied am Anfang während das System hoch fährt. Ich habe dieses Script genommen und verändert, so dass man es auch mit Gentoo benutzen kann.
Special THX an dieser Stelle noch mal an bell, der mich auf die Idee gebracht hat, dass ich es mit mpg123 zum Abspielen der Musikdatei versuchen soll. Außerdem stammt die Version, die ihr jetzt hier vorfindet, teilweise von bell (fade-in und fade-out). Ich hab alles editiert, so dass hier etwas aufgeräumt werden kann.
Ok, was ist also zu tun?
Ihr nehm euch eine MP3-Datei, die ihr gerne beim Start eures Systems hören würdet und kopiert sie nach /usr/share/sounds.
|
Quellcode
|
1
|
cp myfile.mp3 /usr/share/sounds/boot.mp3 && chmod 766 /usr/share/sounds/boot.mp3
|
Wer den Konsolen-Player mpg123 noch nicht installiert hat, sollte dieses jetzt tun.
|
Quellcode
|
1
|
emerge -av mpg123
|
Jetzt legt ihr unter /etc/init.d eine Datei namens music an
|
Quellcode
|
1
|
touch /etc/init.d/music && chmod +x /etc/init.d/music
|
In diese Datei kopiert ihr das Script.
|
Quellcode
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#!/sbin/runscript
# Copyright 2006 SabayonLinux
# Distributed under the terms of the GNU General Public License v2
#
# 19th October 2009
# Edited by Felix Petzold for using with Gentoo Linux
# You have to install mpg123 to use this Script. You can edit this Script to change the mp3-File you want to hear.
#
# 14 April 2010
# bell wrote a fadein and a fadeout
start() {
# variables
fadein="true"
slow=0.1
control="Master"
# Checking if there is a Sound Device
sound_device_available=$(lspci | grep -i "audio")
if [ -n "$sound_device_available" ]; then
if [ "$fadein" == "true" ]; then
# save the original mixer state
origstate=$(amixer sget "$control" | grep '\[on\]' | head -n 1| sed 's/\(.*Playback \)\([0-9]*\)\(.*\)/\2/g')
# and mute
amixer sset "$control" 0
state=0
fi
# Starting sound
ebegin "Starting music"
nice -n -15 mpg123 -p 30 -q /usr/share/sounds/boot.mp3 &> /dev/null && killall pulseaudio &
# Do fadein
if [ "$fadein" == "true" ]; then
while [ "$state" -lt $origstate ]; do
state=$(($state+1))
amixer sset "$control" $state
sleep $slow
done
amixer sset "$control" $origstate
fi & # background
eend 0
else
ebegin "Ok... music disabled"
eend 0
fi
}
|
Und jetzt noch das Script in das Runlevel boot packen.
|
Quellcode
|
1
|
rc-update add music boot
|
Ab jetzt habt ihr jedes Mal beim Hochfahren des Systems Musik
. Sobald das Lied zu Ende ist, hört die Musik auf.
fadeout:
(von bell)
Das Script müsst ihr vom Autostart eures Windowmanagers aufrufen lassen. Damit wird die Musik abgebrochen, wenn euer Windowmanager hochgefahren ist.
|
Quellcode
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
#!/bin/bash
slow=0.1
control="Master"
progkill=mpg123
origstate=$(amixer sget "$control" | grep '\[on\]' | sed 's/\(.*Playback \)\([0-9]*\)\(.*\)/\2/g')
echo "Original: $origstate"
state=$origstate
while [ "$state" -gt 0 ]; do
state=$(($state-1))
amixer sset "$control" $state
sleep $slow
done
sudo killall $progkill
amixer sset "$control" $origstate
|
Das original Lied der Sabayon Live-DVD ist übrigends von "Pornophonique" und heißt "rock'n'roll hall of fame". Nur für die, die es gerne original hätten.
Man kann das Lied auf der Homepage der Band runterladen. Hier ist der Link:
http://www.pornophonique.de/download.php?song_id=8