Using a custom logger with colors and timestamp instead of console.xxx

This commit is contained in:
quadbyte 2025-08-16 19:31:22 -04:00
parent 4794477be3
commit e800bc161d
34 changed files with 278 additions and 236 deletions

View file

@ -95,11 +95,11 @@ Singleton {
path: Settings.configDir + "colors.json" path: Settings.configDir + "colors.json"
watchChanges: true watchChanges: true
onFileChanged: { onFileChanged: {
console.log("[Colors] Reloading colors from disk") Logger.log("Colors", "Reloading colors from disk")
reload() reload()
} }
onAdapterUpdated: { onAdapterUpdated: {
console.log("[Colors] Writing colors to disk") Logger.log("Colors", "Writing colors to disk")
writeAdapter() writeAdapter()
} }
onLoadFailed: function (error) { onLoadFailed: function (error) {

33
Commons/Logger.qml Normal file
View file

@ -0,0 +1,33 @@
pragma Singleton
import Quickshell
import qs.Commons
Singleton {
id: root
function _formatMessage(...args) {
var t = Time.getFormattedTimestamp()
if (args.length > 1) {
var module = args.shift()
return `\x1b[36m${t}\x1b[0m \x1b[35m[${module}]\x1b[0m ` + args.join(" ")
} else {
return `\x1b[36m${t}\x1b[0m ` + args.join(" ")
}
}
function log(...args) {
var msg = _formatMessage(...args)
console.log(msg)
}
function warn(...args) {
var msg = _formatMessage(...args)
console.warn(msg)
}
function error(...args) {
var msg = _formatMessage(...args)
console.error(msg)
}
}

View file

@ -49,11 +49,11 @@ Singleton {
reload() reload()
} }
onLoaded: function () { onLoaded: function () {
console.log("[Settings] Loaded") Logger.log("Settings", "Loaded")
Qt.callLater(function () { Qt.callLater(function () {
// Only set wallpaper on initial load, not on reloads // Only set wallpaper on initial load, not on reloads
if (isInitialLoad && adapter.wallpaper.current !== "") { if (isInitialLoad && adapter.wallpaper.current !== "") {
console.log("[Settings] Set current wallpaper", adapter.wallpaper.current) Logger.log("Settings", "Set current wallpaper", adapter.wallpaper.current)
WallpapersService.setCurrentWallpaper(adapter.wallpaper.current, true) WallpapersService.setCurrentWallpaper(adapter.wallpaper.current, true)
} }
isInitialLoad = false isInitialLoad = false

View file

@ -12,7 +12,7 @@ Singleton {
property string time: { property string time: {
let timeFormat = Settings.data.location.use12HourClock ? "h:mm AP" : "HH:mm" let timeFormat = Settings.data.location.use12HourClock ? "h:mm AP" : "HH:mm"
let timeString = Qt.formatDateTime(date, timeFormat) let timeString = Qt.formatDateTime(date, timeFormat)
if (Settings.data.location.showDateWithClock) { if (Settings.data.location.showDateWithClock) {
let dayName = date.toLocaleDateString(Qt.locale(), "ddd") let dayName = date.toLocaleDateString(Qt.locale(), "ddd")
dayName = dayName.charAt(0).toUpperCase() + dayName.slice(1) dayName = dayName.charAt(0).toUpperCase() + dayName.slice(1)
@ -20,7 +20,7 @@ Singleton {
let month = date.toLocaleDateString(Qt.locale(), "MMM") let month = date.toLocaleDateString(Qt.locale(), "MMM")
return timeString + " - " + dayName + ", " + day + " " + month return timeString + " - " + dayName + ", " + day + " " + month
} }
return timeString return timeString
} }
readonly property string dateString: { readonly property string dateString: {

View file

@ -72,9 +72,9 @@ NLoader {
property string searchText: "" property string searchText: ""
property int selectedIndex: 0 property int selectedIndex: 0
property var filteredEntries: { property var filteredEntries: {
console.log("[AppLauncher] Total desktop entries:", desktopEntries ? desktopEntries.length : 0) Logger.log("AppLauncher", "Total desktop entries:", desktopEntries ? desktopEntries.length : 0)
if (!desktopEntries || desktopEntries.length === 0) { if (!desktopEntries || desktopEntries.length === 0) {
console.log("[AppLauncher] No desktop entries available") Logger.log("AppLauncher", "No desktop entries available")
return [] return []
} }
@ -86,7 +86,7 @@ NLoader {
return true return true
}) })
console.log("[AppLauncher] Visible entries:", visibleEntries.length) Logger.log("AppLauncher", "Visible entries:", visibleEntries.length)
var query = searchText ? searchText.toLowerCase() : "" var query = searchText ? searchText.toLowerCase() : ""
var results = [] var results = []
@ -225,16 +225,16 @@ NLoader {
})) }))
} }
console.log("[AppLauncher] Filtered entries:", results.length) Logger.log("AppLauncher", "Filtered entries:", results.length)
return results return results
} }
Component.onCompleted: { Component.onCompleted: {
console.log("[AppLauncher] Component completed") Logger.log("AppLauncher", "Component completed")
console.log("[AppLauncher] DesktopEntries available:", typeof DesktopEntries !== 'undefined') Logger.log("AppLauncher", "DesktopEntries available:", typeof DesktopEntries !== 'undefined')
if (typeof DesktopEntries !== 'undefined') { if (typeof DesktopEntries !== 'undefined') {
console.log("[AppLauncher] DesktopEntries.entries:", Logger.log("AppLauncher", "DesktopEntries.entries:",
DesktopEntries.entries ? DesktopEntries.entries.length : 'undefined') DesktopEntries.entries ? DesktopEntries.entries.length : 'undefined')
} }
// Start clipboard refresh immediately on open // Start clipboard refresh immediately on open
updateClipboardHistory() updateClipboardHistory()

View file

@ -11,9 +11,9 @@ NLoader {
Component.onCompleted: { Component.onCompleted: {
if (WorkspacesService.isNiri) { if (WorkspacesService.isNiri) {
console.log("[Overview] Loading Overview component (Niri detected)") Logger.log("Overview", "Loading Overview component (Niri detected)")
} else { } else {
console.log("[Overview] Skipping Overview component (Niri not detected)") Logger.log("Overview", "Skipping Overview component (Niri not detected)")
} }
} }

View file

@ -14,12 +14,12 @@ NIconButton {
sizeMultiplier: 0.8 sizeMultiplier: 0.8
showBorder: false showBorder: false
visible: bluetoothEnabled visible: bluetoothEnabled
Component.onCompleted: { Component.onCompleted: {
console.log("[Bluetooth] Component loaded, bluetoothEnabled:", bluetoothEnabled) Logger.log("Bluetooth", "Component loaded, bluetoothEnabled:", bluetoothEnabled)
console.log("[Bluetooth] BluetoothService available:", typeof BluetoothService !== 'undefined') Logger.log("Bluetooth", "BluetoothService available:", typeof BluetoothService !== 'undefined')
if (typeof BluetoothService !== 'undefined') { if (typeof BluetoothService !== 'undefined') {
console.log("[Bluetooth] Connected devices:", BluetoothService.connectedDevices.length) Logger.log("Bluetooth", "Connected devices:", BluetoothService.connectedDevices.length)
} }
} }
icon: { icon: {
@ -55,4 +55,4 @@ NIconButton {
BluetoothMenu { BluetoothMenu {
id: bluetoothMenuLoader id: bluetoothMenuLoader
} }
} }

View file

@ -214,34 +214,34 @@ NLoader {
// Combine all devices into a single list for the ListView // Combine all devices into a single list for the ListView
property var allDevices: { property var allDevices: {
const devices = [] const devices = []
// Add connected devices first // Add connected devices first
for (const device of BluetoothService.connectedDevices) { for (const device of BluetoothService.connectedDevices) {
devices.push({ devices.push({
device: device, "device": device,
type: 'connected', "type": 'connected',
section: 'Connected Devices' "section": 'Connected Devices'
}) })
} }
// Add paired devices // Add paired devices
for (const device of BluetoothService.pairedDevices) { for (const device of BluetoothService.pairedDevices) {
devices.push({ devices.push({
device: device, "device": device,
type: 'paired', "type": 'paired',
section: 'Paired Devices' "section": 'Paired Devices'
}) })
} }
// Add available devices // Add available devices
for (const device of BluetoothService.availableDevices) { for (const device of BluetoothService.availableDevices) {
devices.push({ devices.push({
device: device, "device": device,
type: 'available', "type": 'available',
section: 'Available Devices' "section": 'Available Devices'
}) })
} }
return devices return devices
} }
@ -362,9 +362,8 @@ NLoader {
// Empty state when no devices found // Empty state when no devices found
ColumnLayout { ColumnLayout {
anchors.centerIn: parent anchors.centerIn: parent
visible: Settings.data.network.bluetoothEnabled && visible: Settings.data.network.bluetoothEnabled && !BluetoothService.isDiscovering
!BluetoothService.isDiscovering && && deviceList.count === 0
deviceList.count === 0
spacing: Style.marginMedium * scaling spacing: Style.marginMedium * scaling
NText { NText {
@ -394,4 +393,4 @@ NLoader {
} }
} }
} }
} }

View file

@ -100,7 +100,7 @@ Item {
trayPanel.show() trayPanel.show()
} else { } else {
console.log("[Tray] no menu available for", modelData.id, "or trayMenu not set") Logger.log("Tray", "No menu available for", modelData.id, "or trayMenu not set")
} }
} }
} }

View file

@ -44,7 +44,7 @@ PopupWindow {
function showAt(item, x, y) { function showAt(item, x, y) {
if (!item) { if (!item) {
console.warn("CustomTrayMenu: anchorItem is undefined, won't show menu.") Logger.warn("TrayMenu", "anchorItem is undefined, won't show menu.")
return return
} }
anchorItem = item anchorItem = item
@ -267,7 +267,7 @@ PopupWindow {
function showAt(item, x, y) { function showAt(item, x, y) {
if (!item) { if (!item) {
console.warn("subMenuComponent: anchorItem is undefined, not showing menu.") Logger.warn("TrayMenu", "SubComponent anchorItem is undefined, not showing menu.")
return return
} }
anchorItem = item anchorItem = item

View file

@ -26,7 +26,7 @@ Item {
Connections { Connections {
target: AudioService.sink?.audio ? AudioService.sink?.audio : null target: AudioService.sink?.audio ? AudioService.sink?.audio : null
function onVolumeChanged() { function onVolumeChanged() {
// console.log("[Bar:Volume] onVolumeChanged") // Logger.log("Bar:Volume", "onVolumeChanged")
if (!firstVolumeReceived) { if (!firstVolumeReceived) {
// Ignore the first volume change // Ignore the first volume change
firstVolumeReceived = true firstVolumeReceived = true

View file

@ -145,8 +145,6 @@ NLoader {
Layout.fillWidth: true Layout.fillWidth: true
} }
NIconButton { NIconButton {
icon: "refresh" icon: "refresh"
tooltipText: "Refresh Networks" tooltipText: "Refresh Networks"

View file

@ -202,7 +202,7 @@ NLoader {
label: "Label" label: "Label"
description: "Description" description: "Description"
onToggled: checked => { onToggled: checked => {
console.log("[DemoPanel] NToggle:", checked) Logger.log("DemoPanel", "NToggle:", checked)
} }
} }
@ -255,7 +255,7 @@ NLoader {
} }
currentKey: "dog" currentKey: "dog"
onSelected: function (key) { onSelected: function (key) {
console.log("[DemoPanel] NComboBox: selected ", key) Logger.log("DemoPanel", "NComboBox: selected ", key)
} }
} }

View file

@ -197,7 +197,7 @@ NLoader {
color: appButton.hovered ? Colors.mSurfaceVariant : "transparent" color: appButton.hovered ? Colors.mSurfaceVariant : "transparent"
radius: parent.radius radius: parent.radius
opacity: appButton.hovered ? 0.8 : 0 opacity: appButton.hovered ? 0.8 : 0
Behavior on opacity { Behavior on opacity {
NumberAnimation { NumberAnimation {
duration: Style.animationFast duration: Style.animationFast
@ -218,9 +218,9 @@ NLoader {
mipmap: false mipmap: false
antialiasing: false antialiasing: false
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit
scale: appButton.hovered ? 1.1 : 1.0 scale: appButton.hovered ? 1.1 : 1.0
Behavior on scale { Behavior on scale {
NumberAnimation { NumberAnimation {
duration: Style.animationFast duration: Style.animationFast
@ -237,9 +237,9 @@ NLoader {
font.family: "Material Symbols Rounded" font.family: "Material Symbols Rounded"
font.pointSize: iconSize * 0.7 * scaling font.pointSize: iconSize * 0.7 * scaling
color: appButton.isActive ? Colors.mPrimary : Colors.mOnSurfaceVariant color: appButton.isActive ? Colors.mPrimary : Colors.mOnSurfaceVariant
scale: appButton.hovered ? 1.1 : 1.0 scale: appButton.hovered ? 1.1 : 1.0
Behavior on scale { Behavior on scale {
NumberAnimation { NumberAnimation {
duration: Style.animationFast duration: Style.animationFast

View file

@ -24,39 +24,39 @@ WlSessionLock {
locked: false locked: false
function unlockAttempt() { function unlockAttempt() {
console.log("Unlock attempt started") Logger.log("LockScreen", "Unlock attempt started")
// Real PAM authentication // Real PAM authentication
if (!pamAvailable) { if (!pamAvailable) {
lock.errorMessage = "PAM authentication not available." lock.errorMessage = "PAM authentication not available."
console.log("PAM not available") Logger.log("LockScreen", "PAM not available")
return return
} }
if (!lock.password) { if (!lock.password) {
lock.errorMessage = "Password required." lock.errorMessage = "Password required."
console.log("No password entered") Logger.log("LockScreen", "No password entered")
return return
} }
console.log("Starting PAM authentication...") Logger.log("LockScreen", "Starting PAM authentication")
lock.authenticating = true lock.authenticating = true
lock.errorMessage = "" lock.errorMessage = ""
console.log("[LockScreen] About to create PAM context with userName:", Quickshell.env("USER")) Logger.log("LockScreen", "About to create PAM context with userName:", Quickshell.env("USER"))
var pam = Qt.createQmlObject( var pam = Qt.createQmlObject(
'import Quickshell.Services.Pam; PamContext { config: "login"; user: "' + Quickshell.env("USER") + '" }', 'import Quickshell.Services.Pam; PamContext { config: "login"; user: "' + Quickshell.env("USER") + '" }',
lock) lock)
console.log("PamContext created", pam) Logger.log("LockScreen", "PamContext created", pam)
pam.onCompleted.connect(function (result) { pam.onCompleted.connect(function (result) {
console.log("PAM completed with result:", result) Logger.log("LockScreen", "PAM completed with result:", result)
lock.authenticating = false lock.authenticating = false
if (result === PamResult.Success) { if (result === PamResult.Success) {
console.log("Authentication successful, unlocking...") Logger.log("LockScreen", "Authentication successful, unlocking")
lock.locked = false lock.locked = false
lock.password = "" lock.password = ""
lock.errorMessage = "" lock.errorMessage = ""
} else { } else {
console.log("Authentication failed") Logger.log("LockScreen", "Authentication failed")
lock.errorMessage = "Authentication failed." lock.errorMessage = "Authentication failed."
lock.password = "" lock.password = ""
} }
@ -64,7 +64,7 @@ WlSessionLock {
}) })
pam.onError.connect(function (error) { pam.onError.connect(function (error) {
console.log("PAM error:", error) Logger.log("LockScreen", "PAM error:", error)
lock.authenticating = false lock.authenticating = false
lock.errorMessage = pam.message || "Authentication error." lock.errorMessage = pam.message || "Authentication error."
lock.password = "" lock.password = ""
@ -72,22 +72,22 @@ WlSessionLock {
}) })
pam.onPamMessage.connect(function () { pam.onPamMessage.connect(function () {
console.log("PAM message:", pam.message, "isError:", pam.messageIsError) Logger.log("LockScreen", "PAM message:", pam.message, "isError:", pam.messageIsError)
if (pam.messageIsError) { if (pam.messageIsError) {
lock.errorMessage = pam.message lock.errorMessage = pam.message
} }
}) })
pam.onResponseRequiredChanged.connect(function () { pam.onResponseRequiredChanged.connect(function () {
console.log("PAM response required:", pam.responseRequired) Logger.log("LockScreen", "PAM response required:", pam.responseRequired)
if (pam.responseRequired && lock.authenticating) { if (pam.responseRequired && lock.authenticating) {
console.log("Responding to PAM with password") Logger.log("LockScreen", "Responding to PAM with password")
pam.respond(lock.password) pam.respond(lock.password)
} }
}) })
var started = pam.start() var started = pam.start()
console.log("PAM start result:", started) Logger.log("LockScreen", "PAM start result:", started)
} }
WlSessionLockSurface { WlSessionLockSurface {

View file

@ -248,7 +248,7 @@ NLoader {
sizeMultiplier: 0.7 sizeMultiplier: 0.7
onClicked: { onClicked: {
console.log("[NotificationHistory] Removing notification:", summary) Logger.log("NotificationHistory", "Removing notification:", summary)
NotificationService.historyModel.remove(index) NotificationService.historyModel.remove(index)
NotificationService.saveHistory() NotificationService.saveHistory()
} }

View file

@ -58,8 +58,8 @@ Item {
description: "Display the brightness control icon in the top bar" description: "Display the brightness control icon in the top bar"
checked: !Settings.data.bar.hideBrightness checked: !Settings.data.bar.hideBrightness
onToggled: checked => { onToggled: checked => {
Settings.data.bar.hideBrightness = !checked Settings.data.bar.hideBrightness = !checked
} }
} }
} }
@ -168,7 +168,9 @@ Item {
color: Colors.mSecondary color: Colors.mSecondary
} }
Item { Layout.fillWidth: true } Item {
Layout.fillWidth: true
}
NText { NText {
text: BrightnessService.currentMethod === "ddcutil" ? "External (DDC)" : "Internal" text: BrightnessService.currentMethod === "ddcutil" ? "External (DDC)" : "Internal"
@ -228,7 +230,9 @@ Item {
Layout.alignment: Qt.AlignLeft Layout.alignment: Qt.AlignLeft
} }
Item { Layout.fillWidth: true } Item {
Layout.fillWidth: true
}
NText { NText {
text: BrightnessService.available ? "Available" : "Unavailable" text: BrightnessService.available ? "Available" : "Unavailable"
@ -247,4 +251,4 @@ Item {
} }
} }
} }
} }

View file

@ -92,7 +92,7 @@ ColumnLayout {
var jsonData = JSON.parse(text()) var jsonData = JSON.parse(text())
root.schemeLoaded(schemeName, jsonData) root.schemeLoaded(schemeName, jsonData)
} catch (e) { } catch (e) {
console.warn("Failed to parse JSON for scheme:", schemeName, e) Logger.warn("Failed to parse JSON for scheme:", schemeName, e)
root.schemeLoaded(schemeName, null) // Load defaults on parse error root.schemeLoaded(schemeName, null) // Load defaults on parse error
} }
} }

View file

@ -18,7 +18,7 @@ NBox {
// Height can be overridden by parent layout (SidePanel binds it to stats card) // Height can be overridden by parent layout (SidePanel binds it to stats card)
//implicitHeight: content.implicitHeight + Style.marginLarge * 2 * scaling //implicitHeight: content.implicitHeight + Style.marginLarge * 2 * scaling
// Component.onCompleted: { // Component.onCompleted: {
// console.log(MediaService.trackArtUrl) // Logger.logMediaService.trackArtUrl)
// } // }
ColumnLayout { ColumnLayout {
anchors.fill: parent anchors.fill: parent

View file

@ -103,7 +103,7 @@ NPanel {
hoverEnabled: true hoverEnabled: true
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
onClicked: { onClicked: {
console.log("Lock screen requested") Logger.log("PowerMenu", "Lock screen requested")
// Lock the screen // Lock the screen
lockScreen.locked = true lockScreen.locked = true
powerMenu.visible = false powerMenu.visible = false
@ -353,7 +353,7 @@ NPanel {
} else if (WorkspacesService.isHyprland) { } else if (WorkspacesService.isHyprland) {
logoutProcessHyprland.running = true logoutProcessHyprland.running = true
} else { } else {
console.warn("No supported compositor detected for logout") Logger.warn("PowerMenu", "No supported compositor detected for logout")
} }
} }

View file

@ -53,7 +53,7 @@ Singleton {
function onMutedChanged() { function onMutedChanged() {
root._muted = (sink?.audio.muted ?? true) root._muted = (sink?.audio.muted ?? true)
console.log("[AudioService] onMuteChanged:", root._muted) Logger.log("AudioService", "OnMuteChanged:", root._muted)
} }
} }
@ -70,9 +70,9 @@ Singleton {
// Clamp it accordingly // Clamp it accordingly
sink.audio.muted = false sink.audio.muted = false
sink.audio.volume = Math.max(0, Math.min(1, newVolume)) sink.audio.volume = Math.max(0, Math.min(1, newVolume))
//console.log("[AudioService] setVolume", sink.audio.volume); //Logger.log("AudioService", "SetVolume", sink.audio.volume);
} else { } else {
console.warn("[AudioService] No sink available") Logger.warn("AudioService", "No sink available")
} }
} }
@ -80,7 +80,7 @@ Singleton {
if (sink?.ready && sink?.audio) { if (sink?.ready && sink?.audio) {
sink.audio.muted = muted sink.audio.muted = muted
} else { } else {
console.warn("[AudioService] No sink available") Logger.warn("AudioService", "No sink available")
} }
} }

View file

@ -28,21 +28,21 @@ Singleton {
} }
Component.onCompleted: { Component.onCompleted: {
console.log("[Bluetooth] Service started") Logger.log("Bluetooth", "Service started")
if (isEnabled && Bluetooth.defaultAdapter) { if (isEnabled && Bluetooth.defaultAdapter) {
// Ensure adapter is enabled // Ensure adapter is enabled
if (!Bluetooth.defaultAdapter.enabled) { if (!Bluetooth.defaultAdapter.enabled) {
Bluetooth.defaultAdapter.enabled = true Bluetooth.defaultAdapter.enabled = true
} }
// Start discovery to find devices // Start discovery to find devices
if (!Bluetooth.defaultAdapter.discovering) { if (!Bluetooth.defaultAdapter.discovering) {
Bluetooth.defaultAdapter.discovering = true Bluetooth.defaultAdapter.discovering = true
} }
// Refresh devices after a short delay to allow discovery to start // Refresh devices after a short delay to allow discovery to start
Qt.callLater(function() { Qt.callLater(function () {
refreshDevices() refreshDevices()
}) })
} }
@ -50,7 +50,7 @@ Singleton {
// Function to enable/disable Bluetooth // Function to enable/disable Bluetooth
function setBluetoothEnabled(enabled) { function setBluetoothEnabled(enabled) {
if (enabled) { if (enabled) {
// Store the currently connected devices before enabling // Store the currently connected devices before enabling
for (const device of connectedDevices) { for (const device of connectedDevices) {
@ -59,20 +59,20 @@ Singleton {
break break
} }
} }
// Enable Bluetooth // Enable Bluetooth
if (Bluetooth.defaultAdapter) { if (Bluetooth.defaultAdapter) {
Bluetooth.defaultAdapter.enabled = true Bluetooth.defaultAdapter.enabled = true
// Start discovery to find devices // Start discovery to find devices
if (!Bluetooth.defaultAdapter.discovering) { if (!Bluetooth.defaultAdapter.discovering) {
Bluetooth.defaultAdapter.discovering = true Bluetooth.defaultAdapter.discovering = true
} }
// Refresh devices after enabling // Refresh devices after enabling
Qt.callLater(refreshDevices) Qt.callLater(refreshDevices)
} else { } else {
console.warn("[Bluetooth] No Bluetooth adapter found!") Logger.warn("Bluetooth", "No adapter found")
} }
} else { } else {
// Disconnect from current devices before disabling // Disconnect from current devices before disabling
@ -81,14 +81,14 @@ Singleton {
device.disconnect() device.disconnect()
} }
} }
// Disable Bluetooth // Disable Bluetooth
if (Bluetooth.defaultAdapter) { if (Bluetooth.defaultAdapter) {
console.log("[Bluetooth] Disabling Bluetooth adapter") Logger.log("Bluetooth", "Disabling adapter")
Bluetooth.defaultAdapter.enabled = false Bluetooth.defaultAdapter.enabled = false
} }
} }
Settings.data.network.bluetoothEnabled = enabled Settings.data.network.bluetoothEnabled = enabled
isEnabled = enabled isEnabled = enabled
} }
@ -101,25 +101,24 @@ Singleton {
availableDevices = [] availableDevices = []
return return
} }
// Remove duplicate check since we already did it above
// Remove duplicate check since we already did it above
const connected = [] const connected = []
const paired = [] const paired = []
const available = [] const available = []
let devices = null let devices = null
// Try adapter devices first // Try adapter devices first
if (Bluetooth.defaultAdapter.enabled && Bluetooth.defaultAdapter.devices) { if (Bluetooth.defaultAdapter.enabled && Bluetooth.defaultAdapter.devices) {
devices = Bluetooth.defaultAdapter.devices devices = Bluetooth.defaultAdapter.devices
} }
// Fallback to global devices list // Fallback to global devices list
if (!devices && Bluetooth.devices) { if (!devices && Bluetooth.devices) {
devices = Bluetooth.devices devices = Bluetooth.devices
} }
if (!devices) { if (!devices) {
connectedDevices = [] connectedDevices = []
pairedDevices = [] pairedDevices = []
@ -129,19 +128,20 @@ Singleton {
// Use Qt model methods to iterate through the ObjectModel // Use Qt model methods to iterate through the ObjectModel
let deviceFound = false let deviceFound = false
try { try {
// Get the row count using the Qt model method // Get the row count using the Qt model method
const rowCount = devices.rowCount() const rowCount = devices.rowCount()
if (rowCount > 0) { if (rowCount > 0) {
// Iterate through each row using the Qt model data() method // Iterate through each row using the Qt model data() method
for (let i = 0; i < rowCount; i++) { for (var i = 0; i < rowCount; i++) {
try { try {
// Create a model index for this row // Create a model index for this row
const modelIndex = devices.index(i, 0) const modelIndex = devices.index(i, 0)
if (!modelIndex.valid) continue if (!modelIndex.valid)
continue
// Get the device object using the Qt.UserRole (typically 256) // Get the device object using the Qt.UserRole (typically 256)
const device = devices.data(modelIndex, 256) // Qt.UserRole const device = devices.data(modelIndex, 256) // Qt.UserRole
if (!device) { if (!device) {
@ -153,9 +153,9 @@ Singleton {
continue continue
} }
} }
deviceFound = true deviceFound = true
if (device.connected) { if (device.connected) {
connected.push(device) connected.push(device)
} else if (device.paired) { } else if (device.paired) {
@ -163,13 +163,13 @@ Singleton {
} else { } else {
available.push(device) available.push(device)
} }
} catch (e) { } catch (e) {
// Silent error handling // Silent error handling
} }
} }
} }
// Alternative method: try the values property if available // Alternative method: try the values property if available
if (!deviceFound && devices.values) { if (!deviceFound && devices.values) {
try { try {
@ -177,7 +177,7 @@ Singleton {
if (values && typeof values === 'object') { if (values && typeof values === 'object') {
// Try to iterate through values if it's iterable // Try to iterate through values if it's iterable
if (values.length !== undefined) { if (values.length !== undefined) {
for (let i = 0; i < values.length; i++) { for (var i = 0; i < values.length; i++) {
const device = values[i] const device = values[i]
if (device) { if (device) {
deviceFound = true deviceFound = true
@ -193,18 +193,18 @@ Singleton {
} }
} }
} catch (e) { } catch (e) {
// Silent error handling // Silent error handling
} }
} }
} catch (e) { } catch (e) {
console.warn("[Bluetooth] Error accessing device model:", e) Logger.warn("Bluetooth", "Error accessing device model:", e)
} }
if (!deviceFound) { if (!deviceFound) {
console.log("[Bluetooth] No devices found") Logger.log("Bluetooth", "No device found")
} }
connectedDevices = connected connectedDevices = connected
pairedDevices = paired pairedDevices = paired
availableDevices = available availableDevices = available
@ -212,39 +212,42 @@ Singleton {
// Function to start discovery // Function to start discovery
function startDiscovery() { function startDiscovery() {
if (!isEnabled || !Bluetooth.defaultAdapter) return if (!isEnabled || !Bluetooth.defaultAdapter)
return
isDiscovering = true isDiscovering = true
Bluetooth.defaultAdapter.discovering = true Bluetooth.defaultAdapter.discovering = true
} }
// Function to stop discovery // Function to stop discovery
function stopDiscovery() { function stopDiscovery() {
if (!Bluetooth.defaultAdapter) return if (!Bluetooth.defaultAdapter)
return
isDiscovering = false isDiscovering = false
Bluetooth.defaultAdapter.discovering = false Bluetooth.defaultAdapter.discovering = false
} }
// Function to connect to a device // Function to connect to a device
function connectDevice(device) { function connectDevice(device) {
if (!device) return if (!device)
return
// Check if device is still valid (not stale from previous session) // Check if device is still valid (not stale from previous session)
if (!device.connect || typeof device.connect !== 'function') { if (!device.connect || typeof device.connect !== 'function') {
console.warn("[Bluetooth] Device object is stale, refreshing devices") Logger.warn("Bluetooth", "Device object is stale, refreshing devices")
refreshDevices() refreshDevices()
return return
} }
connectStatus = "connecting" connectStatus = "connecting"
connectStatusDevice = device.name || device.deviceName connectStatusDevice = device.name || device.deviceName
connectError = "" connectError = ""
try { try {
device.connect() device.connect()
} catch (error) { } catch (error) {
console.error("[Bluetooth] Error connecting to device:", error) Logger.error("Bluetooth", "Error connecting to device:", error)
connectStatus = "error" connectStatus = "error"
connectError = error.toString() connectError = error.toString()
Qt.callLater(refreshDevices) Qt.callLater(refreshDevices)
@ -253,15 +256,16 @@ Singleton {
// Function to disconnect from a device // Function to disconnect from a device
function disconnectDevice(device) { function disconnectDevice(device) {
if (!device) return if (!device)
return
// Check if device is still valid (not stale from previous session) // Check if device is still valid (not stale from previous session)
if (!device.disconnect || typeof device.disconnect !== 'function') { if (!device.disconnect || typeof device.disconnect !== 'function') {
console.warn("[Bluetooth] Device object is stale, refreshing devices") Logger.warn("Bluetooth", "Device object is stale, refreshing devices")
refreshDevices() refreshDevices()
return return
} }
try { try {
device.disconnect() device.disconnect()
// Clear connection status // Clear connection status
@ -269,72 +273,74 @@ Singleton {
connectStatusDevice = "" connectStatusDevice = ""
connectError = "" connectError = ""
} catch (error) { } catch (error) {
console.warn("[Bluetooth] Error disconnecting device:", error) Logger.warn("Bluetooth", "Error disconnecting device:", error)
Qt.callLater(refreshDevices) Qt.callLater(refreshDevices)
} }
} }
// Function to pair with a device // Function to pair with a device
function pairDevice(device) { function pairDevice(device) {
if (!device) return if (!device)
return
// Check if device is still valid (not stale from previous session) // Check if device is still valid (not stale from previous session)
if (!device.pair || typeof device.pair !== 'function') { if (!device.pair || typeof device.pair !== 'function') {
console.warn("[Bluetooth] Device object is stale, refreshing devices") Logger.warn("Bluetooth", "Device object is stale, refreshing devices")
refreshDevices() refreshDevices()
return return
} }
try { try {
device.pair() device.pair()
} catch (error) { } catch (error) {
console.warn("[Bluetooth] Error pairing device:", error) Logger.warn("Bluetooth", "Error pairing device:", error)
Qt.callLater(refreshDevices) Qt.callLater(refreshDevices)
} }
} }
// Function to forget a device // Function to forget a device
function forgetDevice(device) { function forgetDevice(device) {
if (!device) return if (!device)
return
// Check if device is still valid (not stale from previous session) // Check if device is still valid (not stale from previous session)
if (!device.forget || typeof device.forget !== 'function') { if (!device.forget || typeof device.forget !== 'function') {
console.warn("[Bluetooth] Device object is stale, refreshing devices") Logger.warn("Bluetooth", "Device object is stale, refreshing devices")
refreshDevices() refreshDevices()
return return
} }
// Store device info before forgetting (in case device object becomes invalid) // Store device info before forgetting (in case device object becomes invalid)
const deviceName = device.name || device.deviceName || "Unknown Device" const deviceName = device.name || device.deviceName || "Unknown Device"
try { try {
device.forget() device.forget()
// Clear any connection status that might be related to this device // Clear any connection status that might be related to this device
if (connectStatusDevice === deviceName) { if (connectStatusDevice === deviceName) {
connectStatus = "" connectStatus = ""
connectStatusDevice = "" connectStatusDevice = ""
connectError = "" connectError = ""
} }
// Refresh devices after a delay to ensure the forget operation is complete // Refresh devices after a delay to ensure the forget operation is complete
Qt.callLater(refreshDevices, 1000) Qt.callLater(refreshDevices, 1000)
} catch (error) { } catch (error) {
console.warn("[Bluetooth] Error forgetting device:", error) Logger.warn("Bluetooth", "Error forgetting device:", error)
Qt.callLater(refreshDevices, 500) Qt.callLater(refreshDevices, 500)
} }
} }
// Function to get device icon // Function to get device icon
function getDeviceIcon(device) { function getDeviceIcon(device) {
if (!device) return "bluetooth" if (!device)
return "bluetooth"
// Use device icon if available, otherwise fall back to device type // Use device icon if available, otherwise fall back to device type
if (device.icon) { if (device.icon) {
return device.icon return device.icon
} }
// Fallback icons based on common device types // Fallback icons based on common device types
const name = (device.name || device.deviceName || "").toLowerCase() const name = (device.name || device.deviceName || "").toLowerCase()
if (name.includes("headphone") || name.includes("earbud") || name.includes("airpods")) { if (name.includes("headphone") || name.includes("earbud") || name.includes("airpods")) {
@ -350,14 +356,15 @@ Singleton {
} else if (name.includes("laptop") || name.includes("computer")) { } else if (name.includes("laptop") || name.includes("computer")) {
return "laptop" return "laptop"
} }
return "bluetooth" return "bluetooth"
} }
// Function to get device status text // Function to get device status text
function getDeviceStatus(device) { function getDeviceStatus(device) {
if (!device) return "" if (!device)
return ""
if (device.connected) { if (device.connected) {
return "Connected" return "Connected"
} else if (device.pairing) { } else if (device.pairing) {
@ -371,8 +378,9 @@ Singleton {
// Function to get battery level text // Function to get battery level text
function getBatteryText(device) { function getBatteryText(device) {
if (!device || !device.batteryAvailable) return "" if (!device || !device.batteryAvailable)
return ""
const percentage = Math.round(device.battery * 100) const percentage = Math.round(device.battery * 100)
return `${percentage}%` return `${percentage}%`
} }
@ -381,7 +389,7 @@ Singleton {
Connections { Connections {
target: Bluetooth.defaultAdapter target: Bluetooth.defaultAdapter
ignoreUnknownSignals: true ignoreUnknownSignals: true
function onEnabledChanged() { function onEnabledChanged() {
root.isEnabled = Bluetooth.defaultAdapter.enabled root.isEnabled = Bluetooth.defaultAdapter.enabled
Settings.data.network.bluetoothEnabled = root.isEnabled Settings.data.network.bluetoothEnabled = root.isEnabled
@ -393,20 +401,20 @@ Singleton {
availableDevices = [] availableDevices = []
} }
} }
function onDiscoveringChanged() { function onDiscoveringChanged() {
root.isDiscovering = Bluetooth.defaultAdapter.discovering root.isDiscovering = Bluetooth.defaultAdapter.discovering
if (Bluetooth.defaultAdapter.discovering) { if (Bluetooth.defaultAdapter.discovering) {
Qt.callLater(refreshDevices) Qt.callLater(refreshDevices)
} }
} }
function onStateChanged() { function onStateChanged() {
if (Bluetooth.defaultAdapter.state >= 4) { if (Bluetooth.defaultAdapter.state >= 4) {
Qt.callLater(refreshDevices) Qt.callLater(refreshDevices)
} }
} }
function onDevicesChanged() { function onDevicesChanged() {
Qt.callLater(refreshDevices) Qt.callLater(refreshDevices)
} }
@ -416,9 +424,9 @@ Singleton {
Connections { Connections {
target: Bluetooth target: Bluetooth
ignoreUnknownSignals: true ignoreUnknownSignals: true
function onDevicesChanged() { function onDevicesChanged() {
Qt.callLater(refreshDevices) Qt.callLater(refreshDevices)
} }
} }
} }

View file

@ -156,13 +156,13 @@ Singleton {
readonly property Process initProc: Process { readonly property Process initProc: Process {
stdout: StdioCollector { stdout: StdioCollector {
onStreamFinished: { onStreamFinished: {
console.log("[Brightness] Raw brightness data for", monitor.modelData.name + ":", text.trim()) Logger.log("Brightness", "Raw brightness data for", monitor.modelData.name + ":", text.trim())
if (monitor.isAppleDisplay) { if (monitor.isAppleDisplay) {
var val = parseInt(text.trim()) var val = parseInt(text.trim())
if (!isNaN(val)) { if (!isNaN(val)) {
monitor.brightness = val / 101 monitor.brightness = val / 101
console.log("[Brightness] Apple display brightness:", monitor.brightness) Logger.log("Brightness", "Apple display brightness:", monitor.brightness)
} }
} else if (monitor.isDdc) { } else if (monitor.isDdc) {
var parts = text.trim().split(" ") var parts = text.trim().split(" ")
@ -171,7 +171,7 @@ Singleton {
var max = parseInt(parts[1]) var max = parseInt(parts[1])
if (!isNaN(current) && !isNaN(max) && max > 0) { if (!isNaN(current) && !isNaN(max) && max > 0) {
monitor.brightness = current / max monitor.brightness = current / max
console.log("[Brightness] DDC brightness:", current + "/" + max + " =", monitor.brightness) Logger.log("Brightness", "DDC brightness:", current + "/" + max + " =", monitor.brightness)
} }
} }
} else { } else {
@ -182,7 +182,7 @@ Singleton {
var max = parseInt(parts[1]) var max = parseInt(parts[1])
if (!isNaN(current) && !isNaN(max) && max > 0) { if (!isNaN(current) && !isNaN(max) && max > 0) {
monitor.brightness = current / max monitor.brightness = current / max
console.log("[Brightness] Internal brightness:", current + "/" + max + " =", monitor.brightness) Logger.log("Brightness", "Internal brightness:", current + "/" + max + " =", monitor.brightness)
} }
} }
} }

View file

@ -10,7 +10,7 @@ Singleton {
id: root id: root
Component.onCompleted: { Component.onCompleted: {
console.log("[ColorSchemes] Service started") Logger.log("ColorSchemes", "Service started")
loadColorSchemes() loadColorSchemes()
} }
@ -20,7 +20,7 @@ Singleton {
property string colorsJsonFilePath: Settings.configDir + "colors.json" property string colorsJsonFilePath: Settings.configDir + "colors.json"
function loadColorSchemes() { function loadColorSchemes() {
console.log("[ColorSchemes] Load ColorSchemes") Logger.log("ColorSchemes", "Load ColorSchemes")
scanning = true scanning = true
schemes = [] schemes = []
// Unsetting, then setting the folder will re-trigger the parsing! // Unsetting, then setting the folder will re-trigger the parsing!
@ -34,7 +34,7 @@ Singleton {
function changedWallpaper() { function changedWallpaper() {
if (Settings.data.colorSchemes.useWallpaperColors) { if (Settings.data.colorSchemes.useWallpaperColors) {
console.log("[ColorSchemes] Starting color generation process") Logger.log("ColorSchemes", "Starting color generation from wallpaper")
generateColorsProcess.running = true generateColorsProcess.running = true
// Invalidate potential predefined scheme // Invalidate potential predefined scheme
Settings.data.colorSchemes.predefinedScheme = "" Settings.data.colorSchemes.predefinedScheme = ""
@ -55,7 +55,7 @@ Singleton {
} }
schemes = files schemes = files
scanning = false scanning = false
console.log("[ColorSchemes] Loaded", schemes.length, "schemes") Logger.log("ColorSchemes", "Loaded", schemes.length, "schemes")
} }
} }
} }
@ -67,13 +67,13 @@ Singleton {
running: false running: false
stdout: StdioCollector { stdout: StdioCollector {
onStreamFinished: { onStreamFinished: {
console.log("[ColorSchemes] Generated colors from wallpaper") Logger.log("ColorSchemes", "Completed colors generation")
} }
} }
stderr: StdioCollector { stderr: StdioCollector {
onStreamFinished: { onStreamFinished: {
if (this.text !== "") { if (this.text !== "") {
console.error(this.text) Logger.error(this.text)
} }
} }
} }

View file

@ -52,11 +52,11 @@ Singleton {
function loadFromCache() { function loadFromCache() {
const now = Time.timestamp const now = Time.timestamp
if (!data.timestamp || (now >= data.timestamp + githubUpdateFrequency)) { if (!data.timestamp || (now >= data.timestamp + githubUpdateFrequency)) {
console.log("[GitHub] Cache expired or missing, fetching new data") Logger.log("GitHub", "Cache expired or missing, fetching new data")
fetchFromGitHub() fetchFromGitHub()
return return
} }
console.log("[GitHub] Loading cached GitHub data (age:", Math.round((now - data.timestamp) / 60), "minutes)") Logger.log("GitHub", "Loading cached GitHub data (age:", Math.round((now - data.timestamp) / 60), "minutes)")
if (data.version) { if (data.version) {
root.latestVersion = data.version root.latestVersion = data.version
@ -69,7 +69,7 @@ Singleton {
// -------------------------------- // --------------------------------
function fetchFromGitHub() { function fetchFromGitHub() {
if (isFetchingData) { if (isFetchingData) {
console.warn("[GitHub] GitHub data is still fetching") Logger.warn("GitHub", "GitHub data is still fetching")
return return
} }
@ -81,8 +81,8 @@ Singleton {
// -------------------------------- // --------------------------------
function saveData() { function saveData() {
data.timestamp = Time.timestamp data.timestamp = Time.timestamp
console.log("[GitHub] Saving data to cache file:", githubDataFile) Logger.log("GitHub", "Saving data to cache file:", githubDataFile)
console.log("[GitHub] Data to save - version:", data.version, "contributors:", data.contributors.length) Logger.log("GitHub", "Data to save - version:", data.version, "contributors:", data.contributors.length)
// Ensure cache directory exists // Ensure cache directory exists
Quickshell.execDetached(["mkdir", "-p", Settings.cacheDir]) Quickshell.execDetached(["mkdir", "-p", Settings.cacheDir])
@ -90,7 +90,7 @@ Singleton {
Qt.callLater(() => { Qt.callLater(() => {
// Use direct ID reference to the FileView // Use direct ID reference to the FileView
githubDataFileView.writeAdapter() githubDataFileView.writeAdapter()
console.log("[GitHub] Cache file written successfully") Logger.log("GitHub", "Cache file written successfully")
}) })
} }
@ -119,15 +119,15 @@ Singleton {
const version = data.tag_name const version = data.tag_name
root.data.version = version root.data.version = version
root.latestVersion = version root.latestVersion = version
console.log("[GitHub] Latest version fetched from GitHub:", version) Logger.log("GitHub", "Latest version fetched from GitHub:", version)
} else { } else {
console.log("[GitHub] No tag_name in GitHub response") Logger.log("GitHub", "No tag_name in GitHub response")
} }
} else { } else {
console.log("[GitHub] Empty response from GitHub API") Logger.log("GitHub", "Empty response from GitHub API")
} }
} catch (e) { } catch (e) {
console.error("[GitHub] Failed to parse version:", e) Logger.error("GitHub", "Failed to parse version:", e)
} }
// Check if both processes are done // Check if both processes are done
@ -145,21 +145,21 @@ Singleton {
onStreamFinished: { onStreamFinished: {
try { try {
const response = text const response = text
console.log("[GitHub] Raw contributors response length:", response ? response.length : 0) Logger.log("GitHub", "Raw contributors response length:", response ? response.length : 0)
if (response && response.trim()) { if (response && response.trim()) {
const data = JSON.parse(response) const data = JSON.parse(response)
console.log("[GitHub] Parsed contributors data type:", typeof data, "length:", Logger.log("GitHub", "Parsed contributors data type:", typeof data, "length:",
Array.isArray(data) ? data.length : "not array") Array.isArray(data) ? data.length : "not array")
root.data.contributors = data || [] root.data.contributors = data || []
root.contributors = root.data.contributors root.contributors = root.data.contributors
console.log("[GitHub] Contributors fetched from GitHub:", root.contributors.length) Logger.log("GitHub", "Contributors fetched from GitHub:", root.contributors.length)
} else { } else {
console.log("[GitHub] Empty response from GitHub API for contributors") Logger.log("GitHub", "Empty response from GitHub API for contributors")
root.data.contributors = [] root.data.contributors = []
root.contributors = [] root.contributors = []
} }
} catch (e) { } catch (e) {
console.error("[GitHub] Failed to parse contributors:", e) Logger.error("GitHub", "Failed to parse contributors:", e)
root.data.contributors = [] root.data.contributors = []
root.contributors = [] root.contributors = []
} }

View file

@ -50,12 +50,12 @@ Singleton {
function init() { function init() {
// does nothing but ensure the singleton is created // does nothing but ensure the singleton is created
// do not remove // do not remove
console.log("[Location] Service started") Logger.log("Location", "Service started")
} }
// -------------------------------- // --------------------------------
function resetWeather() { function resetWeather() {
console.log("[Location] Resetting weather data") Logger.log("Location", "Resetting weather data")
data.latitude = "" data.latitude = ""
data.longitude = "" data.longitude = ""
@ -70,12 +70,12 @@ Singleton {
// -------------------------------- // --------------------------------
function updateWeather() { function updateWeather() {
if (isFetchingWeather) { if (isFetchingWeather) {
console.warn("[Location] Weather is still fetching") Logger.warn("Location", "Weather is still fetching")
return return
} }
if (data.latitude === "") { if (data.latitude === "") {
console.warn("[Location] Why is my latitude empty") Logger.warn("Location", "Why is my latitude empty")
} }
if ((data.weatherLastFetch === "") || (data.weather === null) || (data.latitude === "") || (data.longitude === "") if ((data.weatherLastFetch === "") || (data.weather === null) || (data.latitude === "") || (data.longitude === "")
@ -91,7 +91,7 @@ Singleton {
if ((data.latitude === "") || (data.longitude === "") || (data.name !== Settings.data.location.name)) { if ((data.latitude === "") || (data.longitude === "") || (data.name !== Settings.data.location.name)) {
_geocodeLocation(Settings.data.location.name, function (latitude, longitude) { _geocodeLocation(Settings.data.location.name, function (latitude, longitude) {
console.log("[Location] Geocoded", Settings.data.location.name, "to:", latitude, "/", longitude) Logger.log("Location", " Geocoded", Settings.data.location.name, "to:", latitude, "/", longitude)
// Save location name // Save location name
data.name = Settings.data.location.name data.name = Settings.data.location.name
@ -109,7 +109,7 @@ Singleton {
// -------------------------------- // --------------------------------
function _geocodeLocation(locationName, callback, errorCallback) { function _geocodeLocation(locationName, callback, errorCallback) {
console.log("[Location] Geocoding from api.open-meteo.com") Logger.log("Location", "Geocoding from api.open-meteo.com")
var geoUrl = "https://geocoding-api.open-meteo.com/v1/search?name=" + encodeURIComponent( var geoUrl = "https://geocoding-api.open-meteo.com/v1/search?name=" + encodeURIComponent(
locationName) + "&language=en&format=json" locationName) + "&language=en&format=json"
var xhr = new XMLHttpRequest() var xhr = new XMLHttpRequest()
@ -118,17 +118,17 @@ Singleton {
if (xhr.status === 200) { if (xhr.status === 200) {
try { try {
var geoData = JSON.parse(xhr.responseText) var geoData = JSON.parse(xhr.responseText)
// console.log(JSON.stringify(geoData)) // Logger.logJSON.stringify(geoData))
if (geoData.results && geoData.results.length > 0) { if (geoData.results && geoData.results.length > 0) {
callback(geoData.results[0].latitude, geoData.results[0].longitude) callback(geoData.results[0].latitude, geoData.results[0].longitude)
} else { } else {
errorCallback("[Location] could not resolve location name") errorCallback("Location", "could not resolve location name")
} }
} catch (e) { } catch (e) {
errorCallback("[Location] Failed to parse geocoding data: " + e) errorCallback("Location", "Failed to parse geocoding data: " + e)
} }
} else { } else {
errorCallback("[Location] Geocoding error: " + xhr.status) errorCallback("Location", "Geocoding error: " + xhr.status)
} }
} }
} }
@ -138,7 +138,7 @@ Singleton {
// -------------------------------- // --------------------------------
function _fetchWeather(latitude, longitude, errorCallback) { function _fetchWeather(latitude, longitude, errorCallback) {
console.log("[Location] Fetching weather from api.open-meteo.com") Logger.log("Location", "Fetching weather from api.open-meteo.com")
var url = "https://api.open-meteo.com/v1/forecast?latitude=" + latitude + "&longitude=" + longitude var url = "https://api.open-meteo.com/v1/forecast?latitude=" + latitude + "&longitude=" + longitude
+ "&current_weather=true&current=relativehumidity_2m,surface_pressure&daily=temperature_2m_max,temperature_2m_min,weathercode&timezone=auto" + "&current_weather=true&current=relativehumidity_2m,surface_pressure&daily=temperature_2m_max,temperature_2m_min,weathercode&timezone=auto"
var xhr = new XMLHttpRequest() var xhr = new XMLHttpRequest()
@ -155,12 +155,12 @@ Singleton {
data.longitude = weatherData.longitude.toString() data.longitude = weatherData.longitude.toString()
isFetchingWeather = false isFetchingWeather = false
console.log("[Location] Cached weather to disk") Logger.log("Location", "Cached weather to disk")
} catch (e) { } catch (e) {
errorCallback("[Location] Failed to parse weather data") errorCallback("Location", "Failed to parse weather data")
} }
} else { } else {
errorCallback("[Location] Weather fetch error: " + xhr.status) errorCallback("Location", "Weather fetch error: " + xhr.status)
} }
} }
} }
@ -170,7 +170,7 @@ Singleton {
// -------------------------------- // --------------------------------
function errorCallback(message) { function errorCallback(message) {
console.error(message) Logger.error(message)
isFetchingWeather = false isFetchingWeather = false
} }

View file

@ -50,7 +50,7 @@ Singleton {
function findActivePlayer() { function findActivePlayer() {
let availablePlayers = getAvailablePlayers() let availablePlayers = getAvailablePlayers()
if (availablePlayers.length === 0) { if (availablePlayers.length === 0) {
console.log("[Media] No active player found") Logger.log("Media", "No active player found")
return null return null
} }
@ -68,7 +68,7 @@ Singleton {
if (newPlayer !== currentPlayer) { if (newPlayer !== currentPlayer) {
currentPlayer = newPlayer currentPlayer = newPlayer
currentPosition = currentPlayer ? currentPlayer.position : 0 currentPosition = currentPlayer ? currentPlayer.position : 0
console.log("[Media] Switching player") Logger.log("Media", "Switching player")
} }
} }
@ -149,7 +149,7 @@ Singleton {
Connections { Connections {
target: Mpris.players target: Mpris.players
function onValuesChanged() { function onValuesChanged() {
console.log("[Media] Players changed") Logger.log("Media", "Players changed")
updateCurrentPlayer() updateCurrentPlayer()
} }
} }

View file

@ -18,7 +18,7 @@ Singleton {
property bool isLoading: false property bool isLoading: false
Component.onCompleted: { Component.onCompleted: {
console.log("[Network] Service started") Logger.log("Network", "Service started")
// Only refresh networks if WiFi is enabled // Only refresh networks if WiFi is enabled
if (Settings.data.network.wifiEnabled) { if (Settings.data.network.wifiEnabled) {
refreshNetworks() refreshNetworks()
@ -165,7 +165,7 @@ Singleton {
stderr: StdioCollector { stderr: StdioCollector {
onStreamFinished: { onStreamFinished: {
if (text.trim() !== "") { if (text.trim() !== "") {
console.warn("Error enabling WiFi:", text) Logger.warn("Network", "Error enabling WiFi:", text)
} }
} }
} }
@ -235,7 +235,7 @@ Singleton {
stderr: StdioCollector { stderr: StdioCollector {
onStreamFinished: { onStreamFinished: {
if (text.trim() !== "") { if (text.trim() !== "") {
console.warn("Error disabling WiFi:", text) Logger.warn("Network", "Error disabling WiFi:", text)
} }
} }
} }
@ -274,7 +274,7 @@ Singleton {
const parts = line.split(":") const parts = line.split(":")
if (parts.length < 2) { if (parts.length < 2) {
console.warn("Malformed nmcli output line:", line) Logger.warn("Network", "Malformed nmcli output line:", line)
continue continue
} }
@ -313,7 +313,7 @@ Singleton {
const parts = line.split(":") const parts = line.split(":")
if (parts.length < 4) { if (parts.length < 4) {
console.warn("Malformed nmcli output line:", line) Logger.warn("Network", "Malformed nmcli output line:", line)
continue continue
} }
const ssid = parts[0] const ssid = parts[0]

View file

@ -63,7 +63,7 @@ Singleton {
root.workspaces = workspacesList root.workspaces = workspacesList
} catch (e) { } catch (e) {
console.error("Failed to parse workspaces:", e, line) Logger.error("NiriService", "Failed to parse workspaces:", e, line)
} }
} }
} }
@ -104,7 +104,7 @@ Singleton {
} }
} }
} catch (e) { } catch (e) {
console.error("Error parsing windows event:", e) Logger.error("NiriService", "Error parsing windows event:", e)
} }
} else if (event.WorkspaceActivated) { } else if (event.WorkspaceActivated) {
workspaceProcess.running = true workspaceProcess.running = true
@ -120,17 +120,17 @@ Singleton {
root.focusedWindowIndex = -1 root.focusedWindowIndex = -1
} }
} catch (e) { } catch (e) {
console.error("Error parsing window focus event:", e) Logger.error("NiriService", "Error parsing window focus event:", e)
} }
} else if (event.OverviewOpenedOrClosed) { } else if (event.OverviewOpenedOrClosed) {
try { try {
root.inOverview = event.OverviewOpenedOrClosed.is_open === true root.inOverview = event.OverviewOpenedOrClosed.is_open === true
} catch (e) { } catch (e) {
console.error("Error parsing overview state:", e) Logger.error("NiriService", "Error parsing overview state:", e)
} }
} }
} catch (e) { } catch (e) {
console.error("Error parsing event stream:", e, data) Logger.error("NiriService", "Error parsing event stream:", e, data)
} }
} }
} }

View file

@ -165,7 +165,7 @@ QtObject {
}) })
} }
} catch (e) { } catch (e) {
console.error("[Notifications] Failed to load history:", e) Logger.error("Notifications", "Failed to load history:", e)
} }
} }
@ -190,7 +190,7 @@ QtObject {
historyFileView.writeAdapter() historyFileView.writeAdapter()
}) })
} catch (e) { } catch (e) {
console.error("[Notifications] Failed to save history:", e) Logger.error("Notifications", "Failed to save history:", e)
} }
} }

View file

@ -34,9 +34,9 @@ Singleton {
+ " -k " + settings.videoCodec + " -a " + settings.audioSource + " -q " + settings.quality + " -k " + settings.videoCodec + " -a " + settings.audioSource + " -q " + settings.quality
+ " -cursor " + (settings.showCursor ? "yes" : "no") + " -cr " + settings.colorRange + " -o " + outputPath + " -cursor " + (settings.showCursor ? "yes" : "no") + " -cr " + settings.colorRange + " -o " + outputPath
//console.log("[ScreenRecorder]", command) //Logger.log("ScreenRecorder", command)
Quickshell.execDetached(["sh", "-c", command]) Quickshell.execDetached(["sh", "-c", command])
console.log("[ScreenRecorder] Started recording") Logger.log("ScreenRecorder", "Started recording")
} }
// Stop recording using Quickshell.execDetached // Stop recording using Quickshell.execDetached
@ -46,7 +46,7 @@ Singleton {
} }
Quickshell.execDetached(["sh", "-c", "pkill -SIGINT -f 'gpu-screen-recorder.*portal'"]) Quickshell.execDetached(["sh", "-c", "pkill -SIGINT -f 'gpu-screen-recorder.*portal'"])
console.log("[ScreenRecorder] Finished recording:", outputPath) Logger.log("ScreenRecorder", "Finished recording:", outputPath)
// Just in case, force kill after 3 seconds // Just in case, force kill after 3 seconds
killTimer.running = true killTimer.running = true

View file

@ -10,7 +10,7 @@ Singleton {
id: root id: root
Component.onCompleted: { Component.onCompleted: {
console.log("[Wallpapers] Service started") Logger.log("Wallpapers", "Service started")
loadWallpapers() loadWallpapers()
// Wallpaper is set when the settings are loaded. // Wallpaper is set when the settings are loaded.
@ -26,7 +26,7 @@ Singleton {
property var randomChoices: ["simple", "fade", "left", "right", "top", "bottom", "wipe", "wave", "grow", "center", "any", "outer"] property var randomChoices: ["simple", "fade", "left", "right", "top", "bottom", "wipe", "wave", "grow", "center", "any", "outer"]
function loadWallpapers() { function loadWallpapers() {
console.log("[Wallpapers] Load Wallpapers") Logger.log("Wallpapers", "Load Wallpapers")
scanning = true scanning = true
wallpaperList = [] wallpaperList = []
// Unsetting, then setting the folder will re-trigger the parsing! // Unsetting, then setting the folder will re-trigger the parsing!
@ -35,7 +35,7 @@ Singleton {
} }
function changeWallpaper(path) { function changeWallpaper(path) {
console.log("[Wallpapers] Changing to:", path) Logger.log("Wallpapers", "Changing to:", path)
setCurrentWallpaper(path, false) setCurrentWallpaper(path, false)
} }
@ -58,7 +58,7 @@ Singleton {
} else { } else {
// Fallback: update the settings directly for non-SWWW mode // Fallback: update the settings directly for non-SWWW mode
//console.log("[Wallpapers] Not using Swww, setting wallpaper directly") //Logger.log("Wallpapers", "Not using Swww, setting wallpaper directly")
} }
if (randomWallpaperTimer.running) { if (randomWallpaperTimer.running) {
@ -98,7 +98,7 @@ Singleton {
function startSWWWDaemon() { function startSWWWDaemon() {
if (Settings.data.wallpaper.swww.enabled) { if (Settings.data.wallpaper.swww.enabled) {
console.log("[SWWW] Requesting swww-daemon") Logger.log("Swww", "Requesting swww-daemon")
startDaemonProcess.running = true startDaemonProcess.running = true
} }
} }
@ -128,7 +128,7 @@ Singleton {
} }
wallpaperList = files wallpaperList = files
scanning = false scanning = false
console.log("[Wallpapers] List refreshed, count:", wallpaperList.length) Logger.log("Wallpapers", "List refreshed, count:", wallpaperList.length)
} }
} }
} }
@ -145,10 +145,10 @@ Singleton {
} }
onExited: function (exitCode, exitStatus) { onExited: function (exitCode, exitStatus) {
console.log("[SWWW] Process finished with exit code:", exitCode, "status:", exitStatus) Logger.log("Swww", "Process finished with exit code:", exitCode, "status:", exitStatus)
if (exitCode !== 0) { if (exitCode !== 0) {
console.log("[SWWW] Process failed. Make sure swww-daemon is running with: swww-daemon") Logger.log("Swww", "Process failed. Make sure swww-daemon is running with: swww-daemon")
console.log("[SWWW] You can start it with: swww-daemon --format xrgb") Logger.log("Swww", "You can start it with: swww-daemon --format xrgb")
} }
} }
} }
@ -159,15 +159,15 @@ Singleton {
running: false running: false
onStarted: { onStarted: {
console.log("[SWWW] Daemon start process initiated") Logger.log("Swww", "Daemon start process initiated")
} }
onExited: function (exitCode, exitStatus) { onExited: function (exitCode, exitStatus) {
console.log("[SWWW] Daemon start process finished with exit code:", exitCode) Logger.log("Swww", "Daemon start process finished with exit code:", exitCode)
if (exitCode === 0) { if (exitCode === 0) {
console.log("[SWWW] Daemon started successfully") Logger.log("Swww", "Daemon started successfully")
} else { } else {
console.log("[SWWW] Failed to start daemon, may already be running") Logger.log("Swww", "Failed to start daemon, may already be running")
} }
} }
} }

View file

@ -41,7 +41,7 @@ Singleton {
return return
} }
} catch (e) { } catch (e) {
console.error("[Workspaces] Error detecting compositor:", e) Logger.error("Workspaces", "Error detecting compositor:", e)
} }
} }
@ -54,7 +54,7 @@ Singleton {
// updateHyprlandWorkspaces(); // updateHyprlandWorkspaces();
return true return true
} catch (e) { } catch (e) {
console.error("Error initializing Hyprland:", e) Logger.error("Error initializing Hyprland:", e)
isHyprland = false isHyprland = false
return false return false
} }
@ -98,7 +98,7 @@ Singleton {
} }
workspacesChanged() workspacesChanged()
} catch (e) { } catch (e) {
console.error("[Workspaces] Error updating Hyprland workspaces:", e) Logger.error("Workspaces", "Error updating Hyprland workspaces:", e)
} }
} }
@ -138,16 +138,16 @@ Singleton {
try { try {
Hyprland.dispatch(`workspace ${workspaceId}`) Hyprland.dispatch(`workspace ${workspaceId}`)
} catch (e) { } catch (e) {
console.error("Error switching Hyprland workspace:", e) Logger.error("Error switching Hyprland workspace:", e)
} }
} else if (isNiri) { } else if (isNiri) {
try { try {
Quickshell.execDetached(["niri", "msg", "action", "focus-workspace", workspaceId.toString()]) Quickshell.execDetached(["niri", "msg", "action", "focus-workspace", workspaceId.toString()])
} catch (e) { } catch (e) {
console.error("Error switching Niri workspace:", e) Logger.error("Error switching Niri workspace:", e)
} }
} else { } else {
console.warn("No supported compositor detected for workspace switching") Logger.warn("No supported compositor detected for workspace switching")
} }
} }
} }

View file

@ -18,7 +18,7 @@ Loader {
sourceComponent: content sourceComponent: content
// onLoaded: { // onLoaded: {
// console.log("[NLoader] onLoaded:", item.toString()); // Logger.log("NLoader", "OnLoaded:", item.toString());
// } // }
onActiveChanged: { onActiveChanged: {
if (active && item && item.show) { if (active && item && item.show) {