forked from Shinonome/dots-hyprland
network: implement toggling in service
This commit is contained in:
@@ -12,22 +12,11 @@ import Quickshell.Hyprland
|
|||||||
QuickToggleButton {
|
QuickToggleButton {
|
||||||
toggled: Network.wifiEnabled
|
toggled: Network.wifiEnabled
|
||||||
buttonIcon: Network.materialSymbol
|
buttonIcon: Network.materialSymbol
|
||||||
onClicked: {
|
onClicked: Network.toggleWifi()
|
||||||
toggleNetwork.running = true
|
|
||||||
}
|
|
||||||
altAction: () => {
|
altAction: () => {
|
||||||
Quickshell.execDetached(["bash", "-c", `${Network.ethernet ? Config.options.apps.networkEthernet : Config.options.apps.network}`])
|
Quickshell.execDetached(["bash", "-c", `${Network.ethernet ? Config.options.apps.networkEthernet : Config.options.apps.network}`])
|
||||||
GlobalStates.sidebarRightOpen = false
|
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 {
|
StyledToolTip {
|
||||||
content: Translation.tr("%1 | Right-click to configure").arg(Network.networkName)
|
content: Translation.tr("%1 | Right-click to configure").arg(Network.networkName)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,17 @@ Singleton {
|
|||||||
"signal_wifi_0_bar"
|
"signal_wifi_0_bar"
|
||||||
) : "signal_wifi_off"
|
) : "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() {
|
function update() {
|
||||||
updateConnectionType.startCheck();
|
updateConnectionType.startCheck();
|
||||||
wifiStatusProcess.running = true
|
wifiStatusProcess.running = true
|
||||||
|
|||||||
Reference in New Issue
Block a user