forked from Shinonome/dots-hyprland
per-monitor handling of sidebar opening
This commit is contained in:
@@ -16,6 +16,12 @@ Singleton {
|
|||||||
return Qt.rgba(percentage * c1.r + (1 - percentage) * c2.r, percentage * c1.g + (1 - percentage) * c2.g, percentage * c1.b + (1 - percentage) * c2.b, percentage * c1.a + (1 - percentage) * c2.a);
|
return Qt.rgba(percentage * c1.r + (1 - percentage) * c2.r, percentage * c1.g + (1 - percentage) * c2.g, percentage * c1.b + (1 - percentage) * c2.b, percentage * c1.a + (1 - percentage) * c2.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Transparentize
|
||||||
|
function transparentize(color, percentage) {
|
||||||
|
var c = Qt.color(color);
|
||||||
|
return Qt.rgba(c.r, c.g, c.b, c.a * (1 - percentage));
|
||||||
|
}
|
||||||
|
|
||||||
m3colors: QtObject {
|
m3colors: QtObject {
|
||||||
property bool darkmode: false
|
property bool darkmode: false
|
||||||
property bool transparent: false
|
property bool transparent: false
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ pragma Singleton
|
|||||||
Singleton {
|
Singleton {
|
||||||
property string time: Qt.formatDateTime(clock.date, "hh:mm")
|
property string time: Qt.formatDateTime(clock.date, "hh:mm")
|
||||||
property string date: Qt.formatDateTime(clock.date, "dddd, dd/MM")
|
property string date: Qt.formatDateTime(clock.date, "dddd, dd/MM")
|
||||||
|
property string uptime: "0h, 0m"
|
||||||
|
|
||||||
SystemClock {
|
SystemClock {
|
||||||
id: clock
|
id: clock
|
||||||
@@ -13,4 +14,34 @@ Singleton {
|
|||||||
precision: SystemClock.Minutes
|
precision: SystemClock.Minutes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
interval: 10
|
||||||
|
running: true
|
||||||
|
repeat: true
|
||||||
|
onTriggered: {
|
||||||
|
fileUptime.reload()
|
||||||
|
const textUptime = fileUptime.text()
|
||||||
|
const uptimeSeconds = Number(textUptime.split(" ")[0] ?? 0)
|
||||||
|
|
||||||
|
// Convert seconds to days, hours, and minutes
|
||||||
|
const days = Math.floor(uptimeSeconds / 86400)
|
||||||
|
const hours = Math.floor((uptimeSeconds % 86400) / 3600)
|
||||||
|
const minutes = Math.floor((uptimeSeconds % 3600) / 60)
|
||||||
|
|
||||||
|
// Build the formatted uptime string
|
||||||
|
let formatted = ""
|
||||||
|
if (days > 0) formatted += `${days}d`
|
||||||
|
if (hours > 0) formatted += `${formatted ? ", " : ""}${hours}h`
|
||||||
|
if (minutes > 0 || !formatted) formatted += `${formatted ? ", " : ""}${minutes}m`
|
||||||
|
uptime = formatted
|
||||||
|
interval = ConfigOptions.resources.updateInterval;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FileView {
|
||||||
|
id: fileUptime
|
||||||
|
|
||||||
|
path: "/proc/uptime"
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ Singleton {
|
|||||||
property var previousCpuStats
|
property var previousCpuStats
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
interval: 50
|
interval: 10
|
||||||
running: true
|
running: true
|
||||||
repeat: true
|
repeat: true
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
import QtQuick
|
||||||
|
import Quickshell
|
||||||
|
import Quickshell.Io
|
||||||
|
pragma Singleton
|
||||||
|
|
||||||
|
Singleton {
|
||||||
|
property string distroName: "Unknown"
|
||||||
|
property string distroId: "unknown"
|
||||||
|
property string distroIcon: "linux-symbolic"
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
interval: 1
|
||||||
|
running: true
|
||||||
|
repeat: false
|
||||||
|
onTriggered: {
|
||||||
|
fileOsRelease.reload()
|
||||||
|
const textOsRelease = fileOsRelease.text()
|
||||||
|
|
||||||
|
// Extract the friendly name (PRETTY_NAME field, fallback to NAME)
|
||||||
|
const prettyNameMatch = textOsRelease.match(/^PRETTY_NAME="(.+?)"/m)
|
||||||
|
const nameMatch = textOsRelease.match(/^NAME="(.+?)"/m)
|
||||||
|
distroName = prettyNameMatch ? prettyNameMatch[1] : (nameMatch ? nameMatch[1].replace(/Linux/i, "").trim() : "Unknown")
|
||||||
|
|
||||||
|
// Extract the ID (LOGO field, fallback to "unknown")
|
||||||
|
const logoMatch = textOsRelease.match(/^LOGO=(.+)$/m)
|
||||||
|
distroId = logoMatch ? logoMatch[1].replace(/"/g, "") : "unknown"
|
||||||
|
|
||||||
|
// Update the distroIcon property based on distroId
|
||||||
|
switch (distroId) {
|
||||||
|
case "arch": distroIcon = "arch-symbolic"; break;
|
||||||
|
case "endeavouros": distroIcon = "endeavouros-symbolic"; break;
|
||||||
|
case "cachyos": distroIcon = "cachyos-symbolic"; break;
|
||||||
|
case "nixos": distroIcon = "nixos-symbolic"; break;
|
||||||
|
case "fedora": distroIcon = "fedora-symbolic"; break;
|
||||||
|
case "linuxmint":
|
||||||
|
case "ubuntu":
|
||||||
|
case "zorin":
|
||||||
|
case "popos": distroIcon = "ubuntu-symbolic"; break;
|
||||||
|
case "debian":
|
||||||
|
case "raspbian":
|
||||||
|
case "kali": distroIcon = "debian-symbolic"; break;
|
||||||
|
default: distroIcon = "linux-symbolic"; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FileView {
|
||||||
|
id: fileOsRelease
|
||||||
|
path: "/etc/os-release"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,8 @@ import QtQuick.Layouts
|
|||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Wayland
|
import Quickshell.Wayland
|
||||||
|
import Quickshell.Hyprland
|
||||||
|
import Qt5Compat.GraphicalEffects
|
||||||
|
|
||||||
Scope {
|
Scope {
|
||||||
id: bar
|
id: bar
|
||||||
@@ -13,6 +15,7 @@ Scope {
|
|||||||
readonly property int sidebarWidth: Appearance.sizes.sidebarWidth
|
readonly property int sidebarWidth: Appearance.sizes.sidebarWidth
|
||||||
|
|
||||||
Variants {
|
Variants {
|
||||||
|
id: sidebarVariants
|
||||||
model: Quickshell.screens
|
model: Quickshell.screens
|
||||||
|
|
||||||
PanelWindow {
|
PanelWindow {
|
||||||
@@ -45,26 +48,31 @@ Scope {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Shadow
|
// Shadow
|
||||||
// DropShadow {
|
DropShadow {
|
||||||
// anchors.fill: sideRightBackground
|
anchors.fill: sidebarRightBackground
|
||||||
// horizontalOffset: 0
|
horizontalOffset: 0
|
||||||
// verticalOffset: 2
|
verticalOffset: 2
|
||||||
// radius: 3
|
radius: Appearance.sizes.elevationMargin
|
||||||
// samples: 17
|
samples: Appearance.sizes.elevationMargin * 2 + 1 // Ideally should be 2 * radius + 1, see qt docs
|
||||||
// color: Appearance.m3colors.m3shadow
|
color: Appearance.transparentize(Appearance.m3colors.m3shadow, 0.55)
|
||||||
// source: sideRightBackground
|
source: sidebarRightBackground
|
||||||
// }
|
|
||||||
|
|
||||||
IpcHandler {
|
|
||||||
target: "sidebarRight"
|
|
||||||
|
|
||||||
function toggle(): void {
|
|
||||||
sidebarRoot.visible = !sidebarRoot.visible
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IpcHandler {
|
||||||
|
target: "sidebarRight"
|
||||||
|
|
||||||
|
function toggle(): void {
|
||||||
|
for (let i = 0; i < sidebarVariants.instances.length; i++) {
|
||||||
|
let panelWindow = sidebarVariants.instances[i];
|
||||||
|
if (panelWindow.modelData.name == Hyprland.focusedMonitor.name) {
|
||||||
|
panelWindow.visible = !panelWindow.visible;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user