From 499ef368e9d299c2eedfe90ea5335ae9bb50905b Mon Sep 17 00:00:00 2001
From: John Doe <johndoe@example.com>
Date: Thu, 4 Jun 2026 22:21:59 +0200
Subject: [PATCH 3/6] switch audio player from qmmp to Spotify via MPRIS D-Bus

Replace audioplayer config with Spotify D-Bus commands and add
spotify-play wrapper that auto-starts Spotify and sends Play.
---
 etc/pva/conf.d/01-default.conf | 25 +++++++++----------------
 server/PVA.java                | 31 ++++++++++++++++++++++++++-----
 usr/local/sbin/spotify-play    |  4 ++++
 3 files changed, 39 insertions(+), 21 deletions(-)
 create mode 100755 usr/local/sbin/spotify-play

diff --git a/etc/pva/conf.d/01-default.conf b/etc/pva/conf.d/01-default.conf
index 1b59968..140fb8c 100644
--- a/etc/pva/conf.d/01-default.conf
+++ b/etc/pva/conf.d/01-default.conf
@@ -82,22 +82,15 @@ videoplayer:"enqueue","/usr/bin/celluloidx:x--enqueue"
 #videoplayer:"getvolume","dbus-sendx:x--sessionx:x--print-replyx:x--type=method_callx:x--dest=org.mpris.MediaPlayer2.io.github.celluloid_player.Celluloid.instance-1x:x/org/mpris/MediaPlayer2x:xorg.freedesktop.DBus.Properties.Getx:xstring:'org.mpris.MediaPlayer2.Player'x:xstring:'Volume'"
 #videoplayer:"status","dbus-sendx:x--sessionx:x--print-replyx:x--type=method_callx:x--dest=org.mpris.MediaPlayer2.io.github.celluloid_player.Celluloid.instance-1x:x/org/mpris/MediaPlayer2x:xorg.freedesktop.DBus.Properties.Getx:xstring:'org.mpris.MediaPlayer2.Player'x:xstring:'PlaybackStatus'"
 
-audioplayer:"cmd","/usr/bin/qmmp"
-audioplayer:"enqueue","/usr/bin/qmmpx:x--enqueue"
-#audioplayer:"raisevolume","/usr/bin/qmmpx:x--volume-inc"
-#audioplayer:"lowervolume","/usr/bin/qmmpx:x--volume-dec"
-audioplayer:"play","/usr/bin/qmmpx:x-p"
-audioplayer:"stop","/usr/bin/qmmpx:x-s"
-audioplayer:"pause","/usr/bin/qmmpx:x-u"
-audioplayer:"nexttrack","/usr/bin/qmmpx:x--next"
-audioplayer:"lasttrack","/usr/bin/qmmpx:x--previous"
-audioplayer:"togglemute","/usr/bin/qmmpx:x--toggle-mute"
-audioplayer:"pname","qmmp"
-audioplayer:"clear","/usr/bin/qmmpx:x--pl-clear"
-audioplayer:"playpl","/usr/bin/qmmpx:x--pl-play 1 1"
-audioplayer:"status","/usr/bin/qmmpx:x--status"
-audioplayer:"forward","/usr/bin/qmmpx:x--seek-fwdx:x"
-audioplayer:"backward","/usr/bin/qmmpx:x--seek-bwdx:x"
+audioplayer:"cmd","/usr/bin/spotify"
+audioplayer:"pname","spotify"
+audioplayer:"status","dbus-sendx:x--sessionx:x--print-replyx:x--type=method_callx:x--dest=org.mpris.MediaPlayer2.spotifyx:x/org/mpris/MediaPlayer2x:xorg.freedesktop.DBus.Properties.Getx:xstring:'org.mpris.MediaPlayer2.Player'x:xstring:'PlaybackStatus'"
+audioplayer:"play","/home/kano/Code/Personal-Voice-Assistent/usr/local/sbin/spotify-play"
+audioplayer:"pause","dbus-sendx:x--sessionx:x--type=method_callx:x--dest=org.mpris.MediaPlayer2.spotifyx:x/org/mpris/MediaPlayer2x:xorg.mpris.MediaPlayer2.Player.Pause"
+audioplayer:"stop","dbus-sendx:x--sessionx:x--type=method_callx:x--dest=org.mpris.MediaPlayer2.spotifyx:x/org/mpris/MediaPlayer2x:xorg.mpris.MediaPlayer2.Player.Stop"
+audioplayer:"nexttrack","dbus-sendx:x--sessionx:x--print-replyx:x--type=method_callx:x--dest=org.mpris.MediaPlayer2.spotifyx:x/org/mpris/MediaPlayer2x:xorg.mpris.MediaPlayer2.Player.Next"
+audioplayer:"lasttrack","dbus-sendx:x--sessionx:x--print-replyx:x--type=method_callx:x--dest=org.mpris.MediaPlayer2.spotifyx:x/org/mpris/MediaPlayer2x:xorg.mpris.MediaPlayer2.Player.Previous"
+audioplayer:"togglemute","/usr/bin/pactl set-sink-mute @DEFAULT_SINK@ toggle"
 
 # IF you configure both, a dbus serviceable videoplayer AND the mediaplayer api, you will end up with some funny effects by "toogle" cmds.
 
diff --git a/server/PVA.java b/server/PVA.java
index 7868589..7aee53d 100644
--- a/server/PVA.java
+++ b/server/PVA.java
@@ -2486,12 +2486,33 @@ public class PVA {
 				// TODO: check if this section is really necessary
 				
 				if ( cf.command.equals("HELP") ) {
-					String subtext = text.replaceAll("(hilfe|zu)","").trim();
-					if ( wort("q m m p") ) {
-						log(dos.readPipe("qmmp --help"));
-						reaction = true;
+					text = text.replaceAll("(hilfe|zu)","").trim();
+					if ( oder("musik|playlist|lied") ) {
+						say( texte.get( config.get("conf","lang_short"), "HELPMUSIC") );
+					} else if ( oder("video|film") ) {
+						say( texte.get( config.get("conf","lang_short"), "HELPVIDEO") );
+					} else if ( oder("wetter") ) {
+						say( texte.get( config.get("conf","lang_short"), "HELPWEATHER") );
+					} else if ( oder("zeit|uhr") ) {
+						say( texte.get( config.get("conf","lang_short"), "HELPTIME") );
+					} else if ( oder("app|programm|start") ) {
+						say( texte.get( config.get("conf","lang_short"), "HELPAPPS") );
+					} else if ( oder("such|suche|suche") ) {
+						say( texte.get( config.get("conf","lang_short"), "HELPSEARCH") );
+					} else if ( oder("email|mail") ) {
+						say( texte.get( config.get("conf","lang_short"), "HELPEMAIL") );
+					} else if ( oder("telefon|anruf|ruf") ) {
+						say( texte.get( config.get("conf","lang_short"), "HELPPHONE") );
+					} else if ( oder("timer|termin|erinner") ) {
+						say( texte.get( config.get("conf","lang_short"), "HELPTIMER") );
+					} else if ( oder("system|aus|beenden|exit") ) {
+						say( texte.get( config.get("conf","lang_short"), "HELPSYSTEM") );
+					} else if ( oder("sprache|stimme|ausgabe") ) {
+						say( texte.get( config.get("conf","lang_short"), "HELPVOICE") );
+					} else {
+						say( texte.get( config.get("conf","lang_short"), "HELPGENERAL") );
 					}
-					
+					reaction = true;
 				}
 				if ( cf.command.equals("PLAYVIDEO") ) {
 
diff --git a/usr/local/sbin/spotify-play b/usr/local/sbin/spotify-play
new file mode 100755
index 0000000..553304b
--- /dev/null
+++ b/usr/local/sbin/spotify-play
@@ -0,0 +1,4 @@
+#!/bin/sh
+pgrep -x spotify >/dev/null 2>&1 || (nohup spotify >/dev/null 2>&1 &)
+sleep 2
+dbus-send --session --type=method_call --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Play
-- 
2.47.3

