mirror of
https://github.com/end-4/dots-hyprland.git
synced 2026-06-05 23:09:26 -05:00
network: implement toggling in service
This commit is contained in:
@@ -12,22 +12,11 @@ import Quickshell.Hyprland
|
||||
QuickToggleButton {
|
||||
toggled: Network.wifiEnabled
|
||||
buttonIcon: Network.materialSymbol
|
||||
onClicked: {
|
||||
toggleNetwork.running = true
|
||||
}
|
||||
onClicked: Network.toggleWifi()
|
||||
altAction: () => {
|
||||
Quickshell.execDetached(["bash", "-c", `${Network.ethernet ? Config.options.apps.networkEthernet : Config.options.apps.network}`])
|
||||
GlobalStates.sidebarRightOpen = false
|
||||
}
|
||||
Process {
|
||||
id: toggleNetwork
|
||||
command: ["bash", "-c", "nmcli radio wifi | grep -q enabled && nmcli radio wifi off || nmcli radio wifi on"]
|
||||
onRunningChanged: {
|
||||
if(!running) {
|
||||
Network.update()
|
||||
}
|
||||
}
|
||||
}
|
||||
StyledToolTip {
|
||||
content: Translation.tr("%1 | Right-click to configure").arg(Network.networkName)
|
||||
}
|
||||
|
||||
@@ -26,6 +26,17 @@ Singleton {
|
||||
"signal_wifi_0_bar"
|
||||
) : "signal_wifi_off"
|
||||
|
||||
// Control
|
||||
function toggleWifi(): void {
|
||||
const cmd = wifiEnabled ? "off" : "on";
|
||||
enableWifiProc.exec(["nmcli", "radio", "wifi", cmd]);
|
||||
}
|
||||
|
||||
Process {
|
||||
id: enableWifiProc
|
||||
}
|
||||
|
||||
// Status update
|
||||
function update() {
|
||||
updateConnectionType.startCheck();
|
||||
wifiStatusProcess.running = true
|
||||
|
||||
Reference in New Issue
Block a user