forked from Shinonome/dots-hyprland
togglable monitor-source
This commit is contained in:
+16
-3
@@ -12,8 +12,11 @@ AndroidQuickToggleButton {
|
||||
|
||||
property int timeoutInterval: 5
|
||||
property int timeoutDuration: Config.options.resources.musicRecognitionTimeout
|
||||
|
||||
property string monitorSource: "monitor" // "monitor" (system sound) , "input" (microphone)
|
||||
|
||||
name: Translation.tr("Identify Music")
|
||||
statusText: toggled ? Translation.tr("Listening...") : Translation.tr("Inactive")
|
||||
statusText: toggled ? Translation.tr("Listening...") : monitorSource === "monitor" ? Translation.tr("System sound") : Translation.tr("Microphone")
|
||||
toggled: false
|
||||
buttonIcon: toggled ? "cadence" : "graphic_eq"
|
||||
|
||||
@@ -34,9 +37,10 @@ AndroidQuickToggleButton {
|
||||
root.toggled = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
StyledToolTip {
|
||||
text: Translation.tr("Identifies the song that’s currently playing")
|
||||
text: Translation.tr("Identifies currently playing song | Right-click to change monitor source")
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
@@ -44,11 +48,20 @@ AndroidQuickToggleButton {
|
||||
recognizeMusicProc.running = root.toggled
|
||||
musicReconizedProc.running = false
|
||||
}
|
||||
altAction: () => {
|
||||
if (root.monitorSource === "monitor"){
|
||||
root.monitorSource = "input"
|
||||
return
|
||||
}else {
|
||||
root.monitorSource = "monitor"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Process {
|
||||
id: recognizeMusicProc
|
||||
running: false
|
||||
command: [`${Directories.scriptPath}/musicRecognition/musicRecognition.sh`, "-i", root.timeoutInterval, "-t", root.timeoutDuration]
|
||||
command: [`${Directories.scriptPath}/musicRecognition/musicRecognition.sh`, "-i", root.timeoutInterval, "-t", root.timeoutDuration, "-s", root.monitorSource]
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
handleRecognition(this.text)
|
||||
|
||||
@@ -1,21 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
## can be added manually if not chosen automatically with running this on terminal 'pw-cli list-objects | grep node.name' and manually choose the one you want.
|
||||
MONITOR_SOURCE=$(pactl list short sources 2>/dev/null | grep -m1 monitor | awk '{print $2}' || true)
|
||||
|
||||
INTERVAL=5
|
||||
TOTAL_DURATION=30
|
||||
MIN_VALID_RESULT_LENGTH=300
|
||||
MIN_VALID_RESULT_LENGTH=300
|
||||
SOURCE_TYPE="monitor" # default | "monitor" : system_sound , "input" : microphone
|
||||
|
||||
while getopts "i:t:" opt; do
|
||||
while getopts "i:t:s:" opt; do
|
||||
case $opt in
|
||||
i) INTERVAL=$OPTARG ;;
|
||||
t) TOTAL_DURATION=$OPTARG ;;
|
||||
*) echo "Usage: $0 [-i interval_seconds] [-t total_duration_seconds]"
|
||||
s) SOURCE_TYPE=$OPTARG ;;
|
||||
*) echo "Usage: $0 [-i interval_seconds] [-t total_duration_seconds] [-s monitor|input]"
|
||||
exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Kaynağı belirle
|
||||
if [ "$SOURCE_TYPE" = "monitor" ]; then
|
||||
MONITOR_SOURCE=$(pactl list short sources 2>/dev/null | grep -m1 monitor | awk '{print $2}' || true)
|
||||
elif [ "$SOURCE_TYPE" = "input" ]; then
|
||||
MONITOR_SOURCE=$(pactl info | grep "Default Source:" | awk '{print $3}' || true)
|
||||
else
|
||||
echo "Invalid source type: $SOURCE_TYPE. Use 'monitor' or 'input'."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
START_TIME=$(date +%s)
|
||||
|
||||
while true; do
|
||||
|
||||
Reference in New Issue
Block a user