mirror of
https://github.com/end-4/dots-hyprland.git
synced 2026-06-05 14:59:27 -05:00
37 lines
1.1 KiB
QML
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);
|
|
}
|
|
}
|
|
}
|
|
}
|