nwg-piotr / nwg-panel

GTK3-based panel for sway and Hyprland Wayland compositors
MIT License
630 stars 44 forks source link

[BUG] duplicate panels after edit with `nwg-panel-config` #93

Closed matthis-k closed 2 years ago

matthis-k commented 2 years ago

Describe the bug more than one panel

To Reproduce Steps to reproduce the behavior:

  1. open nwg-panel-config
  2. Change a setting (eg remove modules on the right)
  3. click Save & restart
  4. now there should be 2 panels

Expected behavior The current one gets terminated and the new one starts

Screenshots image

Desktop (please complete the following information):

Additional context Can provide if needed

nwg-piotr commented 2 years ago

Well, it's not that easy. It happens to me sometimes, but I haven't yet managed to make it happen on demand. The steps you described above don't reproduce the misbehavior on my machine. Further investigation needed.

matthis-k commented 2 years ago

I just also tested it on my desktop machine: also duplicates. Here the terminal output from nwg-panel-config that might be useful to you and a screenshot afterwards:

Running on sway
28 signal received
17 signal received
Restarting panels
Dependencies check: {'light': True, 'brightnessctl': True, 'pamixer': True, 'pactl': True, 'playerctl': True, 'netifaces': True, 'btmgmt': True, 'wlr-randr': False, 'upower': True, 'swaync': True}
Running instance killed, PID 2628553
Running on sway
Output: HDMI-A-1, position: bottom, layer: bottom, width: 1920, height: 30
Output: HDMI-A-1, position: top, layer: bottom, width: 1920, height: 30
Command 'upower -i $(upower -e | grep devices/battery) | grep --color=never -E 'state|to\ full|to\ empty|percentage'' returned non-zero exit status 1.
Output: DP-1, position: top, layer: bottom, width: 1920, height: 30
28 signal received
host.init(): running dasbus.EventLoop
Exception in thread Thread-14 (init):
Traceback (most recent call last):
  File "/usr/lib/python3.10/threading.py", line 1009, in _bootstrap_inner
    self.run()
StatusNotifierHostInterface -> watcher_available_handler
  File "/usr/lib/python3.10/threading.py", line 946, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/lib/python3.10/site-packages/nwg_panel/modules/sni_system_tray/watcher.py", line 214, in init
    session_bus.register_service(WATCHER_SERVICE_NAME)
  File "/usr/lib/python3.10/site-packages/dasbus/connection.py", line 262, in register_service
    raise ConnectionError("Name request has failed: {}".format(result))
ConnectionError: Name request has failed: 2
No backlight controller was found, so we could not decide an automatic target. The current command will have no effect. Please use -L to find a target and then specify it with -s.

Command 'upower -i $(upower -e | grep devices/battery) | grep --color=never -E 'state|to\ full|to\ empty|percentage'' returned non-zero exit status 1.
No backlight controller was found, so we could not decide an automatic target. The current command will have no effect. Please use -L to find a target and then specify it with -s.

2022-02-27-164824_screenshot

matthis-k commented 2 years ago

Note: I just noticed I also click apply, otherwise there is no duplication. Edit: Never mind, it seems to be rather random, just try it a few times. It also seems to work without an edit. As you can see here, the first time it just refreshes one of the bars, then it adds another one.

2022-02-27 17-01-37

nwg-piotr commented 2 years ago

This is damned difficult to nail. I've just pressed "Save & restart" 50 times in a row, to no avail.

matthis-k commented 2 years ago

Maybe try using a different preset? I think the active one is preset 0 and i am starting preset 1.

nwg-piotr commented 2 years ago

I use preset-0 99% of time, and the bug shows up occasionally, say once 2 days. I think it must be located somewhere in main.py lines 290 - 299. I'll get back to the issue as soon as I finish what I'm working on now.

JDPDO commented 2 years ago

I've got the problem sometimes too, no matter what preset or custom config.

Maybe it helps to know, that killall nwg-panel only works if the described behaviour isn't present. If the panel gets duplicated only killall -S SIGKILL nwg-panel works. So maybe its something with the SIGTERM-handlers at line 76?

nwg-piotr commented 2 years ago

Good point. I'll take a closer look at it soon. Sorry for the delay. I've been struggling with several dozen of lines of code since Thursday, and got it to work last night at 4 am. Need to test them while I still understand how the hell it works. ;)

nwg-piotr commented 2 years ago

Hopefully it should be fixed now (on the timeout branch). I'll test till tomorrow and merge, if nothing unexpected happens.

JDPDO commented 2 years ago

Is'nt this bug fixed in merge f5622e1a35e63840fb1826a2ef35a8edb9dfcbc2?

nwg-piotr commented 2 years ago

That's what I meant.