Let Ethernet be switched off and on
Wi-Fi had a switch and wired did not, which left no way to take the cable down without reaching for nmcli -- and this machine has two interfaces on one subnet, so turning one off is a genuinely useful thing to be able to do. Both halves are needed to turn it off. Disconnecting alone survives the session but not a carrier event or a reboot, because NetworkManager brings an autoconnecting device straight back; the switch sets the device's autoconnect alongside it. The device property rather than the connection profile, so a toggle here does not quietly rewrite a saved connection somebody expects to come up at boot. The first version built a trap door. It decided whether the switch was usable from hasLink, which reads false while a device is merely disconnected even though NetworkManager still reports the carrier as on -- so turning Ethernet off made the switch disable itself, blame the cable, and offer no way back. A wired device that exists can always be asked to come up; if there is really no cable the attempt fails and says so, which is the honest failure. The word "off" is used where the old text guessed "no cable", because nothing available here can tell those apart. Verified as a round trip against the real device, including that off stays off through eight seconds rather than reconnecting a moment later, and that the mechanism tested is the one the code uses -- the first test drove the connection profile while the code drives the device, which are different things. Claude-Session: https://claude.ai/code/session_01BRvzt4H8XXLPVH5MyYdk9L
This commit is contained in:
@@ -107,6 +107,27 @@ Item {
|
||||
onExpanded: root.expand("wifi")
|
||||
}
|
||||
|
||||
// Only present when there is a wired device at all -- most machines
|
||||
// this runs on have one, but a laptop without a dock does not, and
|
||||
// an Ethernet tile there would be a control for absent hardware.
|
||||
Toggle {
|
||||
width: root.cellWidth
|
||||
visible: Connectivity.wiredDevice !== null
|
||||
icon: Connectivity.wiredOn
|
||||
? "network-wired-symbolic"
|
||||
: "network-wired-disconnected-symbolic"
|
||||
label: "Ethernet"
|
||||
active: Connectivity.wiredOn
|
||||
enabled: Connectivity.wiredAvailable
|
||||
sublabel: {
|
||||
if (Connectivity.wiredOn)
|
||||
return Connectivity.wiredDevice.linkSpeed > 0
|
||||
? Connectivity.wiredDevice.linkSpeed + " Mb/s" : "Connected";
|
||||
return "Off";
|
||||
}
|
||||
onToggled: Connectivity.setWired(!Connectivity.wiredOn)
|
||||
}
|
||||
|
||||
Toggle {
|
||||
width: root.cellWidth
|
||||
icon: root.btAdapter && root.btAdapter.enabled ? "bluetooth-active-symbolic" : "bluetooth-disabled-symbolic"
|
||||
|
||||
Reference in New Issue
Block a user