From 8414e7142259519ea006bf4081288bc742ed8131 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Thu, 30 Oct 2014 12:34:25 +0100 Subject: [PATCH] applications/luci-shairport: add new package. This adds support for configuring shairport. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Álvaro Fernández Rojas --- applications/luci-shairport/Makefile | 4 + .../luasrc/controller/shairport.lua | 25 +++ .../luasrc/model/cbi/shairport.lua | 171 ++++++++++++++++++ .../root/etc/uci-defaults/luci-shairport | 12 ++ contrib/package/luci-addons/Makefile | 1 + 5 files changed, 213 insertions(+) create mode 100644 applications/luci-shairport/Makefile create mode 100644 applications/luci-shairport/luasrc/controller/shairport.lua create mode 100644 applications/luci-shairport/luasrc/model/cbi/shairport.lua create mode 100644 applications/luci-shairport/root/etc/uci-defaults/luci-shairport diff --git a/applications/luci-shairport/Makefile b/applications/luci-shairport/Makefile new file mode 100644 index 0000000000..4c827554c4 --- /dev/null +++ b/applications/luci-shairport/Makefile @@ -0,0 +1,4 @@ +PO = shairport + +include ../../build/config.mk +include ../../build/module.mk diff --git a/applications/luci-shairport/luasrc/controller/shairport.lua b/applications/luci-shairport/luasrc/controller/shairport.lua new file mode 100644 index 0000000000..d201eca542 --- /dev/null +++ b/applications/luci-shairport/luasrc/controller/shairport.lua @@ -0,0 +1,25 @@ +--[[ +LuCI - Lua Configuration Interface - Shairport support + +Copyright 2014 Álvaro Fernández Rojas + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id$ +]]-- + +module("luci.controller.shairport", package.seeall) + +function index() + if not nixio.fs.access("/etc/config/shairport") then + return + end + + local page = entry({"admin", "services", "shairport"}, cbi("shairport"), _("Shairport")) + page.dependent = true + +end diff --git a/applications/luci-shairport/luasrc/model/cbi/shairport.lua b/applications/luci-shairport/luasrc/model/cbi/shairport.lua new file mode 100644 index 0000000000..eb0772572b --- /dev/null +++ b/applications/luci-shairport/luasrc/model/cbi/shairport.lua @@ -0,0 +1,171 @@ +--[[ +LuCI - Lua Configuration Interface - Shairport support + +Copyright 2014 Álvaro Fernández Rojas + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id$ +]]-- + +m = Map("shairport", "Shairport", translate("Shairport is a simple AirPlay server implementation, here you can configure the settings.")) + +s = m:section(TypedSection, "shairport", "") +s.addremove = true +s.anonymous = false + +enable=s:option(Flag, "disabled", translate("Enabled")) +enable.enabled="0" +enable.disabled="1" +enable.default = "1" +respawn=s:option(Flag, "respawn", translate("Respawn")) +respawn.default = false + +bname = s:option(Value, "bname", translate("Airport Name")) +bname.rmempty = true + +pw = s:option(Value, "password", translate("Password")) +pw.rmempty = true +pw.password = true + +port=s:option(Value, "port", translate("Port")) +port.rmempty = true +port.datatype = "port" + +buffer=s:option(Value, "buffer", translate("Buffer fill")) +buffer.rmempty = true +buffer.datatype = "uinteger" + +log_file=s:option(Value, "log_file", translate("Log file")) +log_file.rmempty = true +--log_file.datatype = "file" + +err_file=s:option(Value, "err_file", translate("Error file")) +err_file.rmempty = true +--err_file.datatype = "file" + +meta_dir=s:option(Value, "meta_dir", translate("Metadata directory")) +meta_dir.rmempty = true +meta_dir.datatype = "directory" + +cmd_start=s:option(Value, "cmd_start", translate("Command when playback begins")) +cmd_start.rmempty = true + +cmd_stop=s:option(Value, "cmd_stop", translate("Command when playback ends")) +cmd_stop.rmempty = true + +cmd_wait=s:option(Flag, "cmd_wait", translate("Block while the commands run")) +cmd_wait.default = false + +mdns=s:option(ListValue, "mdns", translate("mDNS")) +mdns.rmempty = true +mdns:value("", translate("Default")) +mdns:value("avahi") +mdns:value("dns_sd") +mdns:value("external_avahi") +mdns:value("external_dns_sd") +mdns:value("tinysvcmdns") + +audio_output=s:option(ListValue, "audio_output", translate("Audio output")) +audio_output.rmempty = true +audio_output:value("", translate("Default")) +audio_output:value("alsa") +audio_output:value("ao") +audio_output:value("dummy") +audio_output:value("pulse") +audio_output:value("pipe") + +-- alsa output -- +output_dev=s:option(Value, "output_dev", translate("Output device")) +output_dev.rmempty = true +output_dev:depends("audio_output", "alsa") + +mixer_dev=s:option(Value, "mixer_dev", translate("Mixer device")) +mixer_dev.rmempty = true +mixer_dev:depends("audio_output", "alsa") + +mixer_type=s:option(ListValue, "mixer_type", translate("Mixer type")) +mixer_type.rmempty = true +mixer_type:value("", translate("Default")) +mixer_type:value("software") +mixer_type:value("hardware") +mixer_type:depends("audio_output", "alsa") + +mixer_control=s:option(Value, "mixer_control", translate("Mixer control")) +mixer_control.rmempty = true +mixer_control:depends("audio_output", "alsa") + +mixer_index = s:option(ListValue, "mixer_index", translate("Mixer index")) +mixer_index.rmempty = true +mixer_index:depends("audio_output", "alsa") +mixer_index:value("", translate("Default")) +local pats = io.popen("find /proc/asound/ -type d -name 'card*' | sort") +if pats then + local l + while true do + l = pats:read("*l") + if not l then break end + + l = string.gsub(l, "/proc/asound/card", "") + if l then + mixer_index:value(l) + end + end + pats:close() +end + +-- ao output -- +ao_driver=s:option(Value, "ao_driver", translate("AO driver")) +ao_driver.rmempty = true +ao_driver:depends("audio_output", "ao") + +ao_name=s:option(Value, "ao_name", translate("AO name")) +ao_name.rmempty = true +ao_name:depends("audio_output", "ao") + +ao_id = s:option(ListValue, "ao_id", translate("AO id")) +ao_id.rmempty = true +ao_id:depends("audio_output", "ao") +ao_id:value("", translate("Default")) +local pats = io.popen("find /proc/asound/ -type d -name 'card*' | sort") +if pats then + local l + while true do + l = pats:read("*l") + if not l then break end + + l = string.gsub(l, "/proc/asound/card", "") + if l then + ao_id:value(l) + end + end + pats:close() +end + +ao_options=s:option(Value, "ao_options", translate("AO options")) +ao_options.rmempty = true +ao_options:depends("audio_output", "ao") + +-- pipe output -- +output_fifo=s:option(Value, "output_fifo", translate("Output FIFO")) +output_fifo.rmempty = true +output_fifo:depends("audio_output", "pipe") + +-- pulse output -- +pulse_server=s:option(Value, "pulse_server", translate("Pulse server")) +pulse_server.rmempty = true +pulse_server:depends("audio_output", "pulse") + +pulse_sink=s:option(Value, "pulse_sink", translate("Pulse sink")) +pulse_sink.rmempty = true +pulse_sink:depends("audio_output", "pulse") + +pulse_appname=s:option(Value, "pulse_appname", translate("Pulse application name")) +pulse_appname.rmempty = true +pulse_appname:depends("audio_output", "pulse") + +return m diff --git a/applications/luci-shairport/root/etc/uci-defaults/luci-shairport b/applications/luci-shairport/root/etc/uci-defaults/luci-shairport new file mode 100644 index 0000000000..be9412bac8 --- /dev/null +++ b/applications/luci-shairport/root/etc/uci-defaults/luci-shairport @@ -0,0 +1,12 @@ +#!/bin/sh + +# needed for "Save and Apply" to restart shairport +uci -q batch <<-EOF >/dev/null + delete ucitrack.@shairport[-1] + add ucitrack shairport + set ucitrack.@shairport[-1].init="shairport" + commit ucitrack +EOF + +rm -f /tmp/luci-indexcache +exit 0 diff --git a/contrib/package/luci-addons/Makefile b/contrib/package/luci-addons/Makefile index a3e293582f..35bc02caf1 100644 --- a/contrib/package/luci-addons/Makefile +++ b/contrib/package/luci-addons/Makefile @@ -213,6 +213,7 @@ $(eval $(call application,pbx-voicemail,LuCI PBX Administration Voicemail Suppor $(eval $(call application,ltqtapi,Lantiq voip)) $(eval $(call application,minidlna,LuCI Support for miniDLNA,minidlna)) $(eval $(call application,shairplay,LuCI Support for Shairplay,shairplay)) +$(eval $(call application,shairport,LuCI Support for Shairport,shairport)) $(eval $(call application,transmission,LuCI Support for Transmission,transmission-daemon)) $(eval $(call application,watchcat,LuCI Support for Watchcat,watchcat)) -- 2.30.2