kernel: disable FW_LOADER_USER_HELPER_FALLBACK
[people/pmueller/ipfire-2.x.git] / config / mpfire / mpfire.pl
1 #!/usr/bin/perl
2
3 require '/var/ipfire/general-functions.pl';
4 require "${General::swroot}/lang.pl";
5 require "${General::swroot}/header.pl";
6
7 my $filename = "";
8 my $debug = 0;
9
10 if ( `/etc/init.d/mpd status` =~/not running/ ){
11 system("/etc/init.d/mpd start >/dev/null");
12 }
13
14 if ($ARGV[0] eq 'scan') {
15 if ($debug){print "Creating Database\n";}
16 system("mpd --create-db >/dev/null");
17 system("/etc/init.d/mpd restart >/dev/null");
18 }
19 elsif ($ARGV[0] eq 'play') {
20 &checkmute();
21 &clearplaylist();
22 if ($debug){print "Yes we are called and we will play $ARGV[1]\n";}
23 system("mpc add \"$ARGV[1]\" >/dev/null && mpc play >/dev/null");
24 }
25 elsif ($ARGV[0] eq 'playadd') {
26 if ($debug){print "Yes we are called and we will add $ARGV[1]\n";}
27 system("mpc add \"$ARGV[1]\" >/dev/null && mpc play >/dev/null");
28 }
29 elsif ($ARGV[0] eq 'clearplaylist') {
30 if ($debug){print "Deleting playlist\n";}
31 &clearplaylist();
32 }
33 elsif ($ARGV[0] eq 'stop') {
34 my $PID = 'cat /var/run/mpd.pid';
35 if ($debug){print "Killing Process $PID\n";}
36 system("mpc stop >/dev/null");
37 }
38 elsif ($ARGV[0] eq 'volup') {
39 if ($debug){print "Increasing Volume\n";}
40 system("/usr/bin/amixer set Master $ARGV[1]%+ 2>/dev/null >/dev/null");
41 system("/usr/bin/amixer set PCM $ARGV[1]%+ 2>/dev/null >/dev/null");
42 }
43 elsif ($ARGV[0] eq 'voldown') {
44 if ($debug){print "Decreasing Volume\n";}
45 system("/usr/bin/amixer set Master $ARGV[1]%- 2>/dev/null >/dev/null");
46 system("/usr/bin/amixer set PCM $ARGV[1]%- 2>/dev/null >/dev/null");
47 }
48 elsif ($ARGV[0] eq 'toggle') {
49 system("mpc toggle >/dev/null");
50 }
51 elsif ($ARGV[0] eq 'next') {
52 if ($debug){print "Next Song\n";}
53 system("mpc next >/dev/null[");
54 }
55 elsif ( $ARGV[0] eq 'prev' ) {
56 if ($debug){print "Previous Song\n";}
57 system("mpc prev >/dev/null");
58 }
59 elsif ($ARGV[0] eq 'song') {
60 my $song = `mpc \| head -2 | grep -v volume`;
61 print $song;
62 }
63 elsif ($ARGV[0] eq 'stats') {
64 my $song = `mpc stats | grep Songs`;
65 print $song;
66 }
67 elsif ($ARGV[0] eq 'playweb') {
68 &checkmute();
69 &clearplaylist();
70 if ($debug){print "Playing webstream $ARGV[1] \n";}
71 system("mpc add http://$ARGV[1] >/dev/null && mpc play >/dev/null && sleep 1");
72 }
73 elsif ($ARGV[0] eq 'volume') {
74 $temp = "Master - ";
75 $temp .= `amixer get Master \| tail -2 \| awk '{ print \$2" "\$5 }'`;
76 $temp .= "<break>PCM -";
77 $temp .= `amixer get PCM \| tail -2 \| awk '{ print \$2" "\$5 }'`;
78 print $temp;
79 }
80
81 sub clearplaylist(){
82 system("mpc clear >/dev/null");
83 }
84
85 sub shuffle(){
86 system("mpc random >/dev/null");
87 }
88
89 sub checkplaylist(){
90 my $Datei = "/var/ipfire/mpfire/playlist.m3u";
91 my @Info = stat($Datei);
92 if ( $Info[7] eq '' || $Info[7] eq '0' ){print "There is no playlist";exit(1);}
93 }
94
95 sub checkmute(){
96 $temp = `amixer get Master \| tail -2`;
97 my @Master = split(/ /,$temp);
98 $temp = `amixer get PCM \| tail -2`;
99 my @PCM = split(/ /,$temp);
100 if ( $PCM[7] =~ /off/ ){
101 if ($debug){print "PCM was muted - umuting.\n";}
102 system("amixer set PCM toggle >/dev/null");
103 }
104 if ( $Master[7] =~ /off/ ){
105 if ($debug){print "Master was muted - umuting.\n";}
106 system("amixer set Master toggle >/dev/null");
107 }
108 }