mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-05 21:15:38 -05:00
Fix audio device change, set-wallpaper, some popup alignment
This commit is contained in:
@@ -29,42 +29,66 @@ Singleton {
|
|||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: audioSinkLister
|
id: audioSinkLister
|
||||||
command: ["bash", "-c", "pactl list sinks | grep -E '^Sink #|device.description|Name:' | paste - - - | sed 's/Sink #//g' | sed 's/Name: //g' | sed 's/device.description = //g' | sed 's/\"//g'"]
|
command: ["pactl", "list", "sinks"]
|
||||||
running: true
|
running: true
|
||||||
|
|
||||||
stdout: StdioCollector {
|
stdout: StdioCollector {
|
||||||
onStreamFinished: {
|
onStreamFinished: {
|
||||||
if (text.trim()) {
|
if (text.trim()) {
|
||||||
|
console.log("Parsing pactl sink output...")
|
||||||
let sinks = []
|
let sinks = []
|
||||||
let lines = text.trim().split('\n')
|
let lines = text.trim().split('\n')
|
||||||
|
|
||||||
|
let currentSink = null
|
||||||
|
|
||||||
for (let line of lines) {
|
for (let line of lines) {
|
||||||
let parts = line.split('\t')
|
line = line.trim()
|
||||||
if (parts.length >= 3) {
|
|
||||||
let id = parts[0].trim()
|
// New sink starts
|
||||||
let name = parts[1].trim()
|
if (line.startsWith('Sink #')) {
|
||||||
let description = parts[2].trim()
|
if (currentSink && currentSink.name && currentSink.id) {
|
||||||
|
sinks.push(currentSink)
|
||||||
// Use description as display name if available, fallback to name processing
|
|
||||||
let displayName = description
|
|
||||||
if (!description || description === name) {
|
|
||||||
if (name.includes("analog-stereo")) displayName = "Built-in Speakers"
|
|
||||||
else if (name.includes("bluez")) displayName = "Bluetooth Audio"
|
|
||||||
else if (name.includes("usb")) displayName = "USB Audio"
|
|
||||||
else if (name.includes("hdmi")) displayName = "HDMI Audio"
|
|
||||||
else if (name.includes("easyeffects")) displayName = "EasyEffects"
|
|
||||||
else displayName = name
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sinks.push({
|
let sinkId = line.replace('Sink #', '').trim()
|
||||||
id: id,
|
currentSink = {
|
||||||
name: name,
|
id: sinkId,
|
||||||
displayName: displayName,
|
name: "",
|
||||||
active: false // Will be determined by default sink
|
displayName: "",
|
||||||
})
|
description: "",
|
||||||
|
active: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Get the Name field
|
||||||
|
else if (line.startsWith('Name: ') && currentSink) {
|
||||||
|
currentSink.name = line.replace('Name: ', '').trim()
|
||||||
|
}
|
||||||
|
// Get description
|
||||||
|
else if (line.includes('device.description = ') && currentSink) {
|
||||||
|
currentSink.description = line.replace('device.description = ', '').replace(/"/g, '').trim()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add the last sink
|
||||||
|
if (currentSink && currentSink.name && currentSink.id) {
|
||||||
|
sinks.push(currentSink)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process display names
|
||||||
|
for (let sink of sinks) {
|
||||||
|
let displayName = sink.description
|
||||||
|
if (!displayName || displayName === sink.name) {
|
||||||
|
if (sink.name.includes("analog-stereo")) displayName = "Built-in Speakers"
|
||||||
|
else if (sink.name.includes("bluez")) displayName = "Bluetooth Audio"
|
||||||
|
else if (sink.name.includes("usb")) displayName = "USB Audio"
|
||||||
|
else if (sink.name.includes("hdmi")) displayName = "HDMI Audio"
|
||||||
|
else if (sink.name.includes("easyeffects")) displayName = "EasyEffects"
|
||||||
|
else displayName = sink.name
|
||||||
|
}
|
||||||
|
sink.displayName = displayName
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("Final audio sinks:", JSON.stringify(sinks, null, 2))
|
||||||
root.audioSinks = sinks
|
root.audioSinks = sinks
|
||||||
defaultSinkChecker.running = true
|
defaultSinkChecker.running = true
|
||||||
}
|
}
|
||||||
@@ -112,16 +136,28 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setAudioSink(sinkName) {
|
function setAudioSink(sinkName) {
|
||||||
let sinkSetProcess = Qt.createQmlObject('
|
console.log("Setting audio sink to:", sinkName)
|
||||||
import Quickshell.Io
|
|
||||||
Process {
|
// Use a more reliable approach instead of Qt.createQmlObject
|
||||||
command: ["pactl", "set-default-sink", "' + sinkName + '"]
|
sinkSetProcess.command = ["pactl", "set-default-sink", sinkName]
|
||||||
running: true
|
sinkSetProcess.running = true
|
||||||
onExited: {
|
}
|
||||||
defaultSinkChecker.running = true
|
|
||||||
audioSinkLister.running = true
|
// Dedicated process for setting audio sink
|
||||||
}
|
Process {
|
||||||
|
id: sinkSetProcess
|
||||||
|
running: false
|
||||||
|
|
||||||
|
onExited: (exitCode) => {
|
||||||
|
console.log("Audio sink change exit code:", exitCode)
|
||||||
|
if (exitCode === 0) {
|
||||||
|
console.log("Audio sink changed successfully")
|
||||||
|
// Refresh current sink and list
|
||||||
|
defaultSinkChecker.running = true
|
||||||
|
audioSinkLister.running = true
|
||||||
|
} else {
|
||||||
|
console.error("Failed to change audio sink")
|
||||||
}
|
}
|
||||||
', root)
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1051,6 +1051,8 @@ PanelWindow {
|
|||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
|
console.log("Clicked audio device:", JSON.stringify(modelData))
|
||||||
|
console.log("Device name to set:", modelData.name)
|
||||||
AudioService.setAudioSink(modelData.name)
|
AudioService.setAudioSink(modelData.name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,8 +61,8 @@ PanelWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
anchors.fill: parent
|
anchors.centerIn: parent
|
||||||
anchors.margins: Theme.spacingL
|
width: parent.width - Theme.spacingL * 2
|
||||||
spacing: Theme.spacingL
|
spacing: Theme.spacingL
|
||||||
|
|
||||||
// Title
|
// Title
|
||||||
|
|||||||
@@ -2,15 +2,17 @@
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
img=$1
|
img=$1
|
||||||
|
# Convert to absolute path to fix symlink issues
|
||||||
|
img=$(realpath "$img")
|
||||||
|
|
||||||
QS_DIR="$HOME/quickshell"
|
QS_DIR="$HOME/quickshell"
|
||||||
mkdir -p "$QS_DIR"
|
mkdir -p "$QS_DIR"
|
||||||
LINK="$QS_DIR/current_wallpaper"
|
LINK="$QS_DIR/current_wallpaper"
|
||||||
|
|
||||||
ln -sf -- "$img" "$LINK"
|
ln -sf -- "$img" "$LINK"
|
||||||
swaybg -m fill -i "$LINK" & disown
|
swaybg -m fill -i "$LINK" & disown
|
||||||
|
|
||||||
json="$(matugen image "$img" --json hex)"
|
json="$(matugen image "$img" --json hex)"
|
||||||
|
|
||||||
get() { jq -r "$1" <<<"$json"; }
|
get() { jq -r "$1" <<<"$json"; }
|
||||||
|
|
||||||
bg=$(get '.colors.dark.background')
|
bg=$(get '.colors.dark.background')
|
||||||
@@ -34,27 +36,26 @@ inverse_b=$(get '.colors.light.inverse_primary')
|
|||||||
cat >"$QS_DIR/generated_niri_colors.kdl" <<EOF
|
cat >"$QS_DIR/generated_niri_colors.kdl" <<EOF
|
||||||
// AUTO-GENERATED on $(date)
|
// AUTO-GENERATED on $(date)
|
||||||
layout {
|
layout {
|
||||||
border {
|
border {
|
||||||
active-color "$primary"
|
active-color "$primary"
|
||||||
inactive-color "$secondary"
|
inactive-color "$secondary"
|
||||||
}
|
}
|
||||||
focus-ring {
|
focus-ring {
|
||||||
active-color "$inverse"
|
active-color "$inverse"
|
||||||
}
|
}
|
||||||
background-color "$bg"
|
background-color "$bg"
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
echo "→ Niri colours: $QS_DIR/generated_niri_colors.kdl"
|
|
||||||
|
echo "→ Niri colours: $QS_DIR/generated_niri_colors.kdl"
|
||||||
|
|
||||||
cat >"$QS_DIR/generated_ghostty_colors.conf" <<EOF
|
cat >"$QS_DIR/generated_ghostty_colors.conf" <<EOF
|
||||||
# AUTO-GENERATED on $(date)
|
# AUTO-GENERATED on $(date)
|
||||||
|
|
||||||
background = $bg
|
background = $bg
|
||||||
foreground = $fg
|
foreground = $fg
|
||||||
cursor-color = $inverse
|
cursor-color = $inverse
|
||||||
selection-background = $secondary
|
selection-background = $secondary
|
||||||
selection-foreground = #ffffff
|
selection-foreground = #ffffff
|
||||||
|
|
||||||
palette = 0=$bg
|
palette = 0=$bg
|
||||||
palette = 1=$error
|
palette = 1=$error
|
||||||
palette = 2=$tertiary
|
palette = 2=$tertiary
|
||||||
@@ -72,7 +73,8 @@ palette = 13=$tertiary_ctr_b
|
|||||||
palette = 14=$inverse_b
|
palette = 14=$inverse_b
|
||||||
palette = 15=$fg_b
|
palette = 15=$fg_b
|
||||||
EOF
|
EOF
|
||||||
echo "→ Ghostty theme: $QS_DIR/generated_ghostty_colors.conf"
|
|
||||||
echo " (use in ghostty: theme = $QS_DIR/generated_ghostty_colors.conf )"
|
|
||||||
|
|
||||||
niri msg action do-screen-transition --delay-ms 100
|
echo "→ Ghostty theme: $QS_DIR/generated_ghostty_colors.conf"
|
||||||
|
echo " (use in ghostty: theme = $QS_DIR/generated_ghostty_colors.conf )"
|
||||||
|
|
||||||
|
niri msg action do-screen-transition --delay-ms 100
|
||||||
Reference in New Issue
Block a user