-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3061931
Showing
8 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Olivier CHURLAUD | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# mpd_cdrom | ||
|
||
Does everything so that whenever a cd is inserted, its music is added to the mpd main playlist. When the cd is removed, it all corresponding songs are removed from the playlist. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
pkgbase="mpd_cdrom" | ||
pkgname="mpd_cdrom" | ||
pkgver="1.0.0" | ||
pkgrel=1 | ||
|
||
pkg_desc="Add songs to mpd when a CD-ROM is inserted, remove them when ejected" | ||
license=('MIT') | ||
arch=('any') | ||
depends=('mpd' 'mpc' 'cdparanoia') | ||
|
||
source=("${pkgname}-${pkgver}::git+https://github.com/ochurlaud/mpd_cdrom.git") | ||
md5sums=('SKIP') | ||
|
||
install=${pkgname}.install | ||
|
||
package() { | ||
cd "${srcdir}/${pkgname}-${pkgver}" | ||
mkdir -p "${pkgdir}/usr/bin/" | ||
mkdir -p "${pkgdir}/etc/udev/rules.d/" | ||
mkdir -p "${pkgdir}/etc/systemd/system/" | ||
cp src/bin/* "${pkgdir}/usr/bin/" | ||
cp src/systemd/* "${pkgdir}/etc/systemd/system/" | ||
cp src/udev-rules/* "${pkgdir}/etc/udev/rules.d/" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
post_install() { | ||
echo "INFO: adding user 'mpd' to the 'optical' group" | ||
usermod -aG optical mpd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/bash | ||
|
||
usage() { | ||
echo "Usage: $0 [load|unload]" | ||
exit $1 | ||
} | ||
|
||
mpd_load() { | ||
nbtracks=$(cdparanoia -sQ |& grep -P "^\s+\d+\." | wc -l) | ||
|
||
for ((i=1; i<=${nbtracks};i++)) ; do | ||
mpc add cdda:///${i} | ||
done | ||
} | ||
|
||
mpd_unload() { | ||
positions=$(mpc playlist | grep -n "cdda:///" | cut -d':' -f1) | ||
if [[ "${positions}" != "" ]] ; then | ||
mpc del ${positions} | ||
fi | ||
} | ||
|
||
control_dependencies() { | ||
which $1 > /dev/null | ||
if [[ "$?" -ne "0" ]]; then | ||
echo "[ERROR] $1 is not installed" | ||
exit 2 | ||
fi | ||
} | ||
|
||
for dependency in "mpc" "cdparanoia"; do | ||
control_dependencies ${dependency} | ||
done | ||
|
||
if [[ "$#" -ne "1" ]] ; then | ||
usage 1 | ||
fi | ||
|
||
if [[ "$1" = "load" ]] ; then | ||
mpd_load | ||
elif [[ "$1" = "unload" ]] ; then | ||
mpd_unload | ||
else | ||
usage 1 | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[Service] | ||
Type=oneshot | ||
ExecStart=/usr/bin/mpd_cdrom load |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[Service] | ||
Type=oneshot | ||
ExecStart=/usr/bin/mpd_cdrom unload |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ACTION=="change", SUBSYSTEM=="block", KERNEL=="sr*", ENV{DISK_EJECT_REQUEST}=="", TAG+="systemd", ENV{SYSTEMD_WANTS}="mpd-load-cdrom.service" | ||
ACTION=="change", SUBSYSTEM=="block", KERNEL=="sr*", ENV{DISK_EJECT_REQUEST}=="1", TAG+="systemd", ENV{SYSTEMD_WANTS}="mpd-unload-cdrom.service" |