Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

network-module.widget fails to show wifi icon at boot #262

Open
bdantas opened this issue Nov 19, 2024 · 5 comments
Open

network-module.widget fails to show wifi icon at boot #262

bdantas opened this issue Nov 19, 2024 · 5 comments

Comments

@bdantas
Copy link

bdantas commented Nov 19, 2024

I'm on 1.0_beta16. sfwbar starts slightly before my wifi is fully connected. The bar only shows a square with a smear where the wifi icon is expected (notice the first icon):
screenshot001
The expected icon shows up if I run pkill sfwbar; sleep 1; sfwbar & after wifi is connected:
screenshot002
Is there a way for the expected icon to show up without having to restart sfwbar?

@bdantas
Copy link
Author

bdantas commented Nov 19, 2024

P.S. This is what my ~/.config/sfwbar/network-module.widget looks like (it only differs from the upstream version by one line--the last one that implements LeftClick action):

module("network")
include("wifi.widget")

Set XNetworkWifiSvg = '<?xml version="1.0" encoding="UTF-8"?>
<svg version="1.1" id="_x31_0" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 512 512" style="width: 512px; height: 512px; opacity: 1;" xml:space="preserve">
<style type="text/css">
	.st0{fill:@theme_fg_color;}
	.st1{fill:@theme_fg_color;opacity:0.33;}
</style>
<g>
	<path class="st'+If(NetStat("signal")<30,"1","0")+'" d="M255.977,376.774c-12.118,0-23.098,4.918-31.043,12.867c-7.95,7.949-12.867,18.926-12.867,31.043
		c0,12.117,4.918,23.098,12.867,31.042c7.946,7.95,18.926,12.867,31.043,12.867c12.117,0,23.098-4.918,31.042-12.867
		c7.95-7.945,12.867-18.926,12.867-31.042c0-12.118-4.918-23.094-12.867-31.043C279.074,381.691,268.094,376.774,255.977,376.774z"></path>
	<path class="st'+If(NetStat("signal")<50,"1","0")+'" d="M155.371,304.555l38.934,39.015c17.562-14.082,39.082-21.73,61.641-21.73c22.648,0,44.179,7.598,61.691,21.582
		l38.875-38.879c-27.969-24.317-63.282-37.59-100.566-37.59C218.652,266.954,183.34,280.23,155.371,304.555z"></path>
	<path class="st'+If(NetStat("signal")<70,"1","0")+'" d="M77.645,226.836l38.828,38.902c38.496-34.691,87.61-53.672,139.473-53.672
		c51.961,0,101.098,18.922,139.531,53.516l38.855-38.856C385.5,181.793,322.578,157.18,255.946,157.18
		C189.344,157.18,126.453,181.832,77.645,226.836z"></path>
	<path class="st'+If(NetStat("signal")<90,"1","0")+'" d="M255.946,47.406C160.137,47.406,69.676,83.469,0,149.18l38.785,38.871
		c59.203-55.387,135.895-85.758,217.161-85.758c81.273,0,157.984,30.317,217.21,85.606L512,149.062
		C442.484,83.422,351.988,47.406,255.946,47.406z"></path>
</g></svg>'

Set XNetworkWirelessIcon = If(Ident(NetworkWirelessIcon),$NetworkWirelessIcon,$XNetworkWifiSvg)
Set XNetworkWiredIcon = If(Ident(NetworkWiredIcon),$NetworkWiredIcon,"network-wired")
Set XNetworkIcon = If(Ident(NetInfo),If(NetInfo("essid")!="",$XNetworkWirelessIcon,$XNetworkWiredIcon),"")

layout {
  style = "module"
  button {
    value = $XNetworkIcon
    trigger = "network"
    action = PopUp "XWifiWindow"
    tooltip = "<span face='Monospace'>" +
              "interface: " + Pad(NetInfo("interface"),20) + "\n" +
              "ip:        " + Pad(NetInfo("ip") + "/" + NetInfo("cidr"),20) +
                "\n" +
              "netmask:   " + Pad(NetInfo("mask"),20) + "\n" +
              "gateway:   " + Pad(NetInfo("gateway"),20) + "\n" +
              "essid:     " + Pad(NetInfo("essid"),20) + "\n" +
              "signal:    " + Pad(Str(NetStat("signal")) + "%",20) +
              "</span>"
    style = If(Ident(NetInfo),"module","hidden")
    action[LeftClick] = Exec "sudo wifi-connect"
  }
}

@LBCrion
Copy link
Owner

LBCrion commented Nov 20, 2024

The square with a smudge is a bit weird. If the module doesn't detect wifi, it displays a wired icon. Which is either specified by $NetworkWireIcon (if this variable is defined anywhere in your config) or network-wired icon as a fallback. Could it be that you have a weird network-wired icon installed somewhere in your icon theme or $NetworkWiredIcon defined in your config?

As to the the wireless detection on startup, detecting isn't straightforward. Currently the network module monitors the netlink interface for IFLA_WIRELESS updates and update the ESSID whenever one is received. In addition, the essid is updated whenever a new default gateway is added to a routing table. The wireless state is then determined by whether an ESSID has been obtained.

On startup, once your sfwbar is already running and wifi has started. Does your mahcine automatically connect to wifi (i.e. does your main internet connection goes through wifi) or do you still need to manually connect to it?

@01micko
Copy link
Contributor

01micko commented Nov 20, 2024

The square with a smudge is a bit weird.

Tipping that that is a wired (weird) network icon of some icon theme with -ScaleImage-color: some-color; applied.

Set XNetworkWiredIcon = If(Ident(NetworkWiredIcon),$NetworkWiredIcon,"network-wired")

@bdantas
Copy link
Author

bdantas commented Nov 20, 2024

Hi LBCrion. I do not define this icon anywhere in my config. The icon being used is whatever is the default.

If it helps, this problem did not occur on 1.0_beta15 on this same machine with same sfwbar configuration. It seems 1.0_beta16 is altering the default wired network icon in a strange way.

I'm on Tiny Core Linux so nothing happens automatically :) My machine is a laptop that never has a wired connection. One of my startup jobs is sfwbar. Another is a script that connects to wifi. The two jobs run at boot close together.

If we can't figure out what's being done to the default wired connection icon, I can try specifying full path to a different icon.

@bdantas
Copy link
Author

bdantas commented Nov 20, 2024

The problem seems to be that 1.0_beta16 is using a png and stretching it in a way that makes it look strange. If I specify path to any .png file, I get different weird shapes. My guess is that 1.0_beta15 was either using a png without stretching it, or else it was defaulting to using a .svg file.

Changing this line in ~/.config/sfwbar/network-module.widget:

    value = $XNetworkIcon

to this:

    value = "/usr/local/share/icons/Adwaita/symbolic/devices/network-wired-symbolic.svg"

makes the icon that shows up after boot be a recognizable wired network icon.

I would still prefer to see a wifi icon, but this is fine and it's what I was used to when running 1.0_beta15.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants