mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-25 14:02:53 -05:00
- QT 6.9.3 removed the previous color picker we used - Zenity is default in gnome based distros - Kcolorchooser can be installed separately and will be preferred over Zenity
79 lines
1.9 KiB
QML
79 lines
1.9 KiB
QML
import QtQuick
|
|
import Quickshell
|
|
import Quickshell.Io
|
|
import qs.Common
|
|
import qs.Services
|
|
|
|
Item {
|
|
id: colorPickerModal
|
|
|
|
property string availablePicker: "zenity"
|
|
|
|
signal colorSelected(color selectedColor)
|
|
|
|
function show() {
|
|
if (availablePicker === "kcolorchooser") {
|
|
kcolorchooserProcess.running = true
|
|
} else {
|
|
zenityProcess.running = true
|
|
}
|
|
}
|
|
|
|
function hide() {
|
|
kcolorchooserProcess.running = false
|
|
zenityProcess.running = false
|
|
}
|
|
|
|
function copyColorToClipboard(colorValue) {
|
|
Quickshell.execDetached(["sh", "-c", `echo "${colorValue}" | wl-copy`])
|
|
ToastService.showInfo(`Color ${colorValue} copied`)
|
|
}
|
|
|
|
Process {
|
|
id: kcolorDetector
|
|
running: false
|
|
command: ["which", "kcolorchooser"]
|
|
|
|
onExited: (code, status) => {
|
|
if (code === 0) {
|
|
availablePicker = "kcolorchooser"
|
|
}
|
|
}
|
|
}
|
|
|
|
Process {
|
|
id: kcolorchooserProcess
|
|
running: false
|
|
command: ["kcolorchooser", "--print"]
|
|
|
|
stdout: SplitParser {
|
|
onRead: data => {
|
|
const colorValue = data.trim()
|
|
if (colorValue.length > 0) {
|
|
copyColorToClipboard(colorValue)
|
|
colorSelected(colorValue)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Process {
|
|
id: zenityProcess
|
|
running: false
|
|
command: ["zenity", "--color-selection", "--show-palette"]
|
|
|
|
stdout: SplitParser {
|
|
onRead: data => {
|
|
const colorValue = data.trim()
|
|
if (colorValue.length > 0) {
|
|
copyColorToClipboard(colorValue)
|
|
colorSelected(colorValue)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Component.onCompleted: {
|
|
kcolorDetector.running = true
|
|
}
|
|
} |