session: detect running downloads

This commit is contained in:
end-4
2025-07-25 23:09:17 +07:00
parent c8b007631d
commit 5099ce15db
@@ -15,6 +15,29 @@ Scope {
id: root id: root
property var focusedScreen: Quickshell.screens.find(s => s.name === Hyprland.focusedMonitor?.name) property var focusedScreen: Quickshell.screens.find(s => s.name === Hyprland.focusedMonitor?.name)
property bool packageManagerRunning: false property bool packageManagerRunning: false
property bool downloadRunning: false
component DescriptionLabel: Rectangle {
id: descriptionLabel
property string text
property color textColor: Appearance.colors.colOnTooltip
color: Appearance.colors.colTooltip
clip: true
radius: Appearance.rounding.normal
implicitHeight: descriptionLabelText.implicitHeight + 10 * 2
implicitWidth: descriptionLabelText.implicitWidth + 15 * 2
Behavior on implicitWidth {
animation: Appearance.animation.elementMove.numberAnimation.createObject(this)
}
StyledText {
id: descriptionLabelText
anchors.centerIn: parent
color: descriptionLabel.textColor
text: descriptionLabel.text
}
}
function closeAllWindows() { function closeAllWindows() {
HyprlandData.windowList.map(w => w.pid).forEach((pid) => { HyprlandData.windowList.map(w => w.pid).forEach((pid) => {
@@ -22,10 +45,13 @@ Scope {
}); });
} }
function detectRunningPackageManager() { function detectRunningStuff() {
packageManagerRunning = false; packageManagerRunning = false;
downloadRunning = false;
detectPackageManagerProc.running = false; detectPackageManagerProc.running = false;
detectPackageManagerProc.running = true; detectPackageManagerProc.running = true;
detectDownloadProc.running = false;
detectDownloadProc.running = true;
} }
Process { Process {
@@ -37,11 +63,19 @@ Scope {
} }
} }
Process {
id: detectDownloadProc
command: ["bash", "-c", "pidof curl wget aria2c yt-dlp || ls ~/Downloads | grep -E '\.crdownload$|\.part$'"]
onExited: (exitCode, exitStatus) => {
root.downloadRunning = (exitCode === 0);
}
}
Loader { Loader {
id: sessionLoader id: sessionLoader
active: false active: false
onActiveChanged: { onActiveChanged: {
if (sessionLoader.active) root.detectRunningPackageManager(); if (sessionLoader.active) root.detectRunningStuff();
} }
Connections { Connections {
@@ -201,54 +235,39 @@ Scope {
} }
} }
Rectangle { DescriptionLabel {
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
radius: Appearance.rounding.normal text: sessionRoot.subtitle
implicitHeight: sessionSubtitle.implicitHeight + 10 * 2
implicitWidth: sessionSubtitle.implicitWidth + 15 * 2
color: Appearance.colors.colTooltip
clip: true
Behavior on implicitWidth {
animation: Appearance.animation.elementMove.numberAnimation.createObject(this)
}
StyledText {
id: sessionSubtitle
anchors.centerIn: parent
color: Appearance.colors.colOnTooltip
text: sessionRoot.subtitle
}
} }
} }
Loader { RowLayout {
active: root.packageManagerRunning
anchors { anchors {
top: contentColumn.bottom top: contentColumn.bottom
topMargin: 10 topMargin: 10
horizontalCenter: contentColumn.horizontalCenter horizontalCenter: contentColumn.horizontalCenter
} }
sourceComponent: Rectangle { spacing: 10
radius: Appearance.rounding.normal
implicitHeight: sessionWarning.implicitHeight + 10 * 2
implicitWidth: sessionWarning.implicitWidth + 15 * 2
color: Appearance.m3colors.m3errorContainer
clip: true
Behavior on implicitWidth { Loader {
animation: Appearance.animation.elementMove.numberAnimation.createObject(this) active: root.packageManagerRunning
} visible: active
sourceComponent: DescriptionLabel {
StyledText {
id: sessionWarning
anchors.centerIn: parent
color: Appearance.m3colors.m3onErrorContainer
text: Translation.tr("Your package manager is running") text: Translation.tr("Your package manager is running")
textColor: Appearance.m3colors.m3onErrorContainer
color: Appearance.m3colors.m3errorContainer
}
}
Loader {
active: root.downloadRunning
visible: active
sourceComponent: DescriptionLabel {
text: Translation.tr("There might be a download in progress")
textColor: Appearance.m3colors.m3onErrorContainer
color: Appearance.m3colors.m3errorContainer
} }
} }
} }
} }
} }