-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfoobar.sh
More file actions
112 lines (95 loc) · 3.22 KB
/
foobar.sh
File metadata and controls
112 lines (95 loc) · 3.22 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
### BEGIN LICENSE
# Copyright (C) 2013 Maciej Baron (@maciekbaron)
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, 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 <http://www.gnu.org/licenses/>.
## END LICENSE
##############
# CONFIG #
##############
# Location of foobar2000
FOOBAR="/media/disk_c/Program Files (x86)/foobar2000/foobar2000.exe"
# The location of your music on Windows
WINDOWS_MUSIC="D:\Music"
# The location of your music on Linux
LINUX_MUSIC="/media/disk_d/Music"
##############
# SCRIPT #
##############
# Commands taken from http://wiki.hydrogenaudio.org/index.php?title=Foobar2000:Commandline_Guide
case "$1" in
# Adding a song to the playlist
/add)
for file in "$@"
do
if [ "$file" != "/add" ]
then
files="$files \"$file\""
fi
done
files=${files//$LINUX_MUSIC/$WINDOWS_MUSIC}
files=${files////\\}
echo wine "\"$FOOBAR\"" /add $files | sh
;;
# Invokes the specified main menu command
/command:*)
wine "$FOOBAR" /command:\"${1:9:${#1}}\"
;;
/playlist_command:*)
wine "$FOOBAR" /playlist_command:\"${1:18:${#1}}\"
;;
/playing_command:*)
wine "$FOOBAR" /playing_command:\"${1:17:${#1}}\"
;;
/context_command:*)
for file in "$@"
do
if [ "$file" != "$1" ]
then
files="$files \"$file\""
fi
done
files=${files//$LINUX_MUSIC/$WINDOWS_MUSIC}
files=${files////\\}
echo wine "\"$FOOBAR\"" /context_command:\"${1:17:${#1}}\" $files | sh
;;
# Single commands that do not require parsing
/play|/pause|/playpause|/prev|/next|/rand|/stop|/exit|/show|/hide|/config)
wine "$FOOBAR" $1
;;
--help|-h|/?)
echo "Author: Maciej Baron
This is a (very) simple script that relays command line commands to Foobar2000 running on Wine.
Ex. ./foobar.sh /add \"/media/drive_d/music/Song by Someone.mp3\"
Remember to configure the script by editing this file!
Available switches:
/add <list-of-files> - appends the specified files to the current playlist instead of replacing the playlist content and playing them immediately
/play, /pause, /playpause, /prev, /next, /rand, /stop - playback controls
/exit - exits foobar2000
/show, /hide - shows or hides the main foobar2000 window
/config - opens the Preferences dialog
/command:<menu command> - invokes the specified main menu command
/playlist_command:<context menu command> - invokes the specified context menu command on current playlist selection
/playing_command:<context menu command> - invokes the specified context menu command on currently played track
/context_command:<context menu command> <files> - invokes the specified context menu command on the specified files"
;;
# Ignore other commands
*)
if [ "$#" -eq "0" ] # No arguments
then
wine "$FOOBAR"
else
echo Unrecognised command
exit 1
fi
esac
exit 0