Skip to content

Commit bf645ec

Browse files
committed
quickshell: fix warnings
1 parent 5fb94b9 commit bf645ec

7 files changed

Lines changed: 30 additions & 27 deletions

File tree

home/services/quickshell/bar/Battery.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ HoverTooltip {
2828

2929
source: {
3030
const nearestTen = Math.round(root.percentage / 10) * 10;
31-
const number = nearestTen.toString().padStart(2, "0");
31+
const number = nearestTen.toString();
3232
let charging;
3333

3434
if (root.battery.state == UPowerDeviceState.Charging) {

home/services/quickshell/bar/Network.qml

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,25 @@ import qs.utils
99
HoverTooltip {
1010
id: root
1111

12-
property NetworkDevice adapter: Networking.devices.values[0]
12+
property NetworkDevice adapter: Networking.devices?.values[0] ?? null
1313

14-
readonly property WifiNetwork activeNetwork: adapter.networks.values.find(network => network.connected)
14+
readonly property WifiNetwork activeNetwork: adapter?.networks?.values.find(network => network.connected) ?? null
1515

16-
visible: !!Networking.devices.values
16+
visible: !!Networking.devices?.values
1717

1818
readonly property string iconState: {
1919
if (!Networking.wifiHardwareEnabled)
2020
return "hardware-disabled";
2121
else if (!Networking.wifiEnabled)
2222
return "disabled";
23-
else if (adapter.state == DeviceConnectionState.Connecting || adapter.state == DeviceConnectionState.Disconnecting)
23+
else if (adapter?.state == DeviceConnectionState.Connecting || adapter?.state == DeviceConnectionState.Disconnecting)
2424
return "acquiring";
25-
else if (adapter.connected) {
25+
else if (adapter?.connected) {
2626
let strength = "good";
2727

28-
if (activeNetwork.signalStrength >= 0.66) {
28+
if (activeNetwork?.signalStrength >= 0.66) {
2929
strength = "good";
30-
} else if (activeNetwork.signalStrength >= 0.33) {
30+
} else if (activeNetwork?.signalStrength >= 0.33) {
3131
strength = "ok";
3232
} else {
3333
strength = "weak";
@@ -41,15 +41,12 @@ HoverTooltip {
4141
text: {
4242
if (!Networking.wifiEnabled)
4343
return "WiFi disabled";
44-
45-
else if (adapter.state == DeviceConnectionState.Connecting)
44+
else if (adapter?.state == DeviceConnectionState.Connecting)
4645
return `Connecting to ${activeNetwork.name}`;
47-
48-
else if (adapter.state == DeviceConnectionState.Disconnecting)
46+
else if (adapter?.state == DeviceConnectionState.Disconnecting)
4947
return `Disconnecting from ${activeNetwork.name}`;
50-
51-
else if (adapter.connected)
52-
return activeNetwork.name;
48+
else if (adapter?.connected)
49+
return activeNetwork?.name ?? null;
5350

5451
return "Disconnected";
5552
}

home/services/quickshell/bar/Workspaces.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ WrapperMouseArea {
7979
radius: height / 2
8080

8181
color: {
82-
ws.modelData.workspace ?? false ? Colors.monitorColors[ws.modelData.workspace?.monitor?.id] : Colors.bgBar;
82+
ws.modelData.workspace ?? false ? Colors.monitorColors[ws.modelData.workspace?.monitor?.id ?? 0] : Colors.bgBar;
8383
}
8484

8585
implicitHeight: parent.height
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
import qs.utils
22

33
Text {
4+
id: root
45
property real fill: 0
56
// property int grade: Colours.light ? 0 : -25
67
property int grade: -25
78

9+
readonly property int targetSize: font.pointSize
10+
readonly property int targetWeight: font.weight
11+
812
font.family: "Material Symbols Rounded"
913
font.pointSize: Config.iconSize + 1
1014
font.variableAxes: ({
1115
FILL: fill.toFixed(1),
1216
GRAD: grade,
13-
opsz: font.pixelSize,
14-
wght: font.weight
17+
opsz: root.targetSize,
18+
wght: root.targetWeight
1519
})
1620
}

home/services/quickshell/osd/OSD.qml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Scope {
1313
property string icon: ""
1414

1515
Connections {
16-
target: PipeWireState.defaultSink?.audio
16+
target: PipeWireState.defaultSink ? PipeWireState.defaultSink.audio : null
1717

1818
function update() {
1919
scope.osdVisible = true;
@@ -32,7 +32,7 @@ Scope {
3232
}
3333

3434
Connections {
35-
target: PipeWireState.defaultSource?.audio
35+
target: PipeWireState.defaultSource ? PipeWireState.defaultSource.audio : null
3636

3737
function update() {
3838
scope.osdVisible = true;

home/services/quickshell/utils/BrightnessState.qml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@ Singleton {
77
id: root
88

99
property real brightness: persist.brightness
10+
property bool interfaceReady: false
1011

1112
PersistentProperties {
1213
id: persist
1314
reloadableId: "persistedBrightness"
1415
property string screenInterface: ""
1516
readonly property string path: `/sys/class/backlight/${screenInterface}`
16-
readonly property int rawBrightness: Number(getRawBrightness.text());
17-
readonly property int max: Number(getMaxBrightness.text());
18-
readonly property real brightness: rawBrightness / max;
17+
readonly property int rawBrightness: screenInterface !== "" ? Number(getRawBrightness.text()) : 0
18+
readonly property int max: screenInterface !== "" ? Number(getMaxBrightness.text()) : 1
19+
readonly property real brightness: max > 0 ? rawBrightness / max : 0
1920
}
2021

2122
Process {
@@ -25,20 +26,21 @@ Singleton {
2526
command: ["sh", "-c", "ls -w1 /sys/class/backlight | head -1"]
2627
stdout: SplitParser {
2728
onRead: data => {
28-
persist.screenInterface = data;
29+
persist.screenInterface = data.trim();
30+
root.interfaceReady = true;
2931
}
3032
}
3133
}
3234

3335
FileView {
3436
id: getMaxBrightness
35-
path: `${persist.path}/max_brightness`
37+
path: !!persist.screenInterface && root.interfaceReady ? `${persist.path}/max_brightness` : ""
3638
blockLoading: true
3739
}
3840

3941
FileView {
4042
id: getRawBrightness
41-
path: `${persist.path}/brightness`
43+
path: !!persist.screenInterface && root.interfaceReady ? `${persist.path}/brightness` : ""
4244
blockLoading: true
4345

4446
watchChanges: true

home/services/quickshell/utils/NotificationState.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Singleton {
8282
notif.tracked = true;
8383
notif.time = Date.now();
8484
root.onNewNotif(notif);
85-
console.log("notif: appName", notif.appName || "null", ", appIcon", notif.appIcon || "null", ", image", notif.image || "null", ", expireTimeout", notif.expireTimeout)
85+
// console.log("notif: appName", notif.appName || "null", ", appIcon", notif.appIcon || "null", ", image", notif.image || "null", ", expireTimeout", notif.expireTimeout)
8686

8787
notif.closed.connect(() => {
8888
notifDismissByNotif(notif);

0 commit comments

Comments
 (0)