Autoformatting + cleanup

This commit is contained in:
Lemmy
2026-01-02 09:31:28 -05:00
parent f04f908a6d
commit 1a252b30a0
13 changed files with 690 additions and 695 deletions
@@ -1,8 +1,8 @@
#!/usr/bin/env bash
# BluetoothConnectionScript.sh
# bluetooth-connect.sh
# Pairs, trusts, and attempts to connect to a Bluetooth device using bluetoothctl.
# Usage: BluetoothConnectionScript.sh <addr> <pairWaitSeconds> <attempts> <intervalSec>
# Usage: bluetooth-connect.sh <addr> <pairWaitSeconds> <attempts> <intervalSec>
set -euo pipefail
+3 -6
View File
@@ -71,11 +71,7 @@ Item {
screen: root.screen
density: Settings.data.bar.density
oppositeDirection: BarService.getPillDirection(root)
icon: !BluetoothService.enabled
? "bluetooth-off"
: ((BluetoothService.connectedDevices && BluetoothService.connectedDevices.length > 0)
? "bluetooth-connected"
: "bluetooth")
icon: !BluetoothService.enabled ? "bluetooth-off" : ((BluetoothService.connectedDevices && BluetoothService.connectedDevices.length > 0) ? "bluetooth-connected" : "bluetooth")
text: {
if (BluetoothService.connectedDevices && BluetoothService.connectedDevices.length > 0) {
const firstDevice = BluetoothService.connectedDevices[0];
@@ -94,7 +90,8 @@ Item {
forceClose: isBarVertical || root.displayMode === "alwaysHide" || text === ""
onClicked: {
var p = PanelService.getPanel("bluetoothPanel", screen);
if (p) p.toggle(this);
if (p)
p.toggle(this);
}
onRightClicked: {
var popupMenuWindow = PanelService.getPopupMenuWindow(screen);
+1 -2
View File
@@ -216,8 +216,7 @@ Item {
if (!isNaN(idx)) {
MediaService.switchToPlayer(idx);
}
}
else if (action === "widget-settings") {
} else if (action === "widget-settings") {
BarService.openWidgetSettings(screen, section, sectionWidgetIndex, widgetId, widgetSettings);
}
}
@@ -134,10 +134,14 @@ NBox {
NText {
text: {
const k = BluetoothService.getStatusKey(modelData);
if (k === "pairing") return I18n.tr("bluetooth.panel.pairing");
if (k === "blocked") return I18n.tr("bluetooth.panel.blocked");
if (k === "connecting") return I18n.tr("bluetooth.panel.connecting");
if (k === "disconnecting") return I18n.tr("bluetooth.panel.disconnecting");
if (k === "pairing")
return I18n.tr("bluetooth.panel.pairing");
if (k === "blocked")
return I18n.tr("bluetooth.panel.blocked");
if (k === "connecting")
return I18n.tr("bluetooth.panel.connecting");
if (k === "disconnecting")
return I18n.tr("bluetooth.panel.disconnecting");
return "";
}
visible: text !== ""
@@ -8,15 +8,12 @@ import qs.Widgets
NIconButtonHot {
property ShellScreen screen
icon: !BluetoothService.enabled
? "bluetooth-off"
: ((BluetoothService.connectedDevices && BluetoothService.connectedDevices.length > 0)
? "bluetooth-connected"
: "bluetooth")
icon: !BluetoothService.enabled ? "bluetooth-off" : ((BluetoothService.connectedDevices && BluetoothService.connectedDevices.length > 0) ? "bluetooth-connected" : "bluetooth")
tooltipText: I18n.tr("quickSettings.bluetooth.tooltip.action")
onClicked: {
var p = PanelService.getPanel("bluetoothPanel", screen);
if (p) p.toggle(this);
if (p)
p.toggle(this);
}
onRightClicked: BluetoothService.setBluetoothEnabled(!BluetoothService.enabled)
}
+1 -5
View File
@@ -41,11 +41,7 @@ ColumnLayout {
description: I18n.tr("settings.network.bluetooth.rssi-polling.description")
checked: Settings.data && Settings.data.network && Settings.data.network.bluetoothRssiPollingEnabled
enabled: BluetoothService.enabled
onToggled: function(checked) {
if (Settings.data && Settings.data.network) {
Settings.data.network.bluetoothRssiPollingEnabled = checked;
}
}
onToggled: checked => Settings.data.network.bluetoothRssiPollingEnabled = checked
}
NDivider {
+2 -2
View File
@@ -287,7 +287,7 @@ ColumnLayout {
NToggle {
checked: modelData.enabled
baseSize: Style.baseWidgetSize * 0.7
onToggled: function (checked) {
onToggled: checked => {
if (checked) {
PluginService.enablePlugin(modelData.compositeKey);
} else {
@@ -382,7 +382,7 @@ ColumnLayout {
NToggle {
checked: modelData.enabled !== false // Default to true if not set
baseSize: Style.baseWidgetSize * 0.7
onToggled: function (checked) {
onToggled: checked => {
PluginRegistry.setSourceEnabled(modelData.url, checked);
PluginService.refreshAvailablePlugins();
ToastService.showNotice(I18n.tr("settings.plugins.title"), I18n.tr("settings.plugins.refresh.refreshing"));
@@ -493,11 +493,9 @@ ColumnLayout {
NToggle {
checked: modelData.countdownEnabled !== undefined ? modelData.countdownEnabled : true
onToggled: function (checked) {
root.updateEntry(delegateItem.index, {
onToggled: checked => root.updateEntry(delegateItem.index, {
"countdownEnabled": checked
});
}
})
}
}
@@ -418,9 +418,7 @@ ColumnLayout {
}
NToggle {
checked: Settings.data.bar.floating
onToggled: function (checked) {
Settings.data.bar.floating = checked;
}
onToggled: checked => Settings.data.bar.floating = checked
}
}
@@ -534,9 +532,7 @@ ColumnLayout {
}
NToggle {
checked: Settings.data.general.enableShadows
onToggled: function (checked) {
Settings.data.general.enableShadows = checked;
}
onToggled: checked => Settings.data.general.enableShadows = checked
}
}
+7 -4
View File
@@ -23,7 +23,9 @@ QtObject {
property Process rssiProcess: Process {
id: proc
running: false
stdout: StdioCollector { id: out }
stdout: StdioCollector {
id: out
}
onExited: function (exitCode, exitStatus) {
try {
var text = out.text || "";
@@ -35,8 +37,7 @@ QtObject {
root.version++;
}
}
} catch (e) {
} finally {
} catch (e) {} finally {
root._currentAddr = "";
}
}
@@ -63,7 +64,9 @@ QtObject {
return; // avoid overlap
root._currentAddr = addr;
proc.command = ["sh", "-c", `bluetoothctl info "${addr}"`];
try { proc.running = true; } catch (e) {}
try {
proc.running = true;
} catch (e) {}
}
}
}
+17 -12
View File
@@ -1,14 +1,14 @@
pragma Singleton
import QtQml
import QtQuick
import QtQml
import Quickshell
import Quickshell.Bluetooth
import Quickshell.Io
import "../../Helpers/BluetoothUtils.js" as BluetoothUtils
import "."
import qs.Commons
import qs.Services.UI
import "."
import "../../Helpers/BluetoothUtils.js" as BluetoothUtils
QtObject {
id: root
@@ -123,7 +123,8 @@ QtObject {
manualScanTimer.interval = durationMs;
manualScanTimer.restart();
} else {
if (manualScanTimer.running) manualScanTimer.stop();
if (manualScanTimer.running)
manualScanTimer.stop();
}
requestCtlPoll(ctlPollSoonMs);
}
@@ -183,7 +184,9 @@ QtObject {
property Process ctlShowProcess: Process {
id: ctlProc
running: false
stdout: StdioCollector { id: ctlStdout }
stdout: StdioCollector {
id: ctlStdout
}
onExited: function (exitCode, exitStatus) {
try {
var text = ctlStdout.text || "";
@@ -341,14 +344,17 @@ QtObject {
var p = getSignalPercent(device);
if (p === null)
return I18n.tr("bluetooth.panel.signal-text.unknown");
if (p >= 80) return I18n.tr("bluetooth.panel.signal-text.excellent");
if (p >= 60) return I18n.tr("bluetooth.panel.signal-text.good");
if (p >= 40) return I18n.tr("bluetooth.panel.signal-text.fair");
if (p >= 20) return I18n.tr("bluetooth.panel.signal-text.poor");
if (p >= 80)
return I18n.tr("bluetooth.panel.signal-text.excellent");
if (p >= 60)
return I18n.tr("bluetooth.panel.signal-text.good");
if (p >= 40)
return I18n.tr("bluetooth.panel.signal-text.fair");
if (p >= 20)
return I18n.tr("bluetooth.panel.signal-text.poor");
return I18n.tr("bluetooth.panel.signal-text.very-poor");
}
// Numeric helpers for UI rendering
function getSignalPercent(device) {
// Establish binding dependency so UI updates when RSSI cache changes
@@ -356,7 +362,6 @@ QtObject {
return BluetoothUtils.signalPercent(device, rssi.cache, _v);
}
function getBatteryPercent(device) {
return BluetoothUtils.batteryPercent(device);
}
@@ -428,7 +433,7 @@ QtObject {
_pauseDiscoveryFor(totalPauseMs);
// Prefer external dev script for pairing/connecting; executed detached
const scriptPath = Quickshell.shellDir + "/Bin/dev/BluetoothConnectionScript.sh";
const scriptPath = Quickshell.shellDir + "/Bin/bluetooth-connect.sh";
// Use bash explicitly to avoid relying on executable bit in all environments
btExec(["bash", scriptPath, String(addr), String(pairWait), String(attempts), String(intervalSec)]);
}