mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
Merge branch 'main' into system_monitor_high_pressure_highlight
This commit is contained in:
@@ -908,7 +908,7 @@
|
||||
"programs": {
|
||||
"code": {
|
||||
"description": "Schreibe {Dateipfad}. Das Hyprluna-Theme muss manuell installiert und aktiviert werden",
|
||||
"description-missing": "Benötigt die Installation von {app}"
|
||||
"description-missing": "Kein Code-Client erkannt. Installieren Sie VSCode oder VSCodium."
|
||||
},
|
||||
"description": "Anwendungsspezifisches Theming.",
|
||||
"discord": {
|
||||
|
||||
@@ -908,7 +908,7 @@
|
||||
"programs": {
|
||||
"code": {
|
||||
"description": "Write {filepath}. Hyprluna theme needs to be installed and activated manually.",
|
||||
"description-missing": "Requires {app} to be installed"
|
||||
"description-missing": "No Code client detected. Install VSCode or VSCodium."
|
||||
},
|
||||
"description": "Application-specific theming.",
|
||||
"discord": {
|
||||
|
||||
@@ -908,7 +908,7 @@
|
||||
"programs": {
|
||||
"code": {
|
||||
"description": "Escribe {filepath}. El tema Hyprluna debe ser instalado y activado manualmente.",
|
||||
"description-missing": "Requiere que {app} esté instalado/a."
|
||||
"description-missing": "No se detectó cliente de Code. Instala VSCode o VSCodium."
|
||||
},
|
||||
"description": "Tematización específica de aplicaciones.",
|
||||
"discord": {
|
||||
|
||||
@@ -928,7 +928,7 @@
|
||||
"programs": {
|
||||
"code": {
|
||||
"description": "Écrire {filepath}. Le thème Hyprluna doit être installé et activé manuellement.",
|
||||
"description-missing": "Nécessite l'installation de {app}"
|
||||
"description-missing": "Aucun client Code détecté. Installez VSCode ou VSCodium."
|
||||
},
|
||||
"description": "Thématisation spécifique aux applications.",
|
||||
"discord": {
|
||||
|
||||
@@ -900,7 +900,7 @@
|
||||
"programs": {
|
||||
"code": {
|
||||
"description": "Schrijf {filepath}. Het Hyprluna-thema moet handmatig worden geïnstalleerd en geactiveerd.",
|
||||
"description-missing": "Vereist dat {app} is geïnstalleerd."
|
||||
"description-missing": "Geen Code-client gedetecteerd. Installeer VSCode of VSCodium."
|
||||
},
|
||||
"description": "Toepassingsspecifieke theming.",
|
||||
"discord": {
|
||||
|
||||
@@ -908,7 +908,7 @@
|
||||
"programs": {
|
||||
"code": {
|
||||
"description": "Escreva em {filepath}. O tema Hyprluna precisa ser instalado e ativado manualmente.",
|
||||
"description-missing": "Requer que o {app} esteja instalado."
|
||||
"description-missing": "Nenhum cliente Code detectado. Instale VSCode ou VSCodium."
|
||||
},
|
||||
"description": "Tematização específica de aplicativos.",
|
||||
"discord": {
|
||||
|
||||
@@ -908,7 +908,7 @@
|
||||
"programs": {
|
||||
"code": {
|
||||
"description": "Записать {filepath}. Тему Hyprluna нужно установить и активировать вручную.",
|
||||
"description-missing": "Требуется установка {app}"
|
||||
"description-missing": "Клиент Code не обнаружен. Установите VSCode или VSCodium."
|
||||
},
|
||||
"description": "Тематика для конкретных приложений.",
|
||||
"discord": {
|
||||
|
||||
@@ -908,7 +908,7 @@
|
||||
"programs": {
|
||||
"code": {
|
||||
"description": "{filepath} dosyasına yaz. Hyprluna temasının kurulu ve manuel olarak etkinleştirilmiş olması gerekir.",
|
||||
"description-missing": "Kurulum için {app} gereklidir"
|
||||
"description-missing": "Code istemcisi tespit edilmedi. VSCode veya VSCodium kurun."
|
||||
},
|
||||
"description": "Uygulamaya özel temalandırma.",
|
||||
"discord": {
|
||||
|
||||
@@ -908,7 +908,7 @@
|
||||
"programs": {
|
||||
"code": {
|
||||
"description": "Записати {filepath}. Тему Hyprluna потрібно встановити та активувати вручну.",
|
||||
"description-missing": "Потрібна установка {app}"
|
||||
"description-missing": "Клієнт Code не виявлено. Встановіть VSCode або VSCodium."
|
||||
},
|
||||
"description": "Оформлення окремих програм.",
|
||||
"discord": {
|
||||
|
||||
@@ -908,7 +908,7 @@
|
||||
"programs": {
|
||||
"code": {
|
||||
"description": "写入 {filepath}。Hyprluna 主题需要手动安装和激活。",
|
||||
"description-missing": "需要安装 {app}"
|
||||
"description-missing": "未检测到 Code 客户端。请安装 VSCode 或 VSCodium。"
|
||||
},
|
||||
"description": "应用程序特定主题。",
|
||||
"discord": {
|
||||
|
||||
@@ -310,13 +310,7 @@
|
||||
"walker": false,
|
||||
"code": false,
|
||||
"spicetify": false,
|
||||
"enableUserTemplates": false,
|
||||
"discord_vesktop": false,
|
||||
"discord_webcord": false,
|
||||
"discord_armcord": false,
|
||||
"discord_equibop": false,
|
||||
"discord_lightcord": false,
|
||||
"discord_dorion": false
|
||||
"enableUserTemplates": false
|
||||
},
|
||||
"nightLight": {
|
||||
"enabled": false,
|
||||
|
||||
+24
-19
@@ -453,13 +453,6 @@ Singleton {
|
||||
property bool code: false
|
||||
property bool spicetify: false
|
||||
property bool enableUserTemplates: false
|
||||
|
||||
property bool discord_vesktop: false // To be deleted soon
|
||||
property bool discord_webcord: false // To be deleted soon
|
||||
property bool discord_armcord: false // To be deleted soon
|
||||
property bool discord_equibop: false // To be deleted soon
|
||||
property bool discord_lightcord: false // To be deleted soon
|
||||
property bool discord_dorion: false // To be deleted soon
|
||||
}
|
||||
|
||||
// night light
|
||||
@@ -669,22 +662,34 @@ Singleton {
|
||||
// 5th. Migrate Discord templates (version 20 → 21)
|
||||
// Consolidate individual discord_* properties into unified discord property
|
||||
if (adapter.settingsVersion < 21) {
|
||||
var anyDiscordEnabled = false
|
||||
// Read raw JSON file to access properties not in adapter schema
|
||||
try {
|
||||
var rawJson = settingsFileView.text()
|
||||
|
||||
// Check if any Discord client was enabled
|
||||
const discordClients = ["discord_vesktop", "discord_webcord", "discord_armcord", "discord_equibop", "discord_lightcord", "discord_dorion"]
|
||||
if (rawJson) {
|
||||
var parsed = JSON.parse(rawJson)
|
||||
var anyDiscordEnabled = false
|
||||
|
||||
for (var i = 0; i < discordClients.length; i++) {
|
||||
if (adapter.templates[discordClients[i]]) {
|
||||
anyDiscordEnabled = true
|
||||
break
|
||||
// Check if any Discord client was enabled
|
||||
const discordClients = ["discord_vesktop", "discord_webcord", "discord_armcord", "discord_equibop", "discord_lightcord", "discord_dorion", "discord_vencord"]
|
||||
|
||||
if (parsed.templates) {
|
||||
for (var i = 0; i < discordClients.length; i++) {
|
||||
if (parsed.templates[discordClients[i]]) {
|
||||
anyDiscordEnabled = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set unified discord property
|
||||
adapter.templates.discord = anyDiscordEnabled
|
||||
|
||||
Logger.i("Settings", "Migrated Discord templates to unified 'discord' property (enabled:", anyDiscordEnabled + ")")
|
||||
}
|
||||
} catch (error) {
|
||||
Logger.w("Settings", "Failed to read raw JSON for Discord migration:", error)
|
||||
}
|
||||
|
||||
// Set unified discord property
|
||||
adapter.templates.discord = anyDiscordEnabled
|
||||
|
||||
Logger.i("Settings", "Migrated Discord templates to unified 'discord' property (enabled:", anyDiscordEnabled + ")")
|
||||
}
|
||||
|
||||
// -----------------
|
||||
|
||||
@@ -122,6 +122,16 @@ PopupWindow {
|
||||
border.color: Color.mOutline
|
||||
border.width: Math.max(1, Style.borderS)
|
||||
radius: Style.radiusM
|
||||
|
||||
// Fade-in animation
|
||||
opacity: root.visible ? 1.0 : 0.0
|
||||
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
duration: Style.animationNormal
|
||||
easing.type: Easing.OutQuad
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Flickable {
|
||||
@@ -131,6 +141,16 @@ PopupWindow {
|
||||
contentHeight: columnLayout.implicitHeight
|
||||
interactive: true
|
||||
|
||||
// Fade-in animation
|
||||
opacity: root.visible ? 1.0 : 0.0
|
||||
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
duration: Style.animationNormal
|
||||
easing.type: Easing.OutQuad
|
||||
}
|
||||
}
|
||||
|
||||
// Use a ColumnLayout to handle menu item arrangement
|
||||
ColumnLayout {
|
||||
id: columnLayout
|
||||
|
||||
@@ -50,6 +50,9 @@ Item {
|
||||
// Ignore the first volume change
|
||||
firstInputVolumeReceived = true
|
||||
} else {
|
||||
// If a tooltip is visible while we show the pill
|
||||
// hide it so it doesn't overlap the volume slider.
|
||||
TooltipService.hide()
|
||||
pill.show()
|
||||
externalHideTimer.restart()
|
||||
}
|
||||
@@ -65,6 +68,7 @@ Item {
|
||||
// Ignore the first mute change
|
||||
firstInputVolumeReceived = true
|
||||
} else {
|
||||
TooltipService.hide()
|
||||
pill.show()
|
||||
externalHideTimer.restart()
|
||||
}
|
||||
@@ -96,6 +100,9 @@ Item {
|
||||
})
|
||||
|
||||
onWheel: function (delta) {
|
||||
// As soon as we start scrolling to adjust volume, hide the tooltip
|
||||
TooltipService.hide()
|
||||
|
||||
wheelAccumulator += delta
|
||||
if (wheelAccumulator >= 120) {
|
||||
wheelAccumulator = 0
|
||||
|
||||
@@ -50,6 +50,8 @@ Item {
|
||||
// Ignore the first volume change
|
||||
firstVolumeReceived = true
|
||||
} else {
|
||||
// Hide any tooltip while the pill is visible / being updated
|
||||
TooltipService.hide()
|
||||
pill.show()
|
||||
externalHideTimer.restart()
|
||||
}
|
||||
@@ -81,6 +83,9 @@ Item {
|
||||
})
|
||||
|
||||
onWheel: function (delta) {
|
||||
// Hide tooltip as soon as the user starts scrolling to adjust volume
|
||||
TooltipService.hide()
|
||||
|
||||
wheelAccumulator += delta
|
||||
if (wheelAccumulator >= 120) {
|
||||
wheelAccumulator = 0
|
||||
|
||||
@@ -2,6 +2,7 @@ import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Services.Pam
|
||||
import qs.Commons
|
||||
import qs.Services.System
|
||||
|
||||
Scope {
|
||||
id: root
|
||||
@@ -40,7 +41,7 @@ Scope {
|
||||
PamContext {
|
||||
id: pam
|
||||
config: "login"
|
||||
user: Quickshell.env("USER")
|
||||
user: HostService.displayName
|
||||
|
||||
onPamMessage: {
|
||||
Logger.i("LockContext", "PAM message:", message, "isError:", messageIsError, "responseRequired:", responseRequired)
|
||||
|
||||
@@ -15,6 +15,7 @@ import qs.Services.Location
|
||||
import qs.Services.Media
|
||||
import qs.Services.Compositor
|
||||
import qs.Services.UI
|
||||
import qs.Services.System
|
||||
import qs.Widgets
|
||||
import qs.Widgets.AudioSpectrum
|
||||
|
||||
@@ -336,7 +337,7 @@ Loader {
|
||||
|
||||
// Welcome back + Username on one line
|
||||
NText {
|
||||
text: I18n.tr("lock-screen.welcome-back") + " " + (Quickshell.env("USER").charAt(0).toUpperCase() + Quickshell.env("USER").slice(1)) + "!"
|
||||
text: I18n.tr("lock-screen.welcome-back") + " " + HostService.displayName + "!"
|
||||
pointSize: Style.fontSizeXXL
|
||||
font.weight: Font.Medium
|
||||
color: Color.mOnSurface
|
||||
|
||||
@@ -56,6 +56,48 @@ Item {
|
||||
// Expose panelBackground as panelItem for AllBackgrounds
|
||||
readonly property var panelItem: panelBackground
|
||||
|
||||
// Primary anchor edge for window positioning
|
||||
readonly property string primaryAnchorEdge: {
|
||||
if (effectivePanelAnchorTop)
|
||||
return "top"
|
||||
if (effectivePanelAnchorBottom)
|
||||
return "bottom"
|
||||
if (effectivePanelAnchorLeft)
|
||||
return "left"
|
||||
if (effectivePanelAnchorRight)
|
||||
return "right"
|
||||
return "top"
|
||||
// default
|
||||
}
|
||||
|
||||
// Calculate window margins for content-sized panel windows
|
||||
function getWindowMargins() {
|
||||
if (!root.width || !root.height)
|
||||
return {
|
||||
"top": 0,
|
||||
"bottom": 0,
|
||||
"left": 0,
|
||||
"right": 0
|
||||
}
|
||||
|
||||
// Determine which edges are anchored (matching SmartPanelWindow logic)
|
||||
var isPrimaryVertical = primaryAnchorEdge === "top" || primaryAnchorEdge === "bottom"
|
||||
var isPrimaryHorizontal = primaryAnchorEdge === "left" || primaryAnchorEdge === "right"
|
||||
|
||||
// Anchor the primary edge + opposite edges of the other axis
|
||||
var useTop = effectivePanelAnchorTop || primaryAnchorEdge === "top" || isPrimaryHorizontal
|
||||
var useBottom = effectivePanelAnchorBottom || primaryAnchorEdge === "bottom" || isPrimaryHorizontal
|
||||
var useLeft = effectivePanelAnchorLeft || primaryAnchorEdge === "left" || isPrimaryVertical
|
||||
var useRight = effectivePanelAnchorRight || primaryAnchorEdge === "right" || isPrimaryVertical
|
||||
|
||||
return {
|
||||
"top": useTop ? panelBackground.targetY : 0,
|
||||
"bottom": useBottom ? (root.height - panelBackground.targetY - panelBackground.targetHeight) : 0,
|
||||
"left": useLeft ? panelBackground.targetX : 0,
|
||||
"right": useRight ? (root.width - panelBackground.targetX - panelBackground.targetWidth) : 0
|
||||
}
|
||||
}
|
||||
|
||||
// Bar configuration
|
||||
readonly property string barPosition: Settings.data.bar.position
|
||||
readonly property bool barIsVertical: barPosition === "left" || barPosition === "right"
|
||||
|
||||
@@ -43,8 +43,8 @@ Item {
|
||||
// Support close with escape
|
||||
property bool closeWithEscape: true
|
||||
|
||||
// Track if window has been created (for lazy loading)
|
||||
property bool windowCreated: false
|
||||
// Track if window should be active (for lazy loading and cleanup)
|
||||
property bool windowActive: false
|
||||
|
||||
// Expose panel state (from content window)
|
||||
readonly property bool isPanelOpen: windowLoader.item ? windowLoader.item.isPanelOpen : false
|
||||
@@ -77,8 +77,8 @@ Item {
|
||||
// Public control functions
|
||||
function toggle(buttonItem, buttonName) {
|
||||
// Ensure window is created before toggling
|
||||
if (!windowCreated) {
|
||||
windowCreated = true
|
||||
if (!root.windowActive) {
|
||||
root.windowActive = true
|
||||
Qt.callLater(function () {
|
||||
if (windowLoader.item) {
|
||||
windowLoader.item.toggle(buttonItem, buttonName)
|
||||
@@ -91,8 +91,8 @@ Item {
|
||||
|
||||
function open(buttonItem, buttonName) {
|
||||
// Ensure window is created before opening
|
||||
if (!windowCreated) {
|
||||
windowCreated = true
|
||||
if (!root.windowActive) {
|
||||
root.windowActive = true
|
||||
Qt.callLater(function () {
|
||||
if (windowLoader.item) {
|
||||
windowLoader.item.open(buttonItem, buttonName)
|
||||
@@ -143,10 +143,10 @@ Item {
|
||||
parent: root.parent
|
||||
}
|
||||
|
||||
// Lazy-load the content window (only created on first open)
|
||||
// Lazy-load the content window (only created when open, destroyed when closed)
|
||||
Loader {
|
||||
id: windowLoader
|
||||
active: root.windowCreated
|
||||
active: root.windowActive
|
||||
sourceComponent: SmartPanelWindow {
|
||||
placeholder: panelPlaceholder
|
||||
panelContent: root.panelContent
|
||||
@@ -156,7 +156,13 @@ Item {
|
||||
|
||||
// Forward signals
|
||||
onPanelOpened: root.opened()
|
||||
onPanelClosed: root.closed()
|
||||
onPanelClosed: {
|
||||
root.closed()
|
||||
// Destroy the window after close animation completes
|
||||
Qt.callLater(function () {
|
||||
root.windowActive = false
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,10 @@ PanelWindow {
|
||||
property bool closeWatchdogActive: false
|
||||
property bool openWatchdogActive: false
|
||||
|
||||
// Cached window size (only update when content size changes, not during animation)
|
||||
property real cachedWindowWidth: 0
|
||||
property real cachedWindowHeight: 0
|
||||
|
||||
// Signals
|
||||
signal panelOpened
|
||||
signal panelClosed
|
||||
@@ -57,18 +61,44 @@ PanelWindow {
|
||||
mask: null // No mask - content window is rectangular
|
||||
visible: isPanelOpen
|
||||
|
||||
// Wayland layer shell configuration - fullscreen window
|
||||
// Wayland layer shell configuration - content-sized window
|
||||
WlrLayershell.layer: WlrLayer.Top
|
||||
WlrLayershell.namespace: "noctalia-panel-content-" + placeholder.panelName + "-" + (placeholder.screen?.name || "unknown")
|
||||
WlrLayershell.exclusionMode: ExclusionMode.Ignore
|
||||
WlrLayershell.keyboardFocus: !root.isPanelOpen ? WlrKeyboardFocus.None : (exclusiveKeyboard ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.OnDemand)
|
||||
|
||||
// Anchor to all edges to make fullscreen
|
||||
anchors {
|
||||
top: true
|
||||
bottom: true
|
||||
left: true
|
||||
right: true
|
||||
// Dynamic anchoring based on panel position
|
||||
// For correct positioning with Wayland layer shell:
|
||||
// - Anchor the primary edge (top/bottom/left/right)
|
||||
// - Also anchor the opposite edge of the OTHER axis (both horizontal edges if panel is vertical, both vertical edges if panel is horizontal)
|
||||
// This prevents unwanted centering and allows margins to position the panel correctly
|
||||
readonly property bool isPrimaryVertical: placeholder.primaryAnchorEdge === "top" || placeholder.primaryAnchorEdge === "bottom"
|
||||
readonly property bool isPrimaryHorizontal: placeholder.primaryAnchorEdge === "left" || placeholder.primaryAnchorEdge === "right"
|
||||
|
||||
anchors.top: placeholder.effectivePanelAnchorTop || placeholder.primaryAnchorEdge === "top" || isPrimaryHorizontal
|
||||
anchors.bottom: placeholder.effectivePanelAnchorBottom || placeholder.primaryAnchorEdge === "bottom" || isPrimaryHorizontal
|
||||
anchors.left: placeholder.effectivePanelAnchorLeft || placeholder.primaryAnchorEdge === "left" || isPrimaryVertical
|
||||
anchors.right: placeholder.effectivePanelAnchorRight || placeholder.primaryAnchorEdge === "right" || isPrimaryVertical
|
||||
|
||||
// Size to content (cached to avoid resizing during animations)
|
||||
implicitWidth: cachedWindowWidth
|
||||
implicitHeight: cachedWindowHeight
|
||||
|
||||
// Position via margins (calculated from target position, not animated position)
|
||||
readonly property var windowMargins: placeholder.getWindowMargins()
|
||||
margins.top: windowMargins.top
|
||||
margins.bottom: windowMargins.bottom
|
||||
margins.left: windowMargins.left
|
||||
margins.right: windowMargins.right
|
||||
|
||||
// Debug logging for positioning
|
||||
Component.onCompleted: {
|
||||
Logger.d("SmartPanelWindow", "Panel positioning:", placeholder.panelName)
|
||||
Logger.d("SmartPanelWindow", " primaryAnchorEdge:", placeholder.primaryAnchorEdge)
|
||||
Logger.d("SmartPanelWindow", " isPrimaryVertical:", isPrimaryVertical, "isPrimaryHorizontal:", isPrimaryHorizontal)
|
||||
Logger.d("SmartPanelWindow", " anchors:", anchors.top, anchors.bottom, anchors.left, anchors.right)
|
||||
Logger.d("SmartPanelWindow", " margins (TLBR):", windowMargins.top, windowMargins.left, windowMargins.bottom, windowMargins.right)
|
||||
Logger.d("SmartPanelWindow", " size:", cachedWindowWidth, "x", cachedWindowHeight)
|
||||
}
|
||||
|
||||
// Sync state to placeholder
|
||||
@@ -82,6 +112,19 @@ PanelWindow {
|
||||
placeholder.opacityFadeComplete = opacityFadeComplete
|
||||
}
|
||||
|
||||
// Update cached window size (only when target size changes)
|
||||
function updateWindowSize() {
|
||||
var targetWidth = placeholder.panelItem.targetWidth
|
||||
var targetHeight = placeholder.panelItem.targetHeight
|
||||
|
||||
// Only update if size actually changed
|
||||
if (cachedWindowWidth !== targetWidth || cachedWindowHeight !== targetHeight) {
|
||||
cachedWindowWidth = targetWidth
|
||||
cachedWindowHeight = targetHeight
|
||||
Logger.d("SmartPanelWindow", "Window size updated:", targetWidth, "x", targetHeight, placeholder.panelName)
|
||||
}
|
||||
}
|
||||
|
||||
// Panel control functions
|
||||
function toggle(buttonItem, buttonName) {
|
||||
if (!isPanelOpen) {
|
||||
@@ -110,6 +153,9 @@ PanelWindow {
|
||||
placeholder.useButtonPosition = false
|
||||
}
|
||||
|
||||
// Initialize cached window size
|
||||
updateWindowSize()
|
||||
|
||||
// Set isPanelOpen to trigger content loading
|
||||
isPanelOpen = true
|
||||
|
||||
@@ -164,12 +210,13 @@ PanelWindow {
|
||||
Logger.d("SmartPanelWindow", "Panel close finalized", placeholder.panelName)
|
||||
}
|
||||
|
||||
// Fullscreen container for click-to-close and content
|
||||
// Content wrapper with opacity animation (fills content-sized window)
|
||||
Item {
|
||||
id: contentWrapper
|
||||
anchors.fill: parent
|
||||
focus: true // Enable keyboard event handling
|
||||
focus: true
|
||||
|
||||
// Handle keyboard events directly via Keys handler
|
||||
// Keyboard event handling
|
||||
Keys.onPressed: event => {
|
||||
Logger.d("SmartPanelWindow", "Key pressed:", event.key, "for panel:", placeholder.panelName)
|
||||
if (event.key === Qt.Key_Escape) {
|
||||
@@ -228,143 +275,120 @@ PanelWindow {
|
||||
}
|
||||
}
|
||||
|
||||
// Background MouseArea for click-to-close (behind content)
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
enabled: root.isPanelOpen && !root.isClosing
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
|
||||
onClicked: mouse => {
|
||||
root.close()
|
||||
mouse.accepted = true
|
||||
}
|
||||
z: 0
|
||||
// Opacity animation
|
||||
opacity: {
|
||||
if (isClosing)
|
||||
return 0.0
|
||||
if (isPanelVisible && sizeAnimationComplete)
|
||||
return 1.0
|
||||
return 0.0
|
||||
}
|
||||
|
||||
// Content wrapper with opacity animation
|
||||
Item {
|
||||
id: contentWrapper
|
||||
// Position at placeholder location within fullscreen window
|
||||
x: placeholder.panelItem.x
|
||||
y: placeholder.panelItem.y
|
||||
width: placeholder.panelItem.width
|
||||
height: placeholder.panelItem.height
|
||||
z: 1 // Above click-to-close MouseArea
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
id: opacityAnimation
|
||||
duration: root.isClosing ? Style.animationFaster : Style.animationFast
|
||||
easing.type: Easing.OutQuad
|
||||
|
||||
// Opacity animation
|
||||
opacity: {
|
||||
if (isClosing)
|
||||
return 0.0
|
||||
if (isPanelVisible && sizeAnimationComplete)
|
||||
return 1.0
|
||||
return 0.0
|
||||
}
|
||||
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
id: opacityAnimation
|
||||
duration: root.isClosing ? Style.animationFaster : Style.animationFast
|
||||
easing.type: Easing.OutQuad
|
||||
|
||||
onRunningChanged: {
|
||||
// Safety: Zero-duration animation handling
|
||||
if (!running && duration === 0) {
|
||||
if (root.isClosing && contentWrapper.opacity === 0.0) {
|
||||
root.opacityFadeComplete = true
|
||||
var shouldFinalizeNow = placeholder.panelItem && !placeholder.panelItem.shouldAnimateWidth && !placeholder.panelItem.shouldAnimateHeight
|
||||
if (shouldFinalizeNow) {
|
||||
Logger.d("SmartPanelWindow", "Zero-duration opacity + no size animation - finalizing", placeholder.panelName)
|
||||
Qt.callLater(root.finalizeClose)
|
||||
}
|
||||
} else if (root.isPanelVisible && contentWrapper.opacity === 1.0) {
|
||||
root.openWatchdogActive = false
|
||||
openWatchdogTimer.stop()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// When opacity fade completes during close, trigger size animation
|
||||
if (!running && root.isClosing && contentWrapper.opacity === 0.0) {
|
||||
onRunningChanged: {
|
||||
// Safety: Zero-duration animation handling
|
||||
if (!running && duration === 0) {
|
||||
if (root.isClosing && contentWrapper.opacity === 0.0) {
|
||||
root.opacityFadeComplete = true
|
||||
var shouldFinalizeNow = placeholder.panelItem && !placeholder.panelItem.shouldAnimateWidth && !placeholder.panelItem.shouldAnimateHeight
|
||||
if (shouldFinalizeNow) {
|
||||
Logger.d("SmartPanelWindow", "No animation - finalizing immediately", placeholder.panelName)
|
||||
Logger.d("SmartPanelWindow", "Zero-duration opacity + no size animation - finalizing", placeholder.panelName)
|
||||
Qt.callLater(root.finalizeClose)
|
||||
} else {
|
||||
Logger.d("SmartPanelWindow", "Animation will run - waiting for size animation", placeholder.panelName)
|
||||
}
|
||||
} // When opacity fade completes during open, stop watchdog
|
||||
else if (!running && root.isPanelVisible && contentWrapper.opacity === 1.0) {
|
||||
} else if (root.isPanelVisible && contentWrapper.opacity === 1.0) {
|
||||
root.openWatchdogActive = false
|
||||
openWatchdogTimer.stop()
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Panel content loader
|
||||
Loader {
|
||||
id: contentLoader
|
||||
active: isPanelOpen
|
||||
anchors.fill: parent
|
||||
sourceComponent: root.panelContent
|
||||
|
||||
// When content finishes loading, trigger positioning and visibility
|
||||
onLoaded: {
|
||||
// Capture initial content-driven size if available
|
||||
if (contentLoader.item) {
|
||||
var hasWidthProp = contentLoader.item.hasOwnProperty('contentPreferredWidth')
|
||||
var hasHeightProp = contentLoader.item.hasOwnProperty('contentPreferredHeight')
|
||||
|
||||
if (hasWidthProp || hasHeightProp) {
|
||||
var initialWidth = hasWidthProp ? contentLoader.item.contentPreferredWidth : 0
|
||||
var initialHeight = hasHeightProp ? contentLoader.item.contentPreferredHeight : 0
|
||||
placeholder.updateContentSize(initialWidth, initialHeight)
|
||||
Logger.d("SmartPanelWindow", "Initial content size:", initialWidth, "x", initialHeight, placeholder.panelName)
|
||||
// When opacity fade completes during close, trigger size animation
|
||||
if (!running && root.isClosing && contentWrapper.opacity === 0.0) {
|
||||
root.opacityFadeComplete = true
|
||||
var shouldFinalizeNow = placeholder.panelItem && !placeholder.panelItem.shouldAnimateWidth && !placeholder.panelItem.shouldAnimateHeight
|
||||
if (shouldFinalizeNow) {
|
||||
Logger.d("SmartPanelWindow", "No animation - finalizing immediately", placeholder.panelName)
|
||||
Qt.callLater(root.finalizeClose)
|
||||
} else {
|
||||
Logger.d("SmartPanelWindow", "Animation will run - waiting for size animation", placeholder.panelName)
|
||||
}
|
||||
} // When opacity fade completes during open, stop watchdog
|
||||
else if (!running && root.isPanelVisible && contentWrapper.opacity === 1.0) {
|
||||
root.openWatchdogActive = false
|
||||
openWatchdogTimer.stop()
|
||||
}
|
||||
|
||||
// Calculate position in placeholder
|
||||
placeholder.setPosition()
|
||||
|
||||
// Make panel visible on the next frame
|
||||
Qt.callLater(function () {
|
||||
root.isPanelVisible = true
|
||||
opacityTrigger.start()
|
||||
|
||||
// Start open watchdog timer
|
||||
root.openWatchdogActive = true
|
||||
openWatchdogTimer.start()
|
||||
|
||||
panelOpened()
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MouseArea to prevent clicks on panel content from closing it
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
|
||||
onClicked: mouse => {
|
||||
mouse.accepted = true // Eat the click to prevent propagation to background
|
||||
}
|
||||
z: -1 // Behind content but above background click-to-close
|
||||
}
|
||||
// Panel content loader
|
||||
Loader {
|
||||
id: contentLoader
|
||||
active: isPanelOpen
|
||||
anchors.fill: parent
|
||||
sourceComponent: root.panelContent
|
||||
|
||||
// Watch for changes in content-driven sizes
|
||||
Connections {
|
||||
target: contentLoader.item
|
||||
ignoreUnknownSignals: true
|
||||
// When content finishes loading, trigger positioning and visibility
|
||||
onLoaded: {
|
||||
// Capture initial content-driven size if available
|
||||
if (contentLoader.item) {
|
||||
var hasWidthProp = contentLoader.item.hasOwnProperty('contentPreferredWidth')
|
||||
var hasHeightProp = contentLoader.item.hasOwnProperty('contentPreferredHeight')
|
||||
|
||||
function onContentPreferredWidthChanged() {
|
||||
if (root.isPanelOpen && root.isPanelVisible && contentLoader.item) {
|
||||
placeholder.updateContentSize(contentLoader.item.contentPreferredWidth, placeholder.contentPreferredHeight)
|
||||
if (hasWidthProp || hasHeightProp) {
|
||||
var initialWidth = hasWidthProp ? contentLoader.item.contentPreferredWidth : 0
|
||||
var initialHeight = hasHeightProp ? contentLoader.item.contentPreferredHeight : 0
|
||||
placeholder.updateContentSize(initialWidth, initialHeight)
|
||||
Logger.d("SmartPanelWindow", "Initial content size:", initialWidth, "x", initialHeight, placeholder.panelName)
|
||||
}
|
||||
}
|
||||
|
||||
function onContentPreferredHeightChanged() {
|
||||
if (root.isPanelOpen && root.isPanelVisible && contentLoader.item) {
|
||||
placeholder.updateContentSize(placeholder.contentPreferredWidth, contentLoader.item.contentPreferredHeight)
|
||||
}
|
||||
// Calculate position in placeholder
|
||||
placeholder.setPosition()
|
||||
|
||||
// Make panel visible on the next frame
|
||||
Qt.callLater(function () {
|
||||
root.isPanelVisible = true
|
||||
opacityTrigger.start()
|
||||
|
||||
// Start open watchdog timer
|
||||
root.openWatchdogActive = true
|
||||
openWatchdogTimer.start()
|
||||
|
||||
panelOpened()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// MouseArea to prevent clicks on panel content from closing it
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
|
||||
onClicked: mouse => {
|
||||
mouse.accepted = true // Eat the click to prevent propagation to background
|
||||
}
|
||||
z: -1 // Behind content but above background click-to-close
|
||||
}
|
||||
|
||||
// Watch for changes in content-driven sizes
|
||||
Connections {
|
||||
target: contentLoader.item
|
||||
ignoreUnknownSignals: true
|
||||
|
||||
function onContentPreferredWidthChanged() {
|
||||
if (root.isPanelOpen && root.isPanelVisible && contentLoader.item) {
|
||||
placeholder.updateContentSize(contentLoader.item.contentPreferredWidth, placeholder.contentPreferredHeight)
|
||||
}
|
||||
}
|
||||
|
||||
function onContentPreferredHeightChanged() {
|
||||
if (root.isPanelOpen && root.isPanelVisible && contentLoader.item) {
|
||||
placeholder.updateContentSize(placeholder.contentPreferredWidth, contentLoader.item.contentPreferredHeight)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -416,6 +440,16 @@ PanelWindow {
|
||||
Connections {
|
||||
target: placeholder.panelItem
|
||||
|
||||
function onTargetWidthChanged() {
|
||||
// Update cached window size when target changes (not during animation)
|
||||
root.updateWindowSize()
|
||||
}
|
||||
|
||||
function onTargetHeightChanged() {
|
||||
// Update cached window size when target changes (not during animation)
|
||||
root.updateWindowSize()
|
||||
}
|
||||
|
||||
function onWidthChanged() {
|
||||
// When width shrinks to 0 during close and we're animating width, finalize
|
||||
if (root.isClosing && placeholder.panelItem.width === 0 && placeholder.panelItem.shouldAnimateWidth) {
|
||||
|
||||
+54
-11
@@ -34,11 +34,13 @@ Variants {
|
||||
readonly property bool isMuted: AudioService.muted
|
||||
property bool volumeInitialized: false
|
||||
property bool muteInitialized: false
|
||||
property real lastKnownVolume: -1 // Track last known volume to detect actual changes
|
||||
|
||||
// Input volume properties
|
||||
readonly property real currentInputVolume: AudioService.inputVolume
|
||||
readonly property bool isInputMuted: AudioService.inputMuted
|
||||
property bool inputAudioInitialized: false
|
||||
property real lastKnownInputVolume: -1 // Track last known volume to detect actual changes
|
||||
|
||||
// Brightness properties
|
||||
property real lastUpdatedBrightness: 0
|
||||
@@ -497,32 +499,66 @@ Variants {
|
||||
target: AudioService
|
||||
|
||||
function onVolumeChanged() {
|
||||
if (volumeInitialized) {
|
||||
// If not initialized yet, capture initial volume silently (fallback if timer hasn't fired)
|
||||
if (lastKnownVolume < 0) {
|
||||
lastKnownVolume = AudioService.volume
|
||||
volumeInitialized = true
|
||||
return
|
||||
}
|
||||
if (!volumeInitialized) {
|
||||
return
|
||||
}
|
||||
// Only show OSD if volume actually changed from last known value
|
||||
if (Math.abs(AudioService.volume - lastKnownVolume) > 0.001) {
|
||||
lastKnownVolume = AudioService.volume
|
||||
showOSD("volume")
|
||||
}
|
||||
}
|
||||
|
||||
function onMutedChanged() {
|
||||
if (muteInitialized) {
|
||||
showOSD("volume")
|
||||
// If not initialized yet, capture initial state silently (fallback if timer hasn't fired)
|
||||
if (lastKnownVolume < 0) {
|
||||
lastKnownVolume = AudioService.volume
|
||||
muteInitialized = true
|
||||
return
|
||||
}
|
||||
if (!muteInitialized) {
|
||||
return
|
||||
}
|
||||
showOSD("volume")
|
||||
}
|
||||
|
||||
function onInputVolumeChanged() {
|
||||
if (!inputAudioInitialized) {
|
||||
return
|
||||
}
|
||||
if (!AudioService.hasInput) {
|
||||
return
|
||||
}
|
||||
showOSD("inputVolume")
|
||||
// If not initialized yet, capture initial volume silently (fallback if timer hasn't fired)
|
||||
if (lastKnownInputVolume < 0) {
|
||||
lastKnownInputVolume = AudioService.inputVolume
|
||||
inputAudioInitialized = true
|
||||
return
|
||||
}
|
||||
if (!inputAudioInitialized) {
|
||||
return
|
||||
}
|
||||
// Only show OSD if volume actually changed from last known value
|
||||
if (Math.abs(AudioService.inputVolume - lastKnownInputVolume) > 0.001) {
|
||||
lastKnownInputVolume = AudioService.inputVolume
|
||||
showOSD("inputVolume")
|
||||
}
|
||||
}
|
||||
|
||||
function onInputMutedChanged() {
|
||||
if (!inputAudioInitialized) {
|
||||
if (!AudioService.hasInput) {
|
||||
return
|
||||
}
|
||||
if (!AudioService.hasInput) {
|
||||
// If not initialized yet, capture initial state silently (fallback if timer hasn't fired)
|
||||
if (lastKnownInputVolume < 0) {
|
||||
lastKnownInputVolume = AudioService.inputVolume
|
||||
inputAudioInitialized = true
|
||||
return
|
||||
}
|
||||
if (!inputAudioInitialized) {
|
||||
return
|
||||
}
|
||||
showOSD("inputVolume")
|
||||
@@ -535,9 +571,16 @@ Variants {
|
||||
interval: 500
|
||||
running: true
|
||||
onTriggered: {
|
||||
volumeInitialized = true
|
||||
// Capture initial volume values to avoid showing OSD on startup
|
||||
if (lastKnownVolume < 0 && AudioService.volume !== undefined) {
|
||||
lastKnownVolume = AudioService.volume
|
||||
volumeInitialized = true
|
||||
}
|
||||
if (lastKnownInputVolume < 0 && AudioService.hasInput && AudioService.inputVolume !== undefined) {
|
||||
lastKnownInputVolume = AudioService.inputVolume
|
||||
inputAudioInitialized = true
|
||||
}
|
||||
muteInitialized = true
|
||||
inputAudioInitialized = true
|
||||
// Brightness initializes on first change to avoid showing OSD on startup
|
||||
connectBrightnessMonitors()
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import Quickshell.Widgets
|
||||
import qs.Commons
|
||||
import qs.Modules.Panels.ControlCenter.Cards
|
||||
import qs.Modules.Panels.Settings
|
||||
import qs.Services.System
|
||||
import qs.Services.UI
|
||||
import qs.Widgets
|
||||
|
||||
@@ -37,7 +38,7 @@ NBox {
|
||||
Layout.fillWidth: true
|
||||
spacing: Style.marginXXS
|
||||
NText {
|
||||
text: Quickshell.env("USER") || "user"
|
||||
text: HostService.displayName
|
||||
font.weight: Style.fontWeightBold
|
||||
font.capitalization: Font.Capitalize
|
||||
}
|
||||
|
||||
@@ -259,11 +259,6 @@ SmartPanel {
|
||||
"label": "settings.screen-recorder.title",
|
||||
"icon": "settings-screen-recorder",
|
||||
"source": screenRecorderTab
|
||||
}, {
|
||||
"id": SettingsPanel.Tab.SessionMenu,
|
||||
"label": "settings.session-menu.title",
|
||||
"icon": "settings-session-menu",
|
||||
"source": sessionMenuTab
|
||||
}, {
|
||||
"id": SettingsPanel.Tab.SystemMonitor,
|
||||
"label": "settings.system-monitor.title",
|
||||
|
||||
@@ -677,6 +677,8 @@ ColumnLayout {
|
||||
enabled: ProgramCheckerService.availableDiscordClients.length > 0
|
||||
opacity: ProgramCheckerService.availableDiscordClients.length > 0 ? 1.0 : 0.6
|
||||
onToggled: checked => {
|
||||
// Set unified discord property
|
||||
Settings.data.templates.discord = checked
|
||||
// Enable/disable all detected Discord clients
|
||||
for (var i = 0; i < ProgramCheckerService.availableDiscordClients.length; i++) {
|
||||
var client = ProgramCheckerService.availableDiscordClients[i]
|
||||
@@ -740,19 +742,50 @@ ColumnLayout {
|
||||
}
|
||||
}
|
||||
|
||||
// Code clients - single toggle with dynamic description
|
||||
NCheckbox {
|
||||
id: codeToggle
|
||||
label: "Code"
|
||||
description: ProgramCheckerService.codeAvailable ? I18n.tr("settings.color-scheme.templates.programs.code.description", {
|
||||
"filepath": "~/.vscode/extensions/hyprluna.hyprluna-theme-1.0.2/themes/hyprluna.json"
|
||||
}) : I18n.tr("settings.color-scheme.templates.programs.code.description-missing", {
|
||||
"app": "code"
|
||||
})
|
||||
checked: Settings.data.templates.code
|
||||
enabled: ProgramCheckerService.codeAvailable
|
||||
opacity: ProgramCheckerService.codeAvailable ? 1.0 : 0.6
|
||||
description: {
|
||||
if (ProgramCheckerService.availableCodeClients.length === 0) {
|
||||
return I18n.tr("settings.color-scheme.templates.programs.code.description-missing")
|
||||
} else {
|
||||
// Show detected clients
|
||||
var clientInfo = []
|
||||
for (var i = 0; i < ProgramCheckerService.availableCodeClients.length; i++) {
|
||||
var client = ProgramCheckerService.availableCodeClients[i]
|
||||
// Capitalize first letter and format nicely
|
||||
var clientName = client.name === "code" ? "VSCode" : "VSCodium"
|
||||
clientInfo.push(clientName)
|
||||
}
|
||||
return "Detected: " + clientInfo.join(", ")
|
||||
}
|
||||
}
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredWidth: -1
|
||||
checked: {
|
||||
// Check if any Code client template is enabled
|
||||
var anyEnabled = false
|
||||
for (var i = 0; i < ProgramCheckerService.availableCodeClients.length; i++) {
|
||||
var client = ProgramCheckerService.availableCodeClients[i]
|
||||
if (Settings.data.templates["code_" + client.name]) {
|
||||
anyEnabled = true
|
||||
break
|
||||
}
|
||||
}
|
||||
return anyEnabled
|
||||
}
|
||||
enabled: ProgramCheckerService.availableCodeClients.length > 0
|
||||
opacity: ProgramCheckerService.availableCodeClients.length > 0 ? 1.0 : 0.6
|
||||
onToggled: checked => {
|
||||
if (ProgramCheckerService.codeAvailable) {
|
||||
Settings.data.templates.code = checked
|
||||
// Set unified code property
|
||||
Settings.data.templates.code = checked
|
||||
// Enable/disable all detected Code clients
|
||||
for (var i = 0; i < ProgramCheckerService.availableCodeClients.length; i++) {
|
||||
var client = ProgramCheckerService.availableCodeClients[i]
|
||||
Settings.data.templates["code_" + client.name] = checked
|
||||
}
|
||||
if (ProgramCheckerService.availableCodeClients.length > 0) {
|
||||
AppThemeService.generate()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ ColumnLayout {
|
||||
|
||||
NTextInputButton {
|
||||
label: I18n.tr("settings.general.profile.picture.label", {
|
||||
"user": Quickshell.env("USER" || "User")
|
||||
"user": HostService.displayName
|
||||
})
|
||||
description: I18n.tr("settings.general.profile.picture.description")
|
||||
text: Settings.data.general.avatarImage
|
||||
|
||||
@@ -13,6 +13,7 @@ Singleton {
|
||||
property bool isHyprland: false
|
||||
property bool isNiri: false
|
||||
property bool isSway: false
|
||||
property bool isMango: false
|
||||
|
||||
// Generic workspace and window data
|
||||
property ListModel workspaces: ListModel {}
|
||||
@@ -50,30 +51,47 @@ Singleton {
|
||||
const hyprlandSignature = Quickshell.env("HYPRLAND_INSTANCE_SIGNATURE")
|
||||
const niriSocket = Quickshell.env("NIRI_SOCKET")
|
||||
const swaySock = Quickshell.env("SWAYSOCK")
|
||||
if (niriSocket && niriSocket.length > 0) {
|
||||
const currentDesktop = Quickshell.env("XDG_CURRENT_DESKTOP")
|
||||
|
||||
// Check for MangoWC using XDG_CURRENT_DESKTOP environment variable
|
||||
// MangoWC sets XDG_CURRENT_DESKTOP=mango
|
||||
if (currentDesktop && currentDesktop.toLowerCase().includes("mango")) {
|
||||
isHyprland = false
|
||||
isNiri = false
|
||||
isSway = false
|
||||
isMango = true
|
||||
backendLoader.sourceComponent = mangoComponent
|
||||
Logger.i("CompositorService", "MangoWC detected via XDG_CURRENT_DESKTOP:", currentDesktop)
|
||||
} else if (niriSocket && niriSocket.length > 0) {
|
||||
isHyprland = false
|
||||
isNiri = true
|
||||
isSway = false
|
||||
isMango = false
|
||||
backendLoader.sourceComponent = niriComponent
|
||||
} else if (hyprlandSignature && hyprlandSignature.length > 0) {
|
||||
isHyprland = true
|
||||
isNiri = false
|
||||
isSway = false
|
||||
isMango = false
|
||||
backendLoader.sourceComponent = hyprlandComponent
|
||||
} else if (swaySock && swaySock.length > 0) {
|
||||
isHyprland = false
|
||||
isNiri = false
|
||||
isSway = true
|
||||
isMango = false
|
||||
backendLoader.sourceComponent = swayComponent
|
||||
} else {
|
||||
// Always fallback to Niri
|
||||
isHyprland = false
|
||||
isNiri = true
|
||||
isSway = false
|
||||
isMango = false
|
||||
backendLoader.sourceComponent = niriComponent
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loader {
|
||||
id: backendLoader
|
||||
onLoaded: {
|
||||
@@ -134,6 +152,14 @@ Singleton {
|
||||
}
|
||||
}
|
||||
|
||||
// Mango backend component
|
||||
Component {
|
||||
id: mangoComponent
|
||||
MangoService {
|
||||
id: mangoBackend
|
||||
}
|
||||
}
|
||||
|
||||
function setupBackendConnections() {
|
||||
if (!backend)
|
||||
return
|
||||
@@ -161,7 +187,7 @@ Singleton {
|
||||
windowListChanged()
|
||||
})
|
||||
|
||||
// Property bindings
|
||||
// Property bindings - use automatic property change signal
|
||||
backend.focusedWindowIndexChanged.connect(() => {
|
||||
focusedWindowIndex = backend.focusedWindowIndex
|
||||
})
|
||||
|
||||
@@ -0,0 +1,799 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import qs.Commons
|
||||
import qs.Services.UI
|
||||
import qs.Services.Keyboard
|
||||
|
||||
// MangoService integrates with MangoWC compositor using mmsg IPC commands
|
||||
// for real-time window management, workspace control, and state monitoring
|
||||
|
||||
Item {
|
||||
id: root
|
||||
|
||||
// Facade interface properties
|
||||
property ListModel workspaces: ListModel {}
|
||||
property var windows: []
|
||||
property int focusedWindowIndex: -1
|
||||
|
||||
// Facade interface signals
|
||||
signal workspaceChanged
|
||||
signal activeWindowChanged
|
||||
signal windowListChanged
|
||||
signal displayScalesChanged
|
||||
|
||||
// MangoWC-specific state
|
||||
property bool initialized: false
|
||||
property bool overviewActive: false
|
||||
property var workspaceCache: ({}) // Cache for workspace data to detect changes
|
||||
property var windowCache: ({}) // Cache for window data to detect changes
|
||||
property var monitorCache: ({}) // Cache for monitor/scale data
|
||||
property string currentLayout: "" // Current layout name
|
||||
property string currentLayoutSymbol: "" // Current layout symbol (e.g., 'S' for scroller)
|
||||
property string currentKeyboardLayout: "" // Current keyboard layout name
|
||||
property string selectedMonitor: "" // Currently selected/focused monitor
|
||||
|
||||
// mmsg command templates for MangoWC IPC (mmsg is the MangoWC message interface)
|
||||
readonly property var mmsgCommands: ({
|
||||
query: {
|
||||
workspaces: ["mmsg", "-g", "-t"],
|
||||
windows: ["mmsg", "-g", "-c"],
|
||||
layout: ["mmsg", "-g", "-l"],
|
||||
keyboard: ["mmsg", "-g", "-k"],
|
||||
outputs: ["mmsg", "-g", "-A"],
|
||||
monitors: ["mmsg", "-g", "-o"],
|
||||
eventStream: ["mmsg", "-w"]
|
||||
},
|
||||
action: {
|
||||
view: ["mmsg", "-s", "-d", "view"],
|
||||
tag: ["mmsg", "-s", "-t"],
|
||||
focusMaster: ["mmsg", "-s", "-d", "focusmaster"],
|
||||
killClient: ["mmsg", "-s", "-d", "killclient"],
|
||||
toggleOverview: ["mmsg", "-s", "-d", "toggleoverview"],
|
||||
setLayout: ["mmsg", "-s", "-d", "setlayout"],
|
||||
quit: ["mmsg", "-s", "-q"]
|
||||
}
|
||||
})
|
||||
|
||||
readonly property string overviewLayoutSymbol: "" // Symbol representing overview layout
|
||||
readonly property int defaultWorkspaceId: 1 // Default workspace ID when none specified
|
||||
|
||||
// Debounce timer for rapid state changes to avoid excessive updates
|
||||
Timer {
|
||||
id: updateTimer
|
||||
interval: 50
|
||||
repeat: false
|
||||
onTriggered: safeUpdate()
|
||||
}
|
||||
|
||||
|
||||
// Event stream process for real-time MangoWC state monitoring using mmsg -w
|
||||
// Monitors events: workspace changes, window focus/movement, layout changes, monitor selection
|
||||
Process {
|
||||
id: eventStream
|
||||
running: false
|
||||
command: mmsgCommands.query.eventStream
|
||||
|
||||
stdout: SplitParser {
|
||||
onRead: function (line) {
|
||||
try {
|
||||
handleEvent(line.trim())
|
||||
} catch (e) {
|
||||
Logger.e("MangoService", "Event parsing error:", e, line)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onExited: function (exitCode) {
|
||||
if (exitCode !== 0) {
|
||||
Logger.e("MangoService", "Event stream exited, restarting...")
|
||||
restartTimer.start()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Restart timer for event stream recovery on failure
|
||||
Timer {
|
||||
id: restartTimer
|
||||
interval: 1000
|
||||
onTriggered: {
|
||||
if (initialized) {
|
||||
eventStream.running = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Process to query workspaces using mmsg -g -t
|
||||
Process {
|
||||
id: workspacesProcess
|
||||
running: false
|
||||
command: mmsgCommands.query.workspaces
|
||||
property string accumulatedOutput: ""
|
||||
|
||||
stdout: SplitParser {
|
||||
onRead: function (line) {
|
||||
workspacesProcess.accumulatedOutput += line + "\n"
|
||||
}
|
||||
}
|
||||
|
||||
onExited: function (exitCode) {
|
||||
if (exitCode === 0) {
|
||||
parseWorkspaces(accumulatedOutput)
|
||||
} else {
|
||||
Logger.e("MangoService", "Workspaces query failed:", exitCode)
|
||||
}
|
||||
accumulatedOutput = ""
|
||||
}
|
||||
}
|
||||
|
||||
// Process to query windows using mmsg -g -c
|
||||
Process {
|
||||
id: windowsProcess
|
||||
running: false
|
||||
command: mmsgCommands.query.windows
|
||||
property string accumulatedOutput: ""
|
||||
property var currentWindow: ({})
|
||||
|
||||
onRunningChanged: {
|
||||
if (running) {
|
||||
windowsProcess.currentWindow = {}
|
||||
}
|
||||
}
|
||||
|
||||
stdout: SplitParser {
|
||||
onRead: function (line) {
|
||||
const trimmed = line.trim()
|
||||
if (!trimmed) return
|
||||
|
||||
const parts = trimmed.split(' ')
|
||||
if (parts.length >= 3) {
|
||||
const outputName = parts[0]
|
||||
const property = parts[1]
|
||||
const value = parts.slice(2).join(' ')
|
||||
|
||||
if (!windowsProcess.currentWindow[outputName]) {
|
||||
windowsProcess.currentWindow[outputName] = {
|
||||
id: outputName,
|
||||
output: outputName
|
||||
}
|
||||
}
|
||||
|
||||
switch (property) {
|
||||
case "title":
|
||||
windowsProcess.currentWindow[outputName].title = value
|
||||
break
|
||||
case "appid":
|
||||
windowsProcess.currentWindow[outputName].appId = value
|
||||
windowsProcess.currentWindow[outputName].class = value
|
||||
break
|
||||
case "fullscreen":
|
||||
windowsProcess.currentWindow[outputName].fullscreen = (value === "1")
|
||||
break
|
||||
case "floating":
|
||||
windowsProcess.currentWindow[outputName].floating = (value === "1")
|
||||
break
|
||||
case "x":
|
||||
windowsProcess.currentWindow[outputName].x = parseInt(value)
|
||||
break
|
||||
case "y":
|
||||
windowsProcess.currentWindow[outputName].y = parseInt(value)
|
||||
break
|
||||
case "width":
|
||||
windowsProcess.currentWindow[outputName].width = parseInt(value)
|
||||
break
|
||||
case "height":
|
||||
windowsProcess.currentWindow[outputName].height = parseInt(value)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onExited: function (exitCode) {
|
||||
if (exitCode === 0) {
|
||||
parseWindows(windowsProcess.currentWindow)
|
||||
} else {
|
||||
Logger.e("MangoService", "Windows query failed:", exitCode)
|
||||
}
|
||||
accumulatedOutput = ""
|
||||
windowsProcess.currentWindow = {}
|
||||
}
|
||||
}
|
||||
|
||||
// Process to query current layout using mmsg -g -l
|
||||
Process {
|
||||
id: layoutProcess
|
||||
running: false
|
||||
command: mmsgCommands.query.layout
|
||||
|
||||
stdout: SplitParser {
|
||||
onRead: function (line) {
|
||||
try {
|
||||
const parts = line.trim().split(/\s+/)
|
||||
if (parts.length >= 2) {
|
||||
const layoutSymbol = parts.slice(1).join(' ')
|
||||
handleLayoutChange(layoutSymbol)
|
||||
}
|
||||
} catch (e) {
|
||||
Logger.e("MangoService", "Layout parsing error:", e, line)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onExited: function (exitCode) {
|
||||
if (exitCode !== 0) {
|
||||
Logger.e("MangoService", "Layout query failed:", exitCode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Process to query keyboard layout using mmsg -g -k
|
||||
Process {
|
||||
id: keyboardProcess
|
||||
running: false
|
||||
command: mmsgCommands.query.keyboard
|
||||
|
||||
stdout: SplitParser {
|
||||
onRead: function (line) {
|
||||
try {
|
||||
const parts = line.trim().split(/\s+/)
|
||||
if (parts.length >= 2 && parts[1] === "kb_layout") {
|
||||
const layoutName = parts.slice(2).join(' ')
|
||||
if (layoutName && layoutName !== currentKeyboardLayout) {
|
||||
currentKeyboardLayout = layoutName
|
||||
KeyboardLayoutService.setCurrentLayout(layoutName)
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
Logger.e("MangoService", "Keyboard layout parsing error:", e, line)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onExited: function (exitCode) {
|
||||
if (exitCode !== 0) {
|
||||
Logger.e("MangoService", "Keyboard query failed:", exitCode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Process to query output scales using mmsg -g -A
|
||||
Process {
|
||||
id: outputsProcess
|
||||
running: false
|
||||
command: mmsgCommands.query.outputs
|
||||
|
||||
stdout: SplitParser {
|
||||
onRead: function (line) {
|
||||
try {
|
||||
const parts = line.trim().split(/\s+/)
|
||||
if (parts.length >= 3 && parts[1] === "scale_factor") {
|
||||
const outputName = parts[0]
|
||||
const scaleFactor = parseFloat(parts[2])
|
||||
|
||||
if (!monitorCache[outputName]) {
|
||||
monitorCache[outputName] = {}
|
||||
}
|
||||
|
||||
monitorCache[outputName].scale = scaleFactor
|
||||
monitorCache[outputName].name = outputName
|
||||
}
|
||||
} catch (e) {
|
||||
Logger.e("MangoService", "Output parsing error:", e, line)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onExited: function (exitCode) {
|
||||
if (exitCode === 0) {
|
||||
updateDisplayScales()
|
||||
} else {
|
||||
Logger.e("MangoService", "Outputs query failed:", exitCode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Process to query monitor states using mmsg -g -o
|
||||
Process {
|
||||
id: monitorStateProcess
|
||||
running: false
|
||||
command: mmsgCommands.query.monitors
|
||||
|
||||
stdout: SplitParser {
|
||||
onRead: function (line) {
|
||||
try {
|
||||
const parts = line.trim().split(/\s+/)
|
||||
if (parts.length >= 3 && parts[1] === "selmon") {
|
||||
const outputName = parts[0]
|
||||
const isSelected = parts[2] === "1"
|
||||
if (isSelected) {
|
||||
selectedMonitor = outputName
|
||||
Logger.d("MangoService", `Initial selected monitor: ${outputName}`)
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
Logger.e("MangoService", "Monitor state parsing error:", e, line)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onExited: function (exitCode) {
|
||||
if (exitCode !== 0) {
|
||||
Logger.e("MangoService", "Monitor state query failed:", exitCode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Process to enumerate available outputs using mmsg -g -O
|
||||
Process {
|
||||
id: outputEnumProcess
|
||||
running: false
|
||||
command: ["mmsg", "-g", "-O"]
|
||||
|
||||
stdout: SplitParser {
|
||||
onRead: function (line) {
|
||||
try {
|
||||
const trimmed = line.trim()
|
||||
|
||||
const outputName = trimmed.replace(/^\+\s*/, '')
|
||||
if (outputName && !monitorCache[outputName]) {
|
||||
monitorCache[outputName] = {
|
||||
name: outputName,
|
||||
scale: 1.0,
|
||||
active: false,
|
||||
focused: false
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
Logger.e("MangoService", "Output enumeration error:", e, line)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onExited: function (exitCode) {
|
||||
if (exitCode !== 0) {
|
||||
Logger.e("MangoService", "Output enumeration failed:", exitCode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Initialize MangoService and establish connection to MangoWC
|
||||
function initialize() {
|
||||
if (initialized) {
|
||||
Logger.w("MangoService", "Already initialized")
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
Logger.i("MangoService", "Initializing MangoWC service...")
|
||||
|
||||
queryOutputEnum()
|
||||
queryMonitorState()
|
||||
eventStream.running = true
|
||||
queryWorkspaces()
|
||||
queryWindows()
|
||||
queryLayout()
|
||||
queryKeyboard()
|
||||
queryOutputs()
|
||||
|
||||
initialized = true
|
||||
Logger.i("MangoService", "Service initialized successfully")
|
||||
} catch (e) {
|
||||
Logger.e("MangoService", "Initialization failed:", e)
|
||||
eventStream.running = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Switch to a specific workspace/tag
|
||||
function switchToWorkspace(workspace) {
|
||||
try {
|
||||
const tagId = workspace.idx || workspace.id || defaultWorkspaceId
|
||||
const outputName = workspace.output || selectedMonitor || ""
|
||||
let command = [...mmsgCommands.action.tag]
|
||||
|
||||
// Only add -o parameter for multi-monitor setups
|
||||
if (outputName && Object.keys(monitorCache).length > 1) {
|
||||
command.push("-o", outputName)
|
||||
}
|
||||
command.push(tagId.toString())
|
||||
|
||||
Quickshell.execDetached(command)
|
||||
} catch (e) {
|
||||
Logger.e("MangoService", "Failed to switch workspace:", e)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Focus a specific window on its workspace
|
||||
function focusWindow(window) {
|
||||
try {
|
||||
if (window && window.output) {
|
||||
let command = [...mmsgCommands.action.view]
|
||||
const isMultiMonitor = Object.keys(monitorCache).length > 1
|
||||
|
||||
if (isMultiMonitor) {
|
||||
command.push("-o", window.output)
|
||||
}
|
||||
command.push(window.workspaceId.toString())
|
||||
Quickshell.execDetached(command)
|
||||
|
||||
Qt.callLater(() => {
|
||||
let focusCommand = [...mmsgCommands.action.focusMaster]
|
||||
if (isMultiMonitor) {
|
||||
focusCommand.push("-o", window.output)
|
||||
}
|
||||
Quickshell.execDetached(focusCommand)
|
||||
})
|
||||
}
|
||||
} catch (e) {
|
||||
Logger.e("MangoService", "Failed to focus window:", e)
|
||||
}
|
||||
}
|
||||
|
||||
function closeWindow(window) {
|
||||
try {
|
||||
const command = [...mmsgCommands.action.killClient]
|
||||
if (selectedMonitor && Object.keys(monitorCache).length > 1) {
|
||||
command.push("-o", selectedMonitor)
|
||||
}
|
||||
Quickshell.execDetached(command)
|
||||
} catch (e) {
|
||||
Logger.e("MangoService", "Failed to close window:", e)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function toggleOverview() {
|
||||
try {
|
||||
const command = [...mmsgCommands.action.toggleOverview]
|
||||
if (selectedMonitor && Object.keys(monitorCache).length > 1) {
|
||||
command.push("-o", selectedMonitor)
|
||||
}
|
||||
Quickshell.execDetached(command)
|
||||
} catch (e) {
|
||||
Logger.e("MangoService", "Failed to toggle overview:", e)
|
||||
}
|
||||
}
|
||||
|
||||
function setLayout(layoutName) {
|
||||
try {
|
||||
const command = [...mmsgCommands.action.setLayout]
|
||||
command.push(layoutName)
|
||||
Quickshell.execDetached(command)
|
||||
} catch (e) {
|
||||
Logger.e("MangoService", "Failed to set layout:", e)
|
||||
}
|
||||
}
|
||||
|
||||
function logout() {
|
||||
try {
|
||||
Quickshell.execDetached(mmsgCommands.action.quit)
|
||||
} catch (e) {
|
||||
Logger.e("MangoService", "Failed to logout:", e)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Parse workspace data from mmsg -g -t output
|
||||
// Handles formats: tag details, tag masks, and binary states
|
||||
// State bits: bit 0 = active/selected, bit 1 = urgent
|
||||
function parseWorkspaces(output) {
|
||||
const lines = output.trim().split('\n')
|
||||
const workspacesList = []
|
||||
const newWorkspaceCache = {}
|
||||
let outputClients = {}
|
||||
|
||||
for (const line of lines) {
|
||||
const trimmed = line.trim()
|
||||
if (!trimmed) continue
|
||||
|
||||
const tagMatch = trimmed.match(/^(\S+)\s+tag\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)$/)
|
||||
if (tagMatch) {
|
||||
const [, outputName, tagNum, state, clients, focused] = tagMatch
|
||||
const tagId = parseInt(tagNum)
|
||||
|
||||
const isActive = (parseInt(state) & 1) !== 0
|
||||
const isUrgent = (parseInt(state) & 2) !== 0
|
||||
const isOccupied = parseInt(clients) > 0
|
||||
const isFocused = isActive && parseInt(focused) === 1
|
||||
|
||||
if (!outputClients[outputName]) {
|
||||
outputClients[outputName] = 0
|
||||
}
|
||||
|
||||
const workspaceData = {
|
||||
id: tagId,
|
||||
idx: tagId,
|
||||
name: tagId.toString(),
|
||||
output: outputName,
|
||||
isActive: isActive,
|
||||
isFocused: isFocused || (isActive && (outputName === selectedMonitor)),
|
||||
isUrgent: isUrgent,
|
||||
isOccupied: isOccupied,
|
||||
clients: parseInt(clients)
|
||||
}
|
||||
|
||||
newWorkspaceCache[`${outputName}-${tagId}`] = workspaceData
|
||||
workspacesList.push(workspaceData)
|
||||
}
|
||||
|
||||
const clientsMatch = trimmed.match(/^(\S+)\s+clients\s+(\d+)$/)
|
||||
if (clientsMatch) {
|
||||
const [, outputName, clientCount] = clientsMatch
|
||||
outputClients[outputName] = parseInt(clientCount)
|
||||
}
|
||||
|
||||
const tagsMatch = trimmed.match(/^(\S+)\s+tags\s+(\d+)\s+(\d+)\s+(\d+)$/)
|
||||
if (tagsMatch) {
|
||||
const [, outputName, occ, seltags, urg] = tagsMatch
|
||||
|
||||
const occBits = occ.padStart(9, '0')
|
||||
const selBits = seltags.padStart(9, '0')
|
||||
const urgBits = urg.padStart(9, '0')
|
||||
|
||||
for (let i = 0; i < 9; i++) {
|
||||
const tagId = i + 1
|
||||
const isActive = selBits[8-i] === '1'
|
||||
const isUrgent = urgBits[8-i] === '1'
|
||||
const isOccupied = occBits[8-i] === '1'
|
||||
|
||||
const workspaceData = {
|
||||
id: tagId,
|
||||
idx: tagId,
|
||||
name: tagId.toString(),
|
||||
output: outputName,
|
||||
isActive: isActive,
|
||||
isFocused: false, // Will be determined by selected monitor
|
||||
isUrgent: isUrgent,
|
||||
isOccupied: isOccupied,
|
||||
clients: 0 // Will be updated by tag-specific data
|
||||
}
|
||||
|
||||
const key = `${outputName}-${tagId}`
|
||||
if (!newWorkspaceCache[key]) {
|
||||
newWorkspaceCache[key] = workspaceData
|
||||
workspacesList.push(workspaceData)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const layoutMatch = trimmed.match(/^(\S+)\s+layout\s+(\S+)$/)
|
||||
if (layoutMatch) {
|
||||
const [, , layoutSymbol] = layoutMatch
|
||||
handleLayoutChange(layoutSymbol)
|
||||
}
|
||||
}
|
||||
|
||||
if (JSON.stringify(newWorkspaceCache) !== JSON.stringify(workspaceCache)) {
|
||||
workspaceCache = newWorkspaceCache
|
||||
|
||||
workspacesList.sort((a, b) => {
|
||||
if (a.id !== b.id) return a.id - b.id
|
||||
return a.output.localeCompare(b.output)
|
||||
})
|
||||
|
||||
workspaces.clear()
|
||||
for (var i = 0; i < workspacesList.length; i++) {
|
||||
workspaces.append(workspacesList[i])
|
||||
}
|
||||
|
||||
workspaceChanged()
|
||||
}
|
||||
}
|
||||
|
||||
// Parse window data from mmsg -g -c output into window list
|
||||
function parseWindows(windowData) {
|
||||
const windowsList = []
|
||||
const newWindowCache = {}
|
||||
let newFocusedIndex = -1
|
||||
|
||||
for (const [outputName, data] of Object.entries(windowData)) {
|
||||
if (data.title || data.appId) {
|
||||
|
||||
const isFocused = (outputName === selectedMonitor)
|
||||
|
||||
|
||||
let activeTagId = defaultWorkspaceId
|
||||
for (const [key, tagData] of Object.entries(workspaceCache)) {
|
||||
if (tagData.output === outputName && tagData.isActive) {
|
||||
activeTagId = tagData.id
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
const windowInfo = {
|
||||
id: `${outputName}-${data.appId || 'unknown'}`,
|
||||
title: data.title || "",
|
||||
appId: data.appId || "",
|
||||
class: data.appId || "",
|
||||
workspaceId: activeTagId,
|
||||
isFocused: isFocused,
|
||||
output: outputName,
|
||||
fullscreen: data.fullscreen || false,
|
||||
floating: data.floating || false,
|
||||
x: data.x || 0,
|
||||
y: data.y || 0,
|
||||
width: data.width || 0,
|
||||
height: data.height || 0,
|
||||
geometry: {
|
||||
x: data.x || 0,
|
||||
y: data.y || 0,
|
||||
width: data.width || 0,
|
||||
height: data.height || 0
|
||||
}
|
||||
}
|
||||
|
||||
windowsList.push(windowInfo)
|
||||
newWindowCache[windowInfo.id] = windowInfo
|
||||
|
||||
if (isFocused) {
|
||||
newFocusedIndex = windowsList.length - 1
|
||||
Logger.d("MangoService", `Focused window detected: ${data.title} on ${outputName}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (JSON.stringify(newWindowCache) !== JSON.stringify(windowCache)) {
|
||||
windowCache = newWindowCache
|
||||
windows = windowsList
|
||||
|
||||
if (newFocusedIndex !== focusedWindowIndex) {
|
||||
focusedWindowIndex = newFocusedIndex
|
||||
activeWindowChanged()
|
||||
}
|
||||
|
||||
windowListChanged()
|
||||
}
|
||||
}
|
||||
|
||||
// Handle layout change events and update overview state
|
||||
function handleLayoutChange(layoutSymbol) {
|
||||
const wasOverview = overviewActive
|
||||
const isOverview = (layoutSymbol === overviewLayoutSymbol)
|
||||
|
||||
if (wasOverview !== isOverview) {
|
||||
overviewActive = isOverview
|
||||
Logger.d("MangoService", `Overview mode: ${overviewActive}`)
|
||||
}
|
||||
|
||||
if (layoutSymbol !== currentLayoutSymbol) {
|
||||
currentLayoutSymbol = layoutSymbol
|
||||
currentLayout = layoutSymbol
|
||||
}
|
||||
}
|
||||
|
||||
// Update display scales and notify CompositorService
|
||||
function updateDisplayScales() {
|
||||
const scales = {}
|
||||
for (const [outputName, data] of Object.entries(monitorCache)) {
|
||||
scales[outputName] = {
|
||||
name: data.name || outputName,
|
||||
scale: data.scale || 1.0,
|
||||
width: data.width || 0,
|
||||
height: data.height || 0,
|
||||
refresh_rate: data.refresh_rate || 0,
|
||||
x: data.x || 0,
|
||||
y: data.y || 0,
|
||||
active: data.active || false,
|
||||
focused: data.focused || false
|
||||
}
|
||||
}
|
||||
|
||||
if (CompositorService && CompositorService.onDisplayScalesUpdated) {
|
||||
CompositorService.onDisplayScalesUpdated(scales)
|
||||
}
|
||||
displayScalesChanged()
|
||||
}
|
||||
|
||||
|
||||
// Handle real-time events from mmsg -w event stream and trigger updates
|
||||
function handleEvent(eventLine) {
|
||||
const parts = eventLine.trim().split(/\s+/)
|
||||
if (parts.length < 2) return
|
||||
|
||||
const eventType = parts[1]
|
||||
|
||||
switch (eventType) {
|
||||
case "selmon":
|
||||
if (parts.length >= 3) {
|
||||
const monitorName = parts[0]
|
||||
const isSelected = parts[2] === "1"
|
||||
if (isSelected) {
|
||||
selectedMonitor = monitorName
|
||||
Logger.d("MangoService", `Selected monitor changed to: ${monitorName}`)
|
||||
}
|
||||
}
|
||||
updateTimer.restart()
|
||||
break
|
||||
case "tag":
|
||||
case "title":
|
||||
case "appid":
|
||||
case "fullscreen":
|
||||
case "floating":
|
||||
case "layout":
|
||||
case "kb_layout":
|
||||
case "scale_factor":
|
||||
case "toggle":
|
||||
case "last_layer":
|
||||
case "keymode":
|
||||
case "clients":
|
||||
case "tags":
|
||||
updateTimer.restart()
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Start workspace query process
|
||||
function queryWorkspaces() {
|
||||
workspacesProcess.running = true
|
||||
}
|
||||
|
||||
// Start window query process
|
||||
function queryWindows() {
|
||||
windowsProcess.running = true
|
||||
}
|
||||
|
||||
// Start layout query process
|
||||
function queryLayout() {
|
||||
layoutProcess.running = true
|
||||
}
|
||||
|
||||
// Start keyboard layout query process
|
||||
function queryKeyboard() {
|
||||
keyboardProcess.running = true
|
||||
}
|
||||
|
||||
// Start output scales query process
|
||||
function queryOutputs() {
|
||||
outputsProcess.running = true
|
||||
}
|
||||
|
||||
// Query display scales (alias for queryOutputs)
|
||||
function queryDisplayScales() {
|
||||
queryOutputs()
|
||||
}
|
||||
|
||||
// Start output enumeration process
|
||||
function queryOutputEnum() {
|
||||
outputEnumProcess.running = true
|
||||
}
|
||||
|
||||
// Start monitor state query process
|
||||
function queryMonitorState() {
|
||||
monitorStateProcess.running = true
|
||||
}
|
||||
|
||||
|
||||
// Safely update all state by querying workspaces, windows, and monitor state
|
||||
function safeUpdate() {
|
||||
try {
|
||||
queryWorkspaces()
|
||||
queryWindows()
|
||||
queryMonitorState()
|
||||
} catch (e) {
|
||||
Logger.e("MangoService", "Safe update failed:", e)
|
||||
}
|
||||
}
|
||||
|
||||
// Get the ID of the currently active workspace/tag
|
||||
function getCurrentActiveTagId() {
|
||||
for (const [key, tagData] of Object.entries(workspaceCache)) {
|
||||
if (tagData.isActive && tagData.output === selectedMonitor) {
|
||||
return tagData.id
|
||||
}
|
||||
}
|
||||
|
||||
for (const [key, tagData] of Object.entries(workspaceCache)) {
|
||||
if (tagData.isActive) {
|
||||
return tagData.id
|
||||
}
|
||||
}
|
||||
return defaultWorkspaceId
|
||||
}
|
||||
}
|
||||
@@ -53,12 +53,12 @@ Singleton {
|
||||
var vol = source.audio.volume
|
||||
if (vol !== undefined && !isNaN(vol)) {
|
||||
root._inputVolume = vol
|
||||
} else {
|
||||
root._inputVolume = 0
|
||||
}
|
||||
// Don't reset to 0 if volume is undefined/NaN - preserve last known value
|
||||
root._inputMuted = !!source.audio.muted
|
||||
} else {
|
||||
root._inputVolume = 0
|
||||
// Don't reset volume to 0 when source is unavailable - preserve last known value
|
||||
// Only reset muted state
|
||||
root._inputMuted = true
|
||||
}
|
||||
}
|
||||
@@ -102,7 +102,7 @@ Singleton {
|
||||
function onVolumeChanged() {
|
||||
var vol = source?.audio?.volume
|
||||
if (vol === undefined || isNaN(vol)) {
|
||||
root._inputVolume = 0
|
||||
// Don't reset to 0 if volume is undefined/NaN - preserve last known value
|
||||
return
|
||||
}
|
||||
// Only update if the value actually changed to prevent spurious signals
|
||||
|
||||
@@ -14,6 +14,28 @@ Singleton {
|
||||
property bool isNixOS: false
|
||||
property bool isReady: false
|
||||
|
||||
// User info
|
||||
readonly property string username: (Quickshell.env("USER") || "")
|
||||
readonly property string envRealName: (Quickshell.env("NOCTALIA_REALNAME") || "")
|
||||
property string realName: ""
|
||||
|
||||
readonly property string displayName: {
|
||||
// Explicit override
|
||||
if (envRealName && envRealName.length > 0)
|
||||
return envRealName
|
||||
|
||||
// Name from getent
|
||||
if (realName && realName.length > 0)
|
||||
return realName
|
||||
|
||||
// Fallback: capitalized $USER
|
||||
if (username && username.length > 0)
|
||||
return username.charAt(0).toUpperCase() + username.slice(1)
|
||||
|
||||
// Last resort: placeholder
|
||||
return "User"
|
||||
}
|
||||
|
||||
function init() {
|
||||
Logger.i("HostService", "Service started")
|
||||
}
|
||||
@@ -111,4 +133,22 @@ Singleton {
|
||||
stdout: StdioCollector {}
|
||||
stderr: StdioCollector {}
|
||||
}
|
||||
|
||||
// Resolve GECOS real name once on startup
|
||||
Process {
|
||||
id: realNameProcess
|
||||
command: ["sh", "-c", "getent passwd \"$USER\" | cut -d: -f5 | cut -d, -f1"]
|
||||
running: true
|
||||
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
const name = String(text || "").trim()
|
||||
if (name.length > 0) {
|
||||
root.realName = name
|
||||
Logger.i("HostService", "resolved real name", name)
|
||||
}
|
||||
}
|
||||
}
|
||||
stderr: StdioCollector {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,9 @@ Singleton {
|
||||
// Discord client auto-detection
|
||||
property var availableDiscordClients: []
|
||||
|
||||
// Code client auto-detection
|
||||
property var availableCodeClients: []
|
||||
|
||||
// Signal emitted when all checks are complete
|
||||
signal checksCompleted
|
||||
|
||||
@@ -42,12 +45,16 @@ Singleton {
|
||||
for (var i = 0; i < TemplateRegistry.discordClients.length; i++) {
|
||||
var client = TemplateRegistry.discordClients[i]
|
||||
var clientName = client.name
|
||||
var configPath = client.configPath
|
||||
|
||||
// Use the actual config path from the client, removing ~ prefix
|
||||
var checkPath = configPath.startsWith("~") ? configPath.substring(2) : configPath.substring(1)
|
||||
|
||||
// Check if this client requires themes folder to exist
|
||||
if (client.requiresThemesFolder) {
|
||||
scriptParts.push("if [ -d \"$HOME/.config/" + clientName + "/themes\" ]; then available_clients=\"$available_clients " + clientName + "\"; fi;")
|
||||
scriptParts.push("if [ -d \"$HOME/" + checkPath + "/themes\" ]; then available_clients=\"$available_clients " + clientName + "\"; fi;")
|
||||
} else {
|
||||
scriptParts.push("if [ -d \"$HOME/.config/" + clientName + "\" ]; then available_clients=\"$available_clients " + clientName + "\"; fi;")
|
||||
scriptParts.push("if [ -d \"$HOME/" + checkPath + "\" ]; then available_clients=\"$available_clients " + clientName + "\"; fi;")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,6 +104,66 @@ Singleton {
|
||||
stderr: StdioCollector {}
|
||||
}
|
||||
|
||||
// Function to detect Code client by checking config directories
|
||||
function detectCodeClient() {
|
||||
// Build shell script to check each client
|
||||
var scriptParts = ["available_clients=\"\";"]
|
||||
|
||||
for (var i = 0; i < TemplateRegistry.codeClients.length; i++) {
|
||||
var client = TemplateRegistry.codeClients[i]
|
||||
var clientName = client.name
|
||||
var configPath = client.configPath
|
||||
|
||||
// Check if the config directory exists
|
||||
scriptParts.push("if [ -d \"$HOME" + configPath.substring(1) + "\" ]; then available_clients=\"$available_clients " + clientName + "\"; fi;")
|
||||
}
|
||||
|
||||
scriptParts.push("echo \"$available_clients\"")
|
||||
|
||||
// Use a Process to check directory existence for all clients
|
||||
codeDetector.command = ["sh", "-c", scriptParts.join(" ")]
|
||||
codeDetector.running = true
|
||||
}
|
||||
|
||||
// Process to detect Code client directories
|
||||
Process {
|
||||
id: codeDetector
|
||||
running: false
|
||||
|
||||
onExited: function (exitCode) {
|
||||
availableCodeClients = []
|
||||
|
||||
if (exitCode === 0) {
|
||||
var detectedClients = stdout.text.trim().split(/\s+/).filter(function (client) {
|
||||
return client.length > 0
|
||||
})
|
||||
|
||||
if (detectedClients.length > 0) {
|
||||
// Build list of available clients
|
||||
for (var i = 0; i < detectedClients.length; i++) {
|
||||
var clientName = detectedClients[i]
|
||||
for (var j = 0; j < TemplateRegistry.codeClients.length; j++) {
|
||||
var client = TemplateRegistry.codeClients[j]
|
||||
if (client.name === clientName) {
|
||||
availableCodeClients.push(client)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Logger.i("ProgramChecker", "Detected Code clients:", detectedClients.join(", "))
|
||||
}
|
||||
}
|
||||
|
||||
if (availableCodeClients.length === 0) {
|
||||
Logger.d("ProgramChecker", "No Code clients detected")
|
||||
}
|
||||
}
|
||||
|
||||
stdout: StdioCollector {}
|
||||
stderr: StdioCollector {}
|
||||
}
|
||||
|
||||
// Programs to check - maps property names to commands
|
||||
readonly property var programsToCheck: ({
|
||||
"matugenAvailable": ["which", "matugen"],
|
||||
@@ -140,8 +207,9 @@ Singleton {
|
||||
|
||||
// Check next program or emit completion signal
|
||||
if (root.completedChecks >= root.totalChecks) {
|
||||
// Run Discord client detection after all checks are complete
|
||||
// Run Discord and Code client detection after all checks are complete
|
||||
root.detectDiscordClient()
|
||||
root.detectCodeClient()
|
||||
root.checksCompleted()
|
||||
} else {
|
||||
root.checkNextProgram()
|
||||
|
||||
@@ -114,6 +114,18 @@ Singleton {
|
||||
}
|
||||
})
|
||||
}
|
||||
} else if (app.id === "code") {
|
||||
// Handle Code clients specially
|
||||
if (Settings.data.templates.code) {
|
||||
app.clients.forEach(client => {
|
||||
// Check if this specific client is detected
|
||||
if (isCodeClientEnabled(client.name)) {
|
||||
lines.push(`\n[templates.code_${client.name}]`)
|
||||
lines.push(`input_path = "${Quickshell.shellDir}/Assets/MatugenTemplates/${app.input}"`)
|
||||
lines.push(`output_path = "${client.path}"`)
|
||||
}
|
||||
})
|
||||
}
|
||||
} else {
|
||||
// Handle regular apps
|
||||
if (Settings.data.templates[app.id]) {
|
||||
@@ -140,6 +152,16 @@ Singleton {
|
||||
return false
|
||||
}
|
||||
|
||||
function isCodeClientEnabled(clientName) {
|
||||
// Check ProgramCheckerService to see if client is detected
|
||||
for (var i = 0; i < ProgramCheckerService.availableCodeClients.length; i++) {
|
||||
if (ProgramCheckerService.availableCodeClients[i].name === clientName) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
function buildMatugenScript(content, wallpaper, mode) {
|
||||
const delimiter = "MATUGEN_CONFIG_EOF_" + Math.random().toString(36).substr(2, 9)
|
||||
const pathEsc = dynamicConfigPath.replace(/'/g, "'\\''")
|
||||
@@ -163,6 +185,10 @@ Singleton {
|
||||
if (Settings.data.templates.discord) {
|
||||
script += processDiscordClients(app, colors, mode, homeDir)
|
||||
}
|
||||
} else if (app.id === "code") {
|
||||
if (Settings.data.templates.code) {
|
||||
script += processCodeClients(app, colors, mode, homeDir)
|
||||
}
|
||||
} else {
|
||||
if (Settings.data.templates[app.id]) {
|
||||
script += processTemplate(app, colors, mode, homeDir)
|
||||
@@ -198,6 +224,39 @@ Singleton {
|
||||
return script
|
||||
}
|
||||
|
||||
function processCodeClients(codeApp, colors, mode, homeDir) {
|
||||
let script = ""
|
||||
const palette = ColorPaletteGenerator.generatePalette(colors, Settings.data.colorSchemes.darkMode, false)
|
||||
|
||||
codeApp.clients.forEach(client => {
|
||||
if (!isCodeClientEnabled(client.name))
|
||||
return
|
||||
|
||||
const templatePath = `${Quickshell.shellDir}/Assets/MatugenTemplates/${codeApp.input}`
|
||||
const outputPath = client.path.replace("~", homeDir)
|
||||
const outputDir = outputPath.substring(0, outputPath.lastIndexOf('/'))
|
||||
|
||||
// Extract base config directory for checking
|
||||
var baseConfigDir = ""
|
||||
if (client.name === "code") {
|
||||
baseConfigDir = "~/.vscode".replace("~", homeDir)
|
||||
} else if (client.name === "codium") {
|
||||
baseConfigDir = "~/.vscode-oss".replace("~", homeDir)
|
||||
}
|
||||
|
||||
script += `\n`
|
||||
script += `if [ -d "${baseConfigDir}" ]; then\n`
|
||||
script += ` mkdir -p ${outputDir}\n`
|
||||
script += ` cp '${templatePath}' '${outputPath}'\n`
|
||||
script += ` ${replaceColorsInFile(outputPath, palette)}`
|
||||
script += `else\n`
|
||||
script += ` echo "Code client ${client.name} not found at ${baseConfigDir}, skipping"\n`
|
||||
script += `fi\n`
|
||||
})
|
||||
|
||||
return script
|
||||
}
|
||||
|
||||
function processTemplate(app, colors, mode, homeDir) {
|
||||
const palette = ColorPaletteGenerator.generatePalette(colors, Settings.data.colorSchemes.darkMode, app.strict || false)
|
||||
let script = ""
|
||||
|
||||
@@ -139,17 +139,20 @@ Singleton {
|
||||
"requiresThemesFolder": false
|
||||
}, {
|
||||
"name": "vencord",
|
||||
"path": "~/.config/discord",
|
||||
"requiresThemesFolder": true
|
||||
"path": "~/.config/Vencord",
|
||||
"requiresThemesFolder": false
|
||||
}]
|
||||
}, // VSCode with hardcoded path (requirement #5)
|
||||
{
|
||||
}, {
|
||||
"id": "code",
|
||||
"name": "VSCode",
|
||||
"category": "applications",
|
||||
"input": "code.json",
|
||||
"outputs": [{
|
||||
"clients": [{
|
||||
"name": "code",
|
||||
"path": "~/.vscode/extensions/hyprluna.hyprluna-theme-1.0.2/themes/hyprluna.json"
|
||||
}, {
|
||||
"name": "codium",
|
||||
"path": "~/.vscode-oss/extensions/hyprluna.hyprluna-theme-1.0.2/themes/hyprluna.json"
|
||||
}]
|
||||
}, {
|
||||
"id": "spicetify",
|
||||
@@ -179,6 +182,33 @@ Singleton {
|
||||
return clients
|
||||
}
|
||||
|
||||
// Extract Code clients for ProgramCheckerService compatibility
|
||||
readonly property var codeClients: {
|
||||
var clients = []
|
||||
var codeApp = applications.find(app => app.id === "code")
|
||||
if (codeApp && codeApp.clients) {
|
||||
codeApp.clients.forEach(client => {
|
||||
// Extract base config directory from theme path
|
||||
var themePath = client.path
|
||||
var baseConfigDir = ""
|
||||
if (client.name === "code") {
|
||||
// For VSCode: ~/.vscode/extensions/... -> ~/.vscode
|
||||
baseConfigDir = "~/.vscode"
|
||||
} else if (client.name === "codium") {
|
||||
// For VSCodium: ~/.vscode-oss/extensions/... -> ~/.vscode-oss
|
||||
baseConfigDir = "~/.vscode-oss"
|
||||
}
|
||||
clients.push({
|
||||
"name": client.name,
|
||||
"configPath": baseConfigDir,
|
||||
"themePath": themePath,
|
||||
"requiresThemesFolder": false
|
||||
})
|
||||
})
|
||||
}
|
||||
return clients
|
||||
}
|
||||
|
||||
// Build user templates TOML content
|
||||
function buildUserTemplatesToml() {
|
||||
var lines = []
|
||||
|
||||
Reference in New Issue
Block a user