Add glassMxrph shell sources

Initial commit of the Quickshell desktop suite: bar, dock, launcher,
settings, Control Center, dashboard, OSD, lock screen, desktop widgets,
plugin host with the vendored Noctalia/Omarchy compatibility layer,
helpers, packaging, tests and phase documentation.

Includes the optimization work so far: usage widgets and dashboard
gauges no longer animate continuously, desktop widgets pause while
covered, system controls stop flickering on background polls, dock app
matching uses an indexed catalog, and workspace ghosts are created only
for occupied slots.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mxandClaude Opus 5.5 committed 2026-10-07 22:36:17 +02:00
commit 99e64a7713
433 files changed
+57792

No files matched your search

@@ -0,0 +1,31 @@
pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Hyprland
// glassMxrph stand-in: glassMxrph runs on Hyprland.
Singleton {
readonly property bool isHyprland: true
readonly property bool isNiri: false
readonly property bool isSway: false
readonly property bool isMango: false
readonly property bool isLabwc: false
readonly property bool overviewActive: false
readonly property var workspaces: Hyprland.workspaces.values.map(w => ({
"id": w.id,
"idx": w.id,
"name": w.name,
"output": w.monitor ? w.monitor.name : "",
"isFocused": w.focused,
"isActive": w.active,
"isUrgent": w.urgent,
"isOccupied": w.toplevels.values.length > 0
}))
function getDisplayScale(screenName) {
const s = Quickshell.screens.find(x => x.name === screenName);
return s ? s.devicePixelRatio : 1;
}
function switchToWorkspace(workspace) {
Hyprland.dispatch("workspace " + (workspace && workspace.id !== undefined ? workspace.id : workspace));
}
}
@@ -0,0 +1,368 @@
pragma Singleton
import QtQml
import QtQuick
import Quickshell
import Quickshell.Io
import Quickshell.Services.UPower
import qs.compat.noctalia.Commons
import qs.compat.noctalia.Services.Networking
import qs.compat.noctalia.Services.UI
Singleton {
id: root
readonly property var primaryDevice: _laptopBattery || _bluetoothBattery || null // Primary battery device (prioritizes laptop over Bluetooth)
readonly property real batteryPercentage: getPercentage(primaryDevice)
readonly property bool batteryCharging: isCharging(primaryDevice)
readonly property bool batteryPluggedIn: isPluggedIn(primaryDevice)
readonly property bool batteryReady: isDeviceReady(primaryDevice)
readonly property bool batteryPresent: isDevicePresent(primaryDevice)
readonly property real warningThreshold: Settings.data.systemMonitor.batteryWarningThreshold
readonly property real criticalThreshold: Settings.data.systemMonitor.batteryCriticalThreshold
readonly property string batteryIcon: getIcon(batteryPercentage, batteryCharging, batteryPluggedIn, batteryReady)
readonly property var laptopBatteries: UPower.devices.values.filter(d => d.isLaptopBattery).sort((x, y) => {
// Force DisplayDevice to the top
if (x.nativePath.includes("DisplayDevice"))
return -1;
if (y.nativePath.includes("DisplayDevice"))
return 1;
// Standard string comparison works for BAT0 vs BAT1
return x.nativePath.localeCompare(y.nativePath, undefined, {
numeric: true
});
})
readonly property var bluetoothBatteries: {
var list = [];
var btArray = BluetoothService.devices?.values || [];
for (var i = 0; i < btArray.length; i++) {
var btd = btArray[i];
if (btd && btd.connected && btd.batteryAvailable) {
list.push(btd);
}
}
return list;
}
readonly property var _laptopBattery: UPower.displayDevice.isPresent ? UPower.displayDevice : (laptopBatteries.length > 0 ? laptopBatteries[0] : null)
readonly property var _bluetoothBattery: bluetoothBatteries.length > 0 ? bluetoothBatteries[0] : null
property var deviceModel: {
var model = [
{
"key": "__default__",
"name": I18n.tr("bar.battery.device-default")
}
];
const devices = UPower.devices?.values || [];
for (let d of devices) {
if (!d || d.type === UPowerDeviceType.LinePower) {
continue;
}
model.push({
key: d.nativePath || "",
name: d.model || d.nativePath || I18n.tr("common.unknown")
});
}
return model;
}
property var _hasNotified: ({})
function findDevice(nativePath) {
if (!nativePath || nativePath === "__default__" || nativePath === "DisplayDevice") {
return _laptopBattery;
}
if (!UPower.devices) {
return null;
}
const devices = UPower.devices?.values || [];
for (let d of devices) {
if (d && d.nativePath === nativePath) {
if (d.type === UPowerDeviceType.LinePower) {
continue;
}
return d;
}
}
return null;
}
function isDevicePresent(device) {
if (!device) {
return false;
}
// Handle Bluetooth devices (identified by having batteryAvailable property)
if (device.batteryAvailable !== undefined) {
return device.connected === true;
}
// Handle UPower devices
if (device.type !== undefined) {
if (device.type === UPowerDeviceType.Battery && device.isPresent !== undefined) {
return device.isPresent === true;
}
// Fallback for non-battery UPower devices or if isPresent is missing
return device.ready && device.percentage !== undefined;
}
return false;
}
function isDeviceReady(device) {
if (!isDevicePresent(device)) {
return false;
}
if (device.batteryAvailable !== undefined) {
return device.battery !== undefined;
}
return device.ready && device.percentage !== undefined;
}
function getPercentage(device) {
if (!device) {
return -1;
}
if (device.batteryAvailable !== undefined) {
return Math.round((device.battery || 0) * 100);
}
return Math.round((device.percentage || 0) * 100);
}
function isCharging(device) {
if (!device || isBluetoothDevice(device)) {
// Tracking bluetooth devices can charge or not is a loop hole, none of my devices has it, even if it possible?!
return false; // Assuming not charging until someone/quickshell brings a way to do pretty unlikely.
}
if (device.state !== undefined) {
return device.state === UPowerDeviceState.Charging;
}
return false;
}
function isPluggedIn(device) {
if (!device || isBluetoothDevice(device)) {
// Tracking bluetooth devices can charge or not is a loop hole, none of my devices has it, even if it possible?!
return false; // Assuming not charging until someone/quickshell brings a way to do pretty unlikely.
}
if (device.state !== undefined) {
return device.state === UPowerDeviceState.FullyCharged || device.state === UPowerDeviceState.PendingCharge;
}
return false;
}
function isCriticalBattery(device) {
return (!isCharging(device) && !isPluggedIn(device)) && getPercentage(device) <= criticalThreshold;
}
function isLowBattery(device) {
return (!isCharging(device) && !isPluggedIn(device)) && getPercentage(device) <= warningThreshold && getPercentage(device) > criticalThreshold;
}
function isBluetoothDevice(device) {
if (!device) {
return false;
}
// Check for Quickshell Bluetooth device property
if (device.batteryAvailable !== undefined) {
return true;
}
// Check for UPower device path indicating it's a Bluetooth device
if (device.nativePath && (device.nativePath.includes("bluez") || device.nativePath.includes("bluetooth"))) {
return true;
}
return false;
}
function getDeviceName(device) {
if (!isDeviceReady(device)) {
return "";
}
if (!isBluetoothDevice(device) && device.isLaptopBattery) {
// If there is more than one battery explicitly name them
// Logger.e("BatteryDebug", "Available Battery count: " + laptopBatteries.length); // can be useful for debugging
if (laptopBatteries.length > 1 && device.nativePath) {
if (device.nativePath === "DisplayDevice") {
return I18n.tr("battery.all-batteries");
}
var match = device.nativePath.match(/(\d+)$/);
if (match) {
// In case of 2 batteries: bat0 => bat1 bat1 => bat2
return I18n.tr("common.battery") + " " + (parseInt(match[1]) + 1); // Append numbers
}
}
// Return Battery if there is only one
return I18n.tr("common.battery");
}
if (isBluetoothDevice(device) && device.name) {
return device.name;
}
if (device.model) {
return device.model;
}
return "";
}
function getIcon(percent, charging, pluggedIn, isReady) {
if (!isReady) {
return "battery-exclamation";
}
if (charging) {
return "battery-charging";
}
if (pluggedIn) {
return "battery-charging-2";
}
const icons = [
{
threshold: 86,
icon: "battery-4"
},
{
threshold: 56,
icon: "battery-3"
},
{
threshold: 31,
icon: "battery-2"
},
{
threshold: 11,
icon: "battery-1"
},
{
threshold: 0,
icon: "battery"
}
];
const match = icons.find(tier => percent >= tier.threshold);
return match ? match.icon : "battery-off"; // New fallback icon clearly represent if nothing is true here.
}
function getRateText(device) {
if (!device || device.changeRate === undefined) {
return "";
}
const rate = Math.abs(device.changeRate);
if (device.timeToFull > 0) {
return I18n.tr("battery.charging-rate", {
"rate": rate.toFixed(2)
});
} else if (device.timeToEmpty > 0) {
return I18n.tr("battery.discharging-rate", {
"rate": rate.toFixed(2)
});
}
}
function getTimeRemainingText(device) {
if (!isDeviceReady(device)) {
return I18n.tr("battery.no-battery-detected");
}
if (isPluggedIn(device)) {
return I18n.tr("battery.plugged-in");
} else if (device.timeToFull > 0) {
return I18n.tr("battery.time-until-full", {
"time": Time.formatVagueHumanReadableDuration(device.timeToFull)
});
} else if (device.timeToEmpty > 0) {
return I18n.tr("battery.time-left", {
"time": Time.formatVagueHumanReadableDuration(device.timeToEmpty)
});
}
return I18n.tr("common.idle");
}
function checkDevice(device) {
if (!device || !isDeviceReady(device)) {
return;
}
const percentage = getPercentage(device);
const charging = isCharging(device);
const pluggedIn = isPluggedIn(device);
const level = isLowBattery(device) ? "low" : (isCriticalBattery(device) ? "critical" : "");
var deviceKey = device.nativePath;
if (!_hasNotified[deviceKey]) {
_hasNotified[deviceKey] = {
low: false,
critical: false
};
}
if (charging || pluggedIn) {
_hasNotified[deviceKey].low = false;
_hasNotified[deviceKey].critical = false;
}
if (percentage > warningThreshold) {
_hasNotified[deviceKey].low = false;
_hasNotified[deviceKey].critical = false;
} else if (percentage > criticalThreshold) {
_hasNotified[deviceKey].critical = false;
}
if (level) {
if (!_hasNotified[deviceKey][level]) {
notify(device, level);
_hasNotified[deviceKey][level] = true;
}
}
}
function notify(device, level) {
if (!Settings.data.notifications.enableBatteryToast) {
return;
}
var name = getDeviceName(device);
var titleKey = level === "critical" ? "toast.battery.critical" : "toast.battery.low";
var descKey = level === "critical" ? "toast.battery.critical-desc" : "toast.battery.low-desc";
var title = I18n.tr(titleKey);
var desc = I18n.tr(descKey, {
"percent": getPercentage(device)
});
var icon = level === "critical" ? "battery-exclamation" : "battery-charging-2";
if (device == _bluetoothBattery && name) {
title = title + " " + name;
}
// Only 'showNotice' supports custom icons
ToastService.showNotice(title, desc, icon, 6000);
}
Instantiator {
model: deviceModel
delegate: Connections {
required property var modelData
property var device: findDevice(modelData.key)
target: device
function onPercentageChanged() {
if (device.isLaptopBattery && modelData.key !== "__default__") {
return;
}
checkDevice(device);
}
function onStateChanged() {
if (device.isLaptopBattery && modelData.key !== "__default__") {
return;
}
checkDevice(device);
}
}
}
}
@@ -0,0 +1,397 @@
pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Io
import qs.compat.noctalia.Commons
// Location and weather service with decoupled geocoding and weather fetching.
Singleton {
id: root
property string locationFile: Quickshell.env("NOCTALIA_WEATHER_FILE") || (Settings.cacheDir + "location.json")
property int weatherUpdateFrequency: 30 * 60
property bool isFetchingWeather: false
// Talia weather
readonly property int taliaMascotWeatherMonth: 3
readonly property int taliaMascotWeatherDay: 1
readonly property bool taliaWeatherMascotDayActive: {
const d = Time.now;
return d.getMonth() === root.taliaMascotWeatherMonth && d.getDate() === root.taliaMascotWeatherDay;
}
readonly property bool taliaWeatherMascotActive: taliaWeatherMascotDayActive || Settings.data.location.weatherTaliaMascotAlways
readonly property alias data: adapter
// True when the user has set a location name or enabled auto-locate
readonly property bool locationConfigured: Settings.data.location.name !== "" || Settings.data.location.autoLocate
// Stable UI properties - only updated when location is successfully geocoded
property bool coordinatesReady: false
property string stableLatitude: ""
property string stableLongitude: ""
property string stableName: ""
FileView {
id: locationFileView
path: locationFile
printErrors: false
onAdapterUpdated: saveTimer.start()
onLoaded: {
Logger.d("Location", "Loaded cached data");
if (adapter.latitude !== "" && adapter.longitude !== "" && adapter.weatherLastFetch > 0) {
root.stableLatitude = adapter.latitude;
root.stableLongitude = adapter.longitude;
root.stableName = adapter.name;
root.coordinatesReady = true;
Logger.i("Location", "Coordinates ready");
}
update();
}
onLoadFailed: function (error) {
update();
}
JsonAdapter {
id: adapter
property string latitude: ""
property string longitude: ""
property string name: ""
property int weatherLastFetch: 0
property var weather: null
}
}
// Formatted coordinates for UI display
readonly property string displayCoordinates: {
if (!root.coordinatesReady || root.stableLatitude === "" || root.stableLongitude === "") {
return "";
}
const lat = parseFloat(root.stableLatitude).toFixed(4);
const lon = parseFloat(root.stableLongitude).toFixed(4);
return `${lat}, ${lon}`;
}
// Auto-geolocate timer - periodically updates location via IP geolocation
Timer {
id: autoLocateTimer
interval: 30 * 60 * 1000
running: Settings.data.location.autoLocate
repeat: true
triggeredOnStart: true
onTriggered: root.geolocateAndApply()
}
// Update timer runs when weather is enabled or location-based scheduling is active
Timer {
id: updateTimer
interval: 20 * 1000
running: Settings.data.location.weatherEnabled || Settings.data.colorSchemes.schedulingMode == "location"
repeat: true
onTriggered: {
update();
}
}
Timer {
id: saveTimer
running: false
interval: 1000
onTriggered: locationFileView.writeAdapter()
}
function init() {
Logger.i("Location", "Service started");
}
function resetWeather() {
Logger.i("Location", "Resetting location and weather data");
root.coordinatesReady = false;
root.stableLatitude = "";
root.stableLongitude = "";
root.stableName = "";
adapter.latitude = "";
adapter.longitude = "";
adapter.name = "";
adapter.weatherLastFetch = 0;
adapter.weather = null;
isFetchingWeather = false;
update();
}
// Main update function - geocodes location if needed, then fetches weather if enabled
function update() {
updateLocation();
if (Settings.data.location.weatherEnabled) {
updateWeatherData();
}
}
// Runs independently of weather toggle
function updateLocation() {
const locationChanged = adapter.name !== Settings.data.location.name;
const needsGeocoding = (adapter.latitude === "") || (adapter.longitude === "") || locationChanged;
if (!needsGeocoding) {
return;
}
if (isFetchingWeather) {
return;
}
isFetchingWeather = true;
if (locationChanged) {
root.coordinatesReady = false;
Logger.d("Location", "Location changed from", adapter.name, "to", Settings.data.location.name);
}
geocodeLocation(Settings.data.location.name, function (latitude, longitude, name, country) {
adapter.name = Settings.data.location.name;
adapter.latitude = latitude.toString();
adapter.longitude = longitude.toString();
root.stableLatitude = adapter.latitude;
root.stableLongitude = adapter.longitude;
root.stableName = `${name}, ${country}`;
root.coordinatesReady = true;
isFetchingWeather = false;
Logger.i("Location", `Geocoded ${Settings.data.location.name}: ${root.stableLatitude}, ${root.stableLongitude}`);
if (locationChanged) {
adapter.weatherLastFetch = 0;
updateWeatherData();
}
}, errorCallback);
}
// Fetch weather data if enabled and coordinates are available
function updateWeatherData() {
if (!Settings.data.location.weatherEnabled) {
return;
}
if (isFetchingWeather) {
return;
}
if (adapter.latitude === "" || adapter.longitude === "") {
Logger.w("Location", "Cannot fetch weather without coordinates");
return;
}
const needsWeatherUpdate = (adapter.weatherLastFetch === "") || (adapter.weather === null) || (Time.timestamp >= adapter.weatherLastFetch + weatherUpdateFrequency);
if (needsWeatherUpdate) {
isFetchingWeather = true;
fetchWeatherData(adapter.latitude, adapter.longitude, errorCallback);
}
}
// Query geocoding API to convert location name to coordinates
function geocodeLocation(locationName, callback, errorCallback) {
if (locationName === "") {
isFetchingWeather = false;
return;
}
Logger.d("Location", "Geocoding location name");
var geoUrl = "https://api.noctalia.dev/geocode?city=" + encodeURIComponent(locationName);
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState === XMLHttpRequest.DONE) {
if (xhr.status === 200) {
try {
var geoData = JSON.parse(xhr.responseText);
if (geoData.lat != null) {
callback(geoData.lat, geoData.lng, geoData.name, geoData.country);
} else {
errorCallback("Location", "could not resolve location name");
}
} catch (e) {
errorCallback("Location", "Failed to parse geocoding data: " + e);
}
} else {
errorCallback("Location", `Geocoding error: ${xhr.status} ${xhr.responseText}`);
}
}
};
xhr.open("GET", geoUrl);
xhr.send();
}
// Fetch weather data from Open-Meteo API
function fetchWeatherData(latitude, longitude, errorCallback) {
Logger.d("Location", "Fetching weather from api.open-meteo.com");
var url = "https://api.open-meteo.com/v1/forecast?latitude=" + latitude + "&longitude=" + longitude + "&current_weather=true&current=relativehumidity_2m,surface_pressure,is_day&daily=temperature_2m_max,temperature_2m_min,weathercode,sunset,sunrise&timezone=auto";
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState === XMLHttpRequest.DONE) {
if (xhr.status === 200) {
try {
var weatherData = JSON.parse(xhr.responseText);
//console.log(JSON.stringify(weatherData))
// Save core data
data.weather = weatherData;
data.weatherLastFetch = Time.timestamp;
// Update stable display values only when complete and successful
root.stableLatitude = data.latitude = weatherData.latitude.toString();
root.stableLongitude = data.longitude = weatherData.longitude.toString();
root.coordinatesReady = true;
isFetchingWeather = false;
Logger.d("Location", "Cached weather to disk - stable coordinates updated");
} catch (e) {
errorCallback("Location", "Failed to parse weather data");
}
} else {
errorCallback("Location", `Weather error: ${xhr.status} ${xhr.responseText}`);
}
}
};
xhr.open("GET", url);
xhr.send();
}
// Geolocate via IP address using the Noctalia API
function geolocate(callback, errorCallback) {
Logger.d("Location", "Geolocating via IP");
var url = "https://api.noctalia.dev/geolocate";
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState === XMLHttpRequest.DONE) {
if (xhr.status === 200) {
try {
var data = JSON.parse(xhr.responseText);
if (data.lat != null) {
callback(data.lat, data.lng, data.city, data.country);
} else {
errorCallback("Location", "Geolocate: no coordinates returned");
}
} catch (e) {
errorCallback("Location", "Failed to parse geolocate data: " + e);
}
} else {
errorCallback("Location", `Geolocate error: ${xhr.status} ${xhr.responseText}`);
}
}
};
xhr.open("GET", url);
xhr.send();
}
// Geolocate via IP and apply the result as the current location
function geolocateAndApply() {
if (isFetchingWeather) {
Logger.w("Location", "Geolocate skipped, fetch already in progress");
return;
}
geolocate(function (lat, lng, city, country) {
Logger.i("Location", "Geolocated to", city + ",", country + ":", lat + "," + lng);
const locationChanged = adapter.name !== city;
Settings.data.location.name = city;
adapter.name = city;
adapter.latitude = lat.toString();
adapter.longitude = lng.toString();
root.stableLatitude = adapter.latitude;
root.stableLongitude = adapter.longitude;
root.stableName = `${city}, ${country}`;
root.coordinatesReady = true;
if (locationChanged) {
adapter.weatherLastFetch = 0;
adapter.weather = null;
}
if (Settings.data.location.weatherEnabled) {
updateWeatherData();
}
}, errorCallback);
}
// --------------------------------
function errorCallback(module, message) {
Logger.w(module, message);
isFetchingWeather = false;
}
// --------------------------------
function weatherSymbolFromCode(code) {
var isDay = data.weather ? data.weather.current_weather.is_day : true;
if (code === 0)
return isDay ? "weather-sun" : "weather-moon";
if (code === 1 || code === 2)
return isDay ? "weather-cloud-sun" : "weather-moon-stars";
if (code === 3)
return "weather-cloud";
if (code >= 45 && code <= 48)
return "weather-cloud-haze";
if (code >= 51 && code <= 67)
return "weather-cloud-rain";
if (code >= 80 && code <= 82)
return "weather-cloud-rain";
if (code >= 71 && code <= 77)
return "weather-cloud-snow";
if (code >= 71 && code <= 77)
return "weather-cloud-snow";
if (code >= 85 && code <= 86)
return "weather-cloud-snow";
if (code >= 95 && code <= 99)
return "weather-cloud-lightning";
return "weather-cloud";
}
// --------------------------------
function taliaWeatherImageFromCode(code) {
var isDay = data.weather ? data.weather.current_weather.is_day : true;
if (code >= 40 && code <= 49)
return Quickshell.shellDir + "/Assets/Talia/TaliaDazed.png";
if (code >= 95 && code <= 99)
return Quickshell.shellDir + "/Assets/Talia/TaliaFear.png";
var wet = (code >= 51 && code <= 67) || (code >= 80 && code <= 82) || (code >= 71 && code <= 77) || (code >= 85 && code <= 86);
if (wet)
return Quickshell.shellDir + "/Assets/Talia/TaliaSob.png";
if ((code === 0 || code === 1 || code === 2) && isDay === false)
return Quickshell.shellDir + "/Assets/Talia/TaliaVampire.png";
if ((code === 0 && isDay === true) || code === 1 || code === 2)
return Quickshell.shellDir + "/Assets/Talia/TaliaParty.png";
return Quickshell.shellDir + "/Assets/Talia/TaliaBlank.png";
}
// --------------------------------
function weatherDescriptionFromCode(code) {
if (code === 0)
return "Clear sky";
if (code === 1)
return "Mainly clear";
if (code === 2)
return "Partly cloudy";
if (code === 3)
return "Overcast";
if (code === 45 || code === 48)
return "Fog";
if (code >= 51 && code <= 67)
return "Drizzle";
if (code >= 71 && code <= 77)
return "Snow";
if (code >= 80 && code <= 82)
return "Rain showers";
if (code >= 95 && code <= 99)
return "Thunderstorm";
return "Unknown";
}
// --------------------------------
function celsiusToFahrenheit(celsius) {
return 32 + celsius * 1.8;
}
}
@@ -0,0 +1,35 @@
pragma Singleton
import QtQuick
import Quickshell
import "../../../../services" as GS
// glassMxrph stand-in: the audio spectrum comes from glassMxrph's Cava
// (Noctalia's PwAudioSpectrum is not in Quickshell 0.3.1).
Singleton {
id: root
property var _registeredComponents: ({})
readonly property int _registeredCount: Object.keys(_registeredComponents).length
readonly property var values: GS.CavaService.bars
readonly property bool isIdle: !GS.CavaService.wanted
property bool subscribed: false
on_RegisteredCountChanged: {
const want = _registeredCount > 0;
if (want !== subscribed) {
GS.CavaService.widgetConsumers += want ? 1 : -1;
subscribed = want;
}
}
function registerComponent(componentId) {
const next = Object.assign({}, _registeredComponents);
next[componentId] = true;
_registeredComponents = next;
}
function unregisterComponent(componentId) {
const next = Object.assign({}, _registeredComponents);
delete next[componentId];
_registeredComponents = next;
}
function isRegistered(componentId) {
return !!_registeredComponents[componentId];
}
}
@@ -0,0 +1,11 @@
pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Bluetooth
// glassMxrph stand-in: only what other compatibility services read.
Singleton {
readonly property var adapter: Bluetooth.defaultAdapter
readonly property var devices: Bluetooth.devices
readonly property bool enabled: !!adapter && adapter.enabled
}
@@ -0,0 +1,46 @@
pragma Singleton
import QtQuick
import Quickshell
import "../../../../services" as GS
// glassMxrph stand-in: answers from glassMxrph's installed plugins.
Singleton {
readonly property string pluginsDir: (Quickshell.env("XDG_DATA_HOME") || Quickshell.env("HOME") + "/.local/share") + "/glassMxrph/plugins"
readonly property var pluginSources: []
function getPluginManifest(pluginId) {
const p = GS.PluginService.plugin(pluginId);
return p ? p.manifest : null;
}
function getPluginDir(pluginId) {
const p = GS.PluginService.plugin(pluginId);
return p ? p.dir : "";
}
function getAllInstalledPluginIds() {
return GS.PluginService.plugins.map(p => p.id);
}
function isPluginEnabled(pluginId) {
return GS.PluginService.isEnabled(pluginId);
}
function isMainSource(url) {
return true;
}
function getPluginSourceUrl(pluginId) {
const p = GS.PluginService.plugin(pluginId);
return p ? p.source : "";
}
function parseCompositeKey(key) {
return {
"pluginId": String(key),
"sourceHash": ""
};
}
function getSourceNameByHash(hash) {
return "";
}
function addPluginSource(name, url) {
}
function removePluginSource(url) {
}
function setSourceEnabled(url, enabled) {
}
}
@@ -0,0 +1,46 @@
pragma Singleton
import QtQuick
import Quickshell
import "../../../../services" as GS
// glassMxrph stand-in: Noctalia plugins talk to glassMxrph's plugin service.
Singleton {
readonly property bool initialized: GS.PluginService.loaded
readonly property bool pluginsFullyLoaded: GS.PluginService.loaded
readonly property var availablePlugins: []
readonly property var pluginUpdates: ({})
readonly property int pluginUpdatesPending: 0
readonly property var installingPlugins: ({})
readonly property int activeFetches: 0
function getPluginAPI(pluginId) {
return GS.PluginService.noctaliaApi(pluginId);
}
function hasPluginError(pluginId) {
return false;
}
function getPluginError(pluginId) {
return "";
}
function enablePlugin(pluginId) {
GS.PluginService.setEnabled(pluginId, true);
}
function disablePlugin(pluginId) {
GS.PluginService.setEnabled(pluginId, false);
}
function uninstallPlugin(pluginId) {
GS.PluginService.remove(pluginId);
}
function installPlugin(plugin) {
}
function updatePlugin(pluginId) {
}
function checkForUpdates() {
}
function refreshAvailablePlugins() {
}
function isPluginHotReloadEnabled(pluginId) {
return false;
}
function togglePluginHotReload(pluginId) {
}
}
@@ -0,0 +1,132 @@
pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Services.UPower
import qs.compat.noctalia.Commons
import qs.compat.noctalia.Services.UI
Singleton {
id: root
readonly property var powerProfiles: PowerProfiles
readonly property bool available: powerProfiles && powerProfiles.hasPerformanceProfile
property int profile: powerProfiles ? powerProfiles.profile : PowerProfile.Balanced
// Not a power profile but a volatile property to quickly disable shadows, animations, etc..
property bool noctaliaPerformanceMode: false
function getName(p) {
if (!available)
return "Unknown";
const prof = (p !== undefined) ? p : profile;
switch (prof) {
case PowerProfile.Performance:
return "Performance";
case PowerProfile.Balanced:
return "Balanced";
case PowerProfile.PowerSaver:
return "Power saver";
default:
return "Unknown";
}
}
function getIcon(p) {
if (!available)
return "balanced";
const prof = (p !== undefined) ? p : profile;
switch (prof) {
case PowerProfile.Performance:
return "performance";
case PowerProfile.Balanced:
return "balanced";
case PowerProfile.PowerSaver:
return "powersaver";
default:
return "balanced";
}
}
function init() {
Logger.d("PowerProfileService", "Service started");
}
function setProfile(p) {
if (!available)
return;
try {
powerProfiles.profile = p;
} catch (e) {
Logger.e("PowerProfileService", "Failed to set profile:", e);
}
}
function cycleProfile() {
if (!available)
return;
const current = powerProfiles.profile;
if (current === PowerProfile.Performance)
setProfile(PowerProfile.PowerSaver);
else if (current === PowerProfile.Balanced)
setProfile(PowerProfile.Performance);
else if (current === PowerProfile.PowerSaver)
setProfile(PowerProfile.Balanced);
}
function cycleProfileReverse() {
if (!available)
return;
const current = powerProfiles.profile;
if (current === PowerProfile.Performance)
setProfile(PowerProfile.Balanced);
else if (current === PowerProfile.Balanced)
setProfile(PowerProfile.PowerSaver);
else if (current === PowerProfile.PowerSaver)
setProfile(PowerProfile.Performance);
}
function isDefault() {
if (!available)
return true;
return (profile === PowerProfile.Balanced);
}
Connections {
target: powerProfiles
function onProfileChanged() {
root.profile = powerProfiles.profile;
// Only show toast if we have a valid profile name (not "Unknown")
const profileName = root.getName();
if (profileName !== "Unknown") {
ToastService.showNotice(I18n.tr("toast.power-profile.profile-name", {
"profile": profileName
}), I18n.tr("toast.power-profile.changed"), profileName.toLowerCase().replace(" ", ""));
}
}
}
// Noctalia Performance Mode
// - Turning shadow off
// - Turning animation off
// - Do Not Disturb
function toggleNoctaliaPerformance() {
noctaliaPerformanceMode = !noctaliaPerformanceMode;
}
function setNoctaliaPerformance(value) {
noctaliaPerformanceMode = value;
}
onNoctaliaPerformanceModeChanged: {
if (noctaliaPerformanceMode) {
ToastService.showNotice(I18n.tr("toast.noctalia-performance.label"), I18n.tr("toast.noctalia-performance.enabled"), "rocket");
} else {
ToastService.showNotice(I18n.tr("toast.noctalia-performance.label"), I18n.tr("toast.noctalia-performance.disabled"), "rocket-off");
}
}
}
@@ -0,0 +1,8 @@
pragma Singleton
import QtQuick
import Quickshell
// glassMxrph stand-in: notifications are handled outside the shell.
Singleton {
property bool doNotDisturb: false
}
@@ -0,0 +1,205 @@
pragma Singleton
import QtQuick
import Quickshell
import qs.compat.noctalia.Commons
Singleton {
id: root
// Map to track active sound players: resolvedPath -> MediaPlayer instance
property var activePlayers: ({})
// Check if QtMultimedia is available
property bool multimediaAvailable: false
// Container for dynamically created players
Item {
id: playersContainer
}
Component.onCompleted: {
// Test if QtMultimedia is available by trying to create a simple component
try {
var testComponent = Qt.createQmlObject(`
import QtQuick
import QtMultimedia
Item {}
`, root, "MultimediaTest");
if (testComponent) {
multimediaAvailable = true;
testComponent.destroy();
Logger.i("SoundService", "QtMultimedia found - sound playback enabled");
}
} catch (e) {
multimediaAvailable = false;
Logger.w("SoundService", "QtMultimedia not available - no audio will be played from noctalia-shell");
}
}
function resolvePath(soundPath) {
if (!soundPath || soundPath === "") {
return "";
}
let resolvedPath = soundPath;
// If it's just a filename (no path separators), assume it's in Assets/Sounds/
if (!soundPath.includes("/") && !soundPath.startsWith("file://")) {
resolvedPath = Quickshell.shellDir + "/Assets/Sounds/" + soundPath;
} else if (!soundPath.startsWith("/") && !soundPath.startsWith("file://")) {
// Relative path - assume it's relative to shellDir
resolvedPath = Quickshell.shellDir + "/" + soundPath;
} else if (soundPath.startsWith("file://")) {
resolvedPath = soundPath.substring(7); // Remove "file://" prefix
}
// Absolute paths are used as-is
return resolvedPath;
}
function playSound(soundPath, options) {
if (!soundPath || soundPath === "") {
Logger.w("SoundService", "No sound path provided");
return;
}
if (!multimediaAvailable) {
Logger.d("SoundService", "QtMultimedia not available, cannot play sound:", soundPath);
return;
}
const opts = options || {};
const volume = opts.volume !== undefined ? opts.volume : 1.0;
const fallback = opts.fallback !== undefined ? opts.fallback : false;
const repeat = opts.repeat !== undefined ? opts.repeat : false;
// Resolve path
const resolvedPath = resolvePath(soundPath);
// Stop any existing player for this path if it's looping
if (repeat && activePlayers[resolvedPath]) {
stopSound(soundPath);
}
// Create MediaPlayer instance dynamically with QtMultimedia import
const loopsValue = repeat ? "MediaPlayer.Infinite" : "1";
const escapedPath = resolvedPath.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
const playerQml = `
import QtQuick
import QtMultimedia
import Quickshell
import qs.compat.noctalia.Commons
import qs.compat.noctalia.Services.System
MediaPlayer {
id: mediaPlayer
property string resolvedPath: "${escapedPath}"
property bool shouldFallback: ${fallback && !repeat}
property real soundVolume: ${Math.max(0, Math.min(1, volume))}
source: "file://${escapedPath}"
loops: ${loopsValue}
audioOutput: AudioOutput {
volume: soundVolume
}
onErrorOccurred: {
Logger.w("SoundService", "Error playing sound:", source, error, errorString);
if (shouldFallback) {
const fallbackPath = Quickshell.shellDir + "/Assets/Sounds/notification.mp3";
if (fallbackPath !== resolvedPath) {
SoundService.playSound(fallbackPath, {
volume: soundVolume,
fallback: false,
repeat: false
});
}
}
if (SoundService.activePlayers[resolvedPath]) {
delete SoundService.activePlayers[resolvedPath];
}
destroy();
}
onPlaybackStateChanged: function (state) {
if (state === MediaPlayer.StoppedState && loops === 1) {
if (SoundService.activePlayers[resolvedPath]) {
delete SoundService.activePlayers[resolvedPath];
}
destroy();
}
}
Component.onCompleted: {
play();
}
}
`;
try {
const player = Qt.createQmlObject(playerQml, playersContainer, "MediaPlayer_" + resolvedPath.replace(/[^a-zA-Z0-9]/g, "_"));
if (!player) {
Logger.w("SoundService", "Failed to create MediaPlayer for:", resolvedPath);
// Try fallback if requested
if (fallback && !repeat) {
const defaultSound = Quickshell.shellDir + "/Assets/Sounds/notification.mp3";
if (defaultSound !== resolvedPath) {
playSound(defaultSound, {
volume: volume,
fallback: false,
repeat: false
});
}
}
return;
}
// Store player in activePlayers map
activePlayers[resolvedPath] = player;
Logger.d("SoundService", "Playing sound:", resolvedPath, `(volume: ${Math.round(volume * 100)}%)`, repeat ? "(repeat)" : "");
} catch (e) {
Logger.w("SoundService", "Failed to create MediaPlayer:", e);
// Try fallback if requested
if (fallback && !repeat) {
const defaultSound = Quickshell.shellDir + "/Assets/Sounds/notification.mp3";
if (defaultSound !== resolvedPath) {
playSound(defaultSound, {
volume: volume,
fallback: false,
repeat: false
});
}
}
}
}
function stopSound(soundPath) {
if (!multimediaAvailable) {
// If multimedia isn't available, there are no active players to stop
return;
}
if (soundPath) {
// Resolve path the same way as playSound
const resolvedPath = resolvePath(soundPath);
// Stop and remove the player for this specific sound
if (activePlayers[resolvedPath]) {
const player = activePlayers[resolvedPath];
player.stop();
delete activePlayers[resolvedPath];
player.destroy();
Logger.d("SoundService", "Stopped sound:", resolvedPath);
}
} else {
// Stop all active players (typically used for repeating sounds)
const paths = Object.keys(activePlayers);
for (let i = 0; i < paths.length; i++) {
const path = paths[i];
const player = activePlayers[path];
player.stop();
player.destroy();
}
activePlayers = {};
Logger.d("SoundService", "Stopped all sounds");
}
}
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,22 @@
pragma Singleton
import QtQuick
import Quickshell
import "../../../../core" as Core
import "../../../../services" as GS
// glassMxrph stand-in: the bar is glassMxrph's own top bar.
Singleton {
readonly property bool isVisible: true
property int widgetsRevision: 0
function getTooltipDirection(screenName) {
return "bottom";
}
function getPillDirection(widgetInstance) {
return !widgetInstance || widgetInstance.section !== "left";
}
// Plugin settings live in Settings → Plugins.
function openPluginSettings(screen, pluginManifest) {
GS.PluginService.focusedSettings = pluginManifest && pluginManifest.id ? pluginManifest.id : "";
Core.ShellState.openSettings("plugins");
}
}
@@ -0,0 +1,13 @@
pragma Singleton
import QtQuick
import Quickshell
// glassMxrph stand-in: Noctalia's built-in widget registry is not used.
Singleton {
property var widgets: ({})
property var widgetMetadata: ({})
property bool editMode: false
function hasWidget(id) {
return false;
}
}
@@ -0,0 +1,13 @@
pragma Singleton
import QtQuick
import Quickshell
// glassMxrph stand-in: Noctalia's built-in widget registry is not used.
Singleton {
property var widgets: ({})
property var widgetMetadata: ({})
property bool editMode: false
function hasWidget(id) {
return false;
}
}
@@ -0,0 +1,13 @@
pragma Singleton
import QtQuick
import Quickshell
// glassMxrph stand-in: Noctalia's built-in widget registry is not used.
Singleton {
property var widgets: ({})
property var widgetMetadata: ({})
property bool editMode: false
function hasWidget(id) {
return false;
}
}
@@ -0,0 +1,13 @@
pragma Singleton
import QtQuick
import Quickshell
// glassMxrph stand-in: Noctalia's built-in widget registry is not used.
Singleton {
property var widgets: ({})
property var widgetMetadata: ({})
property bool editMode: false
function hasWidget(id) {
return false;
}
}
@@ -0,0 +1,55 @@
pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Hyprland
import "../../../../core" as Core
// glassMxrph stand-in: context menus open where the plugin asks and close on
// an outside click (Hyprland focus grab); launcher calls use glassMxrph's.
Singleton {
id: root
property var openedPanel: null
property var lockScreen: null
property bool isKeybindRecording: false
property var menu: null
function showContextMenu(contextMenu, anchorItem, screen, targetItem) {
if (!contextMenu || !anchorItem)
return;
closeContextMenu(screen);
menu = contextMenu;
contextMenu.openAtItem(anchorItem, screen, targetItem);
Qt.callLater(() => grab.active = !!root.menu);
}
function closeContextMenu(screen) {
grab.active = false;
if (menu && typeof menu.close === "function")
menu.close();
menu = null;
}
function getPopupMenuWindow(screen) {
return null;
}
function getPanel(name, screen) {
return null;
}
function isLauncherOpen() {
return Core.ShellState.launcherOpen;
}
function closeLauncher() {
Core.ShellState.launcherOpen = false;
}
function openLauncherWithSearch(text) {
Core.ShellState.openLauncher();
}
function setLauncherSearchText(text) {
}
function getLauncherSearchText() {
return "";
}
HyprlandFocusGrab {
id: grab
windows: root.menu ? [root.menu] : []
onCleared: root.closeContextMenu(null)
}
}
@@ -0,0 +1,24 @@
pragma Singleton
import QtQuick
import Quickshell
// glassMxrph stand-in: Noctalia toasts become desktop notifications.
Singleton {
function notify(urgency, title, description, duration) {
Quickshell.execDetached(["notify-send", "-a", "glassMxrph", "-u", urgency, "-t", String(duration || 4000), String(title || ""), String(description || "")]);
}
function showNotice(title, description = "", icon = "", duration = 3000, actionLabel = "", actionCallback = null) {
notify("low", title, description, duration);
}
function showInfo(title, description = "", icon = "", duration = 3000) {
notify("low", title, description, duration);
}
function showWarning(title, description = "", duration = 4000, actionLabel = "", actionCallback = null) {
notify("normal", title, description, duration);
}
function showError(title, description = "", duration = 6000, actionLabel = "", actionCallback = null) {
notify("critical", title, description, duration);
}
function dismissToast() {
}
}
@@ -0,0 +1,40 @@
pragma Singleton
import QtQuick
import Quickshell
import "../../../../core" as Core
import "../../../../services" as GS
// glassMxrph stand-in: tooltips of bar widgets use the shell's hover popout
// (it hangs from the bar); tooltips elsewhere are not shown.
Singleton {
id: root
property var current: null
function inBar(target) {
const w = target && target.QsWindow ? target.QsWindow.window : null;
return !!w && GS.TrayService.barWindows.includes(w);
}
function show(target, content, direction, delay, fontFamily) {
if (!target || !content || !inBar(target))
return;
current = target;
Core.PopoutState.hover(target, "tooltip", String(content));
}
function hide(target) {
if (target && current !== target)
return;
if (current)
Core.PopoutState.unhover(current);
current = null;
}
function hideImmediately() {
current = null;
Core.PopoutState.close();
}
function updateContent(newContent) {
updateText(newContent);
}
function updateText(newText) {
if (current && Core.PopoutState.anchor === current)
Core.PopoutState.text = String(newText);
}
}
@@ -0,0 +1,29 @@
pragma Singleton
import QtQuick
import Quickshell
import "../../../../services" as GS
// glassMxrph stand-in for wallpaper queries.
Singleton {
readonly property bool isInitialized: true
readonly property var currentWallpapers: GS.ConfigService.ready ? GS.ConfigService.data.wallpaper.byMonitor : ({})
signal wallpaperProcessingComplete
function getWallpaper(screenName) {
return currentWallpapers[screenName] || "";
}
function getWallpapersEffectiveMap() {
return currentWallpapers;
}
function changeWallpaper(path, screenName) {
GS.WallpaperService.apply(path);
}
function isSolidColorPath(path) {
return String(path).startsWith("solid://");
}
function getSolidColor(path) {
return String(path).replace("solid://", "");
}
function getFillModeUniform() {
return 1;
}
}