forked from Shinonome/dots-hyprland
music recognition: add check for songrec command existence
This commit is contained in:
+9
-2
@@ -41,14 +41,15 @@ AndroidQuickToggleButton {
|
|||||||
|
|
||||||
|
|
||||||
StyledToolTip {
|
StyledToolTip {
|
||||||
text: Translation.tr("Identifies currently playing song | Right-click to change monitor source")
|
text: Translation.tr("Recognize music | Right-click to toggle source")
|
||||||
}
|
}
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
root.toggled = !root.toggled
|
root.toggled = !root.toggled
|
||||||
recognizeMusicProc.running = root.toggled
|
recognizeMusicProc.running = root.toggled
|
||||||
musicReconizedProc.running = false
|
musicReconizedProc.running = false
|
||||||
}
|
}
|
||||||
|
|
||||||
altAction: () => {
|
altAction: () => {
|
||||||
if (root.monitorSource === "monitor"){
|
if (root.monitorSource === "monitor"){
|
||||||
root.monitorSource = "input"
|
root.monitorSource = "input"
|
||||||
@@ -68,6 +69,12 @@ AndroidQuickToggleButton {
|
|||||||
handleRecognition(this.text)
|
handleRecognition(this.text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
onExited: (exitCode, exitStatus) => {
|
||||||
|
if (exitCode === 1) {
|
||||||
|
Quickshell.execDetached(["notify-send", Translation.tr("Couldn't recognize music"), Translation.tr("Make sure you have songrec installed"), "-a", "Shell"])
|
||||||
|
root.toggled = false
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Process {
|
Process {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ else
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$MONITOR_SOURCE" ]; then
|
if [ -z "$MONITOR_SOURCE" ] || ! command -v songrec >/dev/null 2>&1; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -46,7 +46,6 @@ while true; do
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
ffmpeg -f s16le -ar 44100 -ac 2 -i "$TMP_RAW" -acodec libmp3lame -y -hide_banner -loglevel error "$TMP_MP3" 2>/dev/null
|
ffmpeg -f s16le -ar 44100 -ac 2 -i "$TMP_RAW" -acodec libmp3lame -y -hide_banner -loglevel error "$TMP_MP3" 2>/dev/null
|
||||||
|
|
||||||
RESULT=$(songrec audio-file-to-recognized-song "$TMP_MP3" 2>/dev/null || true)
|
RESULT=$(songrec audio-file-to-recognized-song "$TMP_MP3" 2>/dev/null || true)
|
||||||
|
|
||||||
if echo "$RESULT" | grep -q '"matches": \[' && [ ${#RESULT} -gt $MIN_VALID_RESULT_LENGTH ]; then
|
if echo "$RESULT" | grep -q '"matches": \[' && [ ${#RESULT} -gt $MIN_VALID_RESULT_LENGTH ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user