Aylur / ags

A customizable and extensible shell
GNU General Public License v3.0
2.23k stars 116 forks source link

Icons not updating on change in wifi state #547

Open yashranjan1 opened 2 months ago

yashranjan1 commented 2 months ago

When i turn off my wifi using either the terminal or the UI button I have made, the UI icons and label do not seem to be updating. However, when I switch it on using either the terminal or the the UI button, both of them update. On reloading the widget, all states are initially correct but do not update. I think I just haven't implemented the bind function well, but I have gone over the documentation multiple times and cant figure out whats wrong. Thanks for your time

const Wifi = () => {   

    return Widget.Box({
        spacing: 8,
        children: [
            Widget.Button({
                on_clicked: ()=>{ {
                    if (network.wifi.enabled){
                        network.wifi.enabled = false
                    }
                    else {
                        network.wifi.enabled = true
                    }
                } },
                child: Widget.Box({
                    children: [
                        Widget.Icon({
                            icon: network.wifi.bind("icon_name")
                        }),
                        Widget.Label({
                            label: network.wifi.bind("ssid").as(ssid => ssid || "Not Connected")
                        })
                    ]
                })
            })
        ],
        hexpand: true,
        class_name: 'section shortcut-menu-item'
    })
}
yashranjan1 commented 2 months ago

I substituted bind with hook and it seems to be working right now, seems more likely that it is a problem with implementation.

adminy commented 1 month ago

my icon stays as a crossed out wifi, I'm not using network manager, instead I am using iwd, and connected using iwctl station commands.

getting the following errors in the logs:

JS ERROR: TypeError: this._device is undefined
get access_points@resource:///com/github/Aylur/ags/service/network.js:135:9
WifiSelection/setup/<@file:///tmp/asztal/main.js:3541:46
hook/id<@resource:///com/github/Aylur/ags/widgets/widget.js:36:21
changed@resource:///com/github/Aylur/ags/service.js:53:14
Wifi/<@resource:///com/github/Aylur/ags/service/network.js:96:69
_init/GLib.MainLoop.prototype.runAsync/</<@resource:///org/gnome/gjs/modules/core/overrides/GLib.js:266:34

There are more errors, unrelated to this:


Sep 09 10:45:34 box .ags-wrapped[142016]: JS ERROR: Error: Wrong type undefined; string expected
_size@resource:///com/github/Aylur/ags/widgets/icon.js:70:13
set icon@resource:///com/github/Aylur/ags/widgets/icon.js:55:14
bind/callback<@resource:///com/github/Aylur/ags/widgets/widget.js:53:30
hook/<@resource:///com/github/Aylur/ags/widgets/widget.js:43:25
_init/GLib.MainLoop.prototype.runAsync/</<@resource:///org/gnome/gjs/modules/core/overrides/GLib.js:266:34
Sep 09 10:45:34 box .ags-wrapped[142016]: value "-0.070000" of type 'gdouble' is invalid or out of range for property 'value' of type 'gdouble'
Sep 09 10:45:34 box .ags-wrapped[142016]: value "-0.070000" of type 'gdouble' is invalid or out of range for property 'value' of type 'gdouble'
Sep 09 10:45:34 box .ags-wrapped[142016]: value "-0.070000" of type 'gdouble' is invalid or out of range for property 'value' of type 'gdouble'
yashranjan1 commented 1 month ago

getting the following errors in the logs:

Just to make sure i understand, are you using the in-built network service? If yes, the in-built service has a network-manager listed as a dependency

adminy commented 1 month ago

No I didn't have network-manager enabled. I enabled it and that seems to have solved the issue. network manager was broken for me for weeks, so I had to manually connect to wifi.