mirror of
https://github.com/end-4/dots-hyprland.git
synced 2026-06-05 14:59:27 -05:00
music recognition: add check for songrec command existence
This commit is contained in:
+9
-2
@@ -41,14 +41,15 @@ AndroidQuickToggleButton {
|
||||
|
||||
|
||||
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
|
||||
recognizeMusicProc.running = root.toggled
|
||||
musicReconizedProc.running = false
|
||||
}
|
||||
|
||||
altAction: () => {
|
||||
if (root.monitorSource === "monitor"){
|
||||
root.monitorSource = "input"
|
||||
@@ -68,6 +69,12 @@ AndroidQuickToggleButton {
|
||||
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 {
|
||||
|
||||
@@ -23,7 +23,7 @@ else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$MONITOR_SOURCE" ]; then
|
||||
if [ -z "$MONITOR_SOURCE" ] || ! command -v songrec >/dev/null 2>&1; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -46,7 +46,6 @@ while true; do
|
||||
fi
|
||||
|
||||
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)
|
||||
|
||||
if echo "$RESULT" | grep -q '"matches": \[' && [ ${#RESULT} -gt $MIN_VALID_RESULT_LENGTH ]; then
|
||||
|
||||
Reference in New Issue
Block a user