Files
dots-hyprland/dots/.config/quickshell/ii/modules/common/utils/ImageDownloaderProcess.qml
T
2025-11-29 02:40:28 +03:00

37 lines
1.1 KiB
QML

import QtQuick
import Quickshell
import Quickshell.Io
import qs.modules.common
import qs.modules.common.functions
Process {
id: root
signal done(string path, int width, int height);
required property string filePath;
required property string sourceUrl;
property string downloadUserAgent: Config.options?.networking.userAgent ?? ""
function processFilePath() {
return StringUtils.shellSingleQuoteEscape(FileUtils.trimFileProtocol(filePath));
}
running: true
command: ["bash", "-c",
`mkdir -p $(dirname '${processFilePath()}'); [ -f '${processFilePath()}' ] || curl -sSL '${sourceUrl}' -o '${processFilePath()}' && file '${processFilePath()}'`
]
stdout: StdioCollector {
id: imageSizeOutputCollector
onStreamFinished: {
const output = imageSizeOutputCollector.text.trim();
const match = output.match(/(\d+)\s*x\s*(\d+)/);
if (match) {
const width = Number(match[1]);
const height = Number(match[2]);
root.done(root.filePath, width, height);
}
}
}
}