forked from Shinonome/dots-hyprland
initial commit of musicRecognition
This commit is contained in:
+1
-1
@@ -10,7 +10,7 @@ AndroidQuickToggleButton {
|
||||
name: Translation.tr("EasyEffects")
|
||||
|
||||
toggled: EasyEffects.active
|
||||
buttonIcon: "graphic_eq"
|
||||
buttonIcon: "instant_mix"
|
||||
|
||||
Component.onCompleted: {
|
||||
EasyEffects.fetchActiveState()
|
||||
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
import qs
|
||||
import qs.modules.common
|
||||
import qs.modules.common.widgets
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import qs.services
|
||||
|
||||
|
||||
AndroidQuickToggleButton {
|
||||
id: root
|
||||
|
||||
property int timeoutInterval: 5
|
||||
property int timeoutDuration: Config.options.resources.musicRecognitionTimeout
|
||||
property string resultsJSON
|
||||
|
||||
property string recognizedTrackTitle
|
||||
property string recognizedTrackSubtitle
|
||||
property string recognizedTrackURL
|
||||
|
||||
name: Translation.tr("Identify Music")
|
||||
statusText: toggled ? Translation.tr("Listening...") : Translation.tr("Inactive")
|
||||
toggled: false
|
||||
buttonIcon: toggled ? "cadence" : "graphic_eq"
|
||||
onClicked: {
|
||||
if (!toggled){
|
||||
recognizeMusicProc.running = true
|
||||
} else {
|
||||
recognizeMusicProc.running = false
|
||||
}
|
||||
|
||||
root.toggled = !root.toggled
|
||||
}
|
||||
|
||||
Process {
|
||||
id: recognizeMusicProc
|
||||
running: false
|
||||
command: [`${Directories.scriptPath}/musicRecognition/musicRecognition.sh`, "-i", root.timeoutInterval, "-t", root.timeoutDuration]
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
root.resultsJSON = this.text
|
||||
if (this.text.length < 100) {
|
||||
Quickshell.execDetached(["notify-send", "No music recognized", "Please make sure your music is playing and try again", "-a", "Shell"])
|
||||
toggled = false
|
||||
return
|
||||
}
|
||||
var obj = JSON.parse(root.resultsJSON)
|
||||
root.recognizedTrackTitle = obj.track.title
|
||||
root.recognizedTrackSubtitle = obj.track.subtitle
|
||||
root.recognizedTrackURL = obj.track.url
|
||||
musicReconizedProc.running = true
|
||||
toggled = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Process {
|
||||
id: musicReconizedProc
|
||||
running: false
|
||||
command: [ "notify-send" , "Music Recognized" , root.recognizedTrackTitle + " by " + root.recognizedTrackSubtitle , "-A" , "Shazam Link" , "-a" , "Shell"]
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
if (this.text !== ""){
|
||||
Qt.openUrlExternally(root.recognizedTrackURL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
StyledToolTip {
|
||||
//text: Translation.tr("Identifies the song that’s playing right now")
|
||||
text: "Identifies the song that’s playing right now"
|
||||
}
|
||||
}
|
||||
+13
@@ -232,4 +232,17 @@ DelegateChooser {
|
||||
cellSize: modelData.size
|
||||
} }
|
||||
|
||||
DelegateChoice { roleValue: "musicrecognition"; AndroidMusicRecognition {
|
||||
required property int index
|
||||
required property var modelData
|
||||
buttonIndex: root.startingIndex + index
|
||||
buttonData: modelData
|
||||
editMode: root.editMode
|
||||
expandedSize: modelData.size > 1
|
||||
baseCellWidth: root.baseCellWidth
|
||||
baseCellHeight: root.baseCellHeight
|
||||
cellSpacing: root.spacing
|
||||
cellSize: modelData.size
|
||||
} }
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user