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

[Bug]: Action triggers button does not respond to clicks after polybar reloads #3007

Open
5 tasks done
rayshabh opened this issue Sep 5, 2023 · 8 comments
Open
5 tasks done

Comments

@rayshabh
Copy link

rayshabh commented Sep 5, 2023

Checklist

  • I have read the appropriate section in the contributing guidelines
  • I believe this issue is a problem with polybar itself and not a misconfiguration on my part
  • I have searched for other open and closed issues that may have already reported this problem
  • I have checked the known issues page for this problem.
  • I have followed the debugging guide to narrow down the problem to a minimal config.

Steps to reproduce

Problem occurs only when using dual monitors. When screenchange-reload = True and I plug out external monitor, then polybar shuts the external monitor bar and reloads only the main bar for the primary monitor. Polybar does this efficiently but the problems starts when trying to perform certain Action Button Triggers such as systemctl poweroff or systemctl reboot.
The polybar successfully terminates the external monitor bar and reloads the main bar but the Action buttons does not perform any actions when clicked.

This problem only occurs when External Monitor is plugged out in between, else everything works good!

Minimal config

[bar/main]
monitor = eDP-1
modules-left = workspaces sep cpu memory filesystem
modules-center = date weather
modules-right = network sep pulseaudio sep powermenu

[bar/externalMonitor]
monitor = HDMI-1
inherit = bar/main

[module/powermenu]
type = custom/menu
expand-right = true
menu-0-0 = " Reboot %{F#141414}%{T2}|%{T-}%{F-}"
menu-0-0-exec = #powermenu.open.1
menu-0-1 = " Shutdown"
menu-0-1-exec = #powermenu.open.2
menu-1-0 = " Reboot"
menu-1-0-exec = systemctl reboot
menu-2-0 = " Shutdown"
menu-2-0-exec = systemctl poweroff
format = <label-toggle><menu>

label-open = "%{T2}⏻%{T-}"
label-open-foreground = ${colors.red}
label-open-padding = 0
label-close = "%{T2}«%{T-}"
label-close-foreground = ${colors.red}
label-close-padding = 0

Polybar log

No response

Expected behavior

Whenever I plug out the External Monitor, the polybar must terminates the external monitor bar and reload the main bar for the primary monitor and all action buttons must work.

Actual behavior

When the external monitor is plugged out, the polybar terminates the external monitor bar and reload the main bar but the actions buttons stops working, i.e. when clicked, the buttons does not perform any actions.

Note: I use autorandr to auto switch the display profile. To get the action buttons working, I have a postswitch script which executes i3-msg restart.

Window Manager and Version

i3 version 4.22 (2023-01-02)

Linux Distribution

Arch Linux

Polybar version

polybar 3.6.3

Features: +alsa +curl +i3 +mpd +network(libnl) +pulseaudio +xkeyboard

X extensions: +randr (+monitors) +composite +xkb +xrm +xcursor

Build type: Release
Compiler: /usr/bin/c++
Compiler flags: -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions         -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security         -fstack-clash-protection -fcf-protection -Wp,-D_GLIBCXX_ASSERTIONS -g -ffile-prefix-map=/build/polybar/src=/usr/src/debug/polybar -flto=auto -O3 -DNDEBUG -Wall -Wextra -Wpedantic -Wsuggest-override
Linker flags: -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -flto=auto -Wall -Wextra -Wpedantic -Wsuggest-override  -Wall -Wextra -Wpedantic -Wsuggest-override

Additional Context / Screenshots

No response

@patrick96
Copy link
Member

patrick96 commented Sep 10, 2023

The restarted polybar is probably obscured by something, try setting wm-restack = i3. If that doesn't help please post the output of xwininfo -tree -root before (when it is working) and after (when it is not). This will include a list of all windows, so maybe run it when you only have polybar running.

EDIT: wm-restack = i3, not true

@rayshabh
Copy link
Author

rayshabh commented Sep 10, 2023

The restarted polybar is probably obscured by something, try setting wm-restack = i3. If that doesn't help please post the output of xwininfo -tree -root before (when it is working) and after (when it is not). This will include a list of all windows, so maybe run it when you only have polybar running.

EDIT: wm-restack = i3, not true

should i set it to false or should i just comment it so the setting is disable?
I mean
wm-restack = false or ; wm-restack = i3 or wm-restack = ??

@patrick96
Copy link
Member

I suggested setting wm-restack = i3 since you don't have the setting in your config (true or false don't have a meaning here, that was an error on my part)

@rayshabh
Copy link
Author

wm-restack = i3 is already set in my config.

Here's my config, please have a look and specify where I need to make changes to counter the problem.

;; Global WM Settings

[global/wm]
; Adjust the _NET_WM_STRUT_PARTIAL top value
; Used for top aligned bars
margin-bottom = 0

; Adjust the _NET_WM_STRUT_PARTIAL bottom value
; Used for bottom aligned bars
margin-top = 0

;; _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_

;; File Inclusion
; include an external file, like module file, etc.

include-file = ~/.config/polybar/includes/colors.ini
include-file = ~/.config/polybar/includes/modules.ini
include-file = ~/.config/polybar/includes/user-modules.ini

;; _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_

;; Bar Settings

[bar/main]
; Use either of the following command to list available outputs:
; If unspecified, the application will pick the first one it finds.
; $ polybar -m | cut -d ':' -f 1
; $ xrandr -q | grep " connected" | cut -d ' ' -f1
monitor = eDP-1

; Use the specified monitor as a fallback if the main one is not found.
monitor-fallback =

; Require the monitor to be in connected state
; XRandR sometimes reports my monitor as being disconnected (when in use)
monitor-strict = false

; Tell the Window Manager not to configure the window.
; Use this to detach the bar if your WM is locking its size/position.
override-redirect = true

; Put the bar at the bottom of the screen
bottom = false

; Prefer fixed center position for the `modules-center` block
; When false, the center position will be based on the size of the other blocks.
fixed-center = true

; Dimension defined as pixel value (e.g. 35) or percentage (e.g. 50%),
; the percentage can optionally be extended with a pixel offset like so:
; 50%:-10, this will result in a width or height of 50% minus 10 pixels
;
; To match the width of your Polybar with your i3-gaps window width, you can use the following formula:
; width = Screen width - (2 * inner gaps)
; For example, if your screen resolution is 1366 x 768 and you have inner gaps of 7 pixels on each side, the calculation would be:
; width = 1366 - (2 * 7)
width = 1352
height = 22

; Offset defined as pixel value (e.g. 35) or percentage (e.g. 50%)
; the percentage can optionally be extended with a pixel offset like so:
; 50%:-10, this will result in an offset in the x or y direction 
; of 50% minus 10 pixels
; To match the width of your Polybar with your i3-gaps window width, you must set the value of offset-x:
; offset-x = value of inner gaps
offset-x = 7
offset-y = 5

; Background ARGB color (e.g. #f00, #ff992a, #ddff1023)
background = ${colors.background}

; Foreground ARGB color (e.g. #f00, #ff992a, #ddff1023)
foreground = ${colors.foreground}

; Background gradient (vertical steps)
;   background-[0-9]+ = #aarrggbb
;;background-0 = 

; Value used for drawing rounded corners
; Note: This shouldn't be used together with border-size because the border 
; doesn't get rounded
; Individual top/bottom values can be defined using:
;   radius-{top,bottom}
radius-top = 0.0
radius-bottom = 0.0

; Under-/overline pixel size and argb color
; Individual values can be defined using:
;   {overline,underline}-size
;   {overline,underline}-color
line-size = 0
line-color = ${colors.background}

; Values applied to all borders
; Individual side values can be defined using:
;   border-{left,top,right,bottom}-size
;   border-{left,top,right,bottom}-color
; The top and bottom borders are added to the bar height, so the effective
; window height is:
;   height + border-top-size + border-bottom-size
; Meanwhile the effective window width is defined entirely by the width key and
; the border is placed withing this area. So you effectively only have the
; following horizontal space on the bar:
;   width - border-right-size - border-left-size
border-bottom-size = 0
border-bottom-color = ${colors.foreground}

; Number of spaces to add at the beginning/end of the bar
; Individual side values can be defined using:
;   padding-{left,right}
;padding = 2
padding-left = 1
padding-right = 1

; Number of spaces to add before/after each module
; Individual side values can be defined using:
;   module-margin-{left,right}
module-margin-left = 0
module-margin-right = 1

;; _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_

; Fonts are defined using <font-name>;<vertical-offset>
; Font names are specified using a fontconfig pattern.
; See the Fonts wiki page for more details

font-0 = MonoLisa:weight=book:size=12;3
font-1 = Font Awesome 6 Pro:style=Solid:size=11;3
font-2 = IBMPlexSansJP:weight=bold:size=11;3
font-3 = feather:weight=bold:size=11;4
font-4 = MonoLisa:weight=bold:size=12;3

;font-5 = DejaVuSansM Nerd Font:weight=book:size=12;3

; Modules are added to one of the available blocks
modules-left = workspaces sep cpu memory filesystem
modules-center = date weather
modules-right = network sep pulseaudio sep powermenu

;; _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_

; The separator will be inserted between the output of each module
;separator = |

; Opacity value between 0.0 and 1.0 used on fade in/out
dim-value = 1.0

; Value to be used to set the WM_NAME atom
; If the value is empty or undefined, the atom value
; will be created from the following template: polybar-[BAR]_[MONITOR]
; NOTE: The placeholders are not available for custom values
wm-name = i3-wm

; Locale used to localize various module data (e.g. date)
; Expects a valid libc locale, for example: sv_SE.UTF-8
locale = 

; Position of the system tray window
; If empty or undefined, tray support will be disabled
; NOTE: A center aligned tray will cover center aligned modules
;
; Available positions:
;   left
;   center
;   right
;   none
tray-position = none

; If true, the bar will not shift its
; contents when the tray changes
tray-detached = false

; Tray icon max size
tray-maxsize = 16

; Background color for the tray container 
; ARGB color (e.g. #f00, #ff992a, #ddff1023)
; By default the tray container will use the bar
; background color.
tray-background = ${colors.background}

; Tray offset defined as pixel value (e.g. 35) or percentage (e.g. 50%)
tray-offset-x = 0
tray-offset-y = 0

; Pad the sides of each tray icon
tray-padding = 0

; Scale factor for tray clients
tray-scale = 1.0

; Restack the bar window and put it above the
; selected window manager's root
;
; Fixes the issue where the bar is being drawn
; on top of fullscreen window's
;
; Currently supported WM's:
;   bspwm
;   i3 (requires: `override-redirect = true`)
wm-restack = i3

; Set a DPI values used when rendering text
; This only affects scalable fonts
; dpi = 

; Enable support for inter-process messaging
; See the Messaging wiki page for more details.
enable-ipc = true

; Fallback click handlers that will be called if
; there's no matching module handler found.
click-left = 
click-middle = 
click-right =
scroll-up =
scroll-down =
double-click-left =
double-click-middle =
double-click-right =

; Requires polybar to be built with xcursor support (xcb-util-cursor)
; Possible values are:
; - default   : The default pointer as before, can also be an empty string (default)
; - pointer   : Typically in the form of a hand
; - ns-resize : Up and down arrows, can be used to indicate scrolling
cursor-click = 
cursor-scroll = 

;; WM Workspace Specific

; bspwm
;;scroll-up = bspwm-desknext
;;scroll-down = bspwm-deskprev
;;scroll-up = bspc desktop -f prev.local
;;scroll-down = bspc desktop -f next.local

;i3
;;scroll-up = i3wm-wsnext
;;scroll-down = i3wm-wsprev
;;scroll-up = i3-msg workspace next_on_output
;;scroll-down = i3-msg workspace prev_on_output

;; _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_

;; External Monitor

[bar/externalMonitor]
monitor = HDMI-1
inherit = bar/main

;; _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_

;; Application Settings

[settings]
; The throttle settings lets the eventloop swallow up till X events
; if they happen within Y millisecond after first event was received.
; This is done to prevent flood of update event.
;
; For example if 5 modules emit an update event at the same time, we really
; just care about the last one. But if we wait too long for events to swallow
; the bar would appear sluggish so we continue if timeout
; expires or limit is reached.
throttle-output = 5
throttle-output-for = 10

; Time in milliseconds that the input handler will wait between processing events
;throttle-input-for = 30

; Reload upon receiving XCB_RANDR_SCREEN_CHANGE_NOTIFY events
screenchange-reload = false

; Compositing operators
; @see: https://www.cairographics.org/manual/cairo-cairo-t.html#cairo-operator-t
compositing-background = source
compositing-foreground = over
compositing-overline = over
compositing-underline = over
compositing-border = over

; Define fallback values used by all module formats
;format-foreground = 
;format-background = 
;format-underline =
;format-overline =
;format-spacing =
;format-padding =
;format-margin =
;format-offset =

; Enables pseudo-transparency for the bar
; If set to true the bar can be transparent without a compositor.
pseudo-transparency = false

;; _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_

@rayshabh
Copy link
Author

Currently, I have set screenchange-reload = false, to fix the action button issue. Every time the autorandr profile is switched, a postscript is executed which restarts my i3 using i3-msg restart command which also reloads my polybar as it is running as dex application.

@patrick96
Copy link
Member

I see. I assumed you were using the config you originally posted.

In that case, try one of the following:

  • Turn off wm-restack (remove the setting)
  • Turn off override-redirect (remove or set to false)

If that doesn't work, please post the output of xwininfo -tree -root before and after unplugging your monitor, so we can figure out what is blocking the bar.

@rayshabh
Copy link
Author

I see. I assumed you were using the config you originally posted.

In that case, try one of the following:

* Turn off `wm-restack` (remove the setting)

* Turn off `override-redirect` (remove or set to `false`)

If that doesn't work, please post the output of xwininfo -tree -root before and after unplugging your monitor, so we can figure out what is blocking the bar.

Okay, as you suggested, I've made the necessary changes in my config.ini and rebooted the system.
Following are the cases, please go thru it once.

Case: 1 Turning off wm-restack and setting override-redirect = false

Observation: After rebooting the system with external monitor connected, the polybar loads both the bars (i.e. main bar & external bar) correctly at the correct monitor locations (i.e. eDP-1 & HDMI-1).
The only weird thing I observed that when setting override-redirect = false, the polybar fails to preserve bar offset values (i.e. offset-x and offset-y). The bar simply stays to the left of the display.

Now output of xwininfo -tree -root before and after unplugging the external monitor.

Case: 1.1 Output after performing clean reboot without disconnecting external monitor:

xwininfo: Window id: 0x68e (the root window) "i3"

  Root window id: 0x68e (the root window) "i3"
  Parent window id: 0x0 (none)
     39 children:
     0x1a00062 "[Bug]: Action triggers button does not respond to clicks after polybar reloads · Issue #3007 · polybar/polybar": ("Firefox" "firefox")  587x70+663+133  +663+133
        1 child:
        0x1a00063 (has no name): ()  1x1+-1+-1  +662+132
     0x1a000aa "Feb 11, 2022, 11:23 PM GMT+5:30": ("Firefox" "firefox")  244x49+448+409  +448+409
        1 child:
        0x1a000ab (has no name): ()  1x1+-1+-1  +447+408
     0x1a00070 "Firefox": ("Firefox" "firefox")  306x316+463+360  +463+360
        1 child:
        0x1a00099 (has no name): ()  1x1+-1+-1  +462+359
     0x1a00066 "Firefox": ("firefox" "firefox")  200x200+0+0  +0+0
        1 child:
        0x1a0006d (has no name): ()  1x1+-1+-1  +-1+-1
     0x2800000 (has no name): ()  1x1+0+0  +0+0
     0x2600000 (has no name): ()  1x1+0+0  +0+0
     0x2400000 (has no name): ()  1x1+0+0  +0+0
     0x2200000 (has no name): ()  1x1+0+0  +0+0
     0x1a0005a "Firefox": ("firefox" "firefox")  200x200+0+0  +0+0
        1 child:
        0x1a0005b (has no name): ()  1x1+-1+-1  +-1+-1
     0x1a00048 (has no name): ("Firefox" "firefox")  100x100+0+0  +0+0
        1 child:
        0x1a00049 (has no name): ()  1x1+-1+-1  +-1+-1
     0x1a00039 "Firefox": ()  10x10+-100+-100  +-100+-100
     0x1e00001 "xdg-desktop-portal-gtk": ("xdg-desktop-portal-gtk" "Xdg-desktop-portal-gtk")  10x10+10+10  +10+10
     0x1a00001 "Firefox": ("firefox" "Firefox")  10x10+10+10  +10+10
     0xa00002 "Dunst": ("Dunst" "Dunst")  303x58+2419+50  +2419+50
     0x800001 "polkit-gnome-authentication-agent-1": ("polkit-gnome-authentication-agent-1" "Polkit-gnome-authentication-agent-1")  10x10+10+10  +10+10
     0x1800000 (has no name): ()  1x1+-1+-1  +-1+-1
     0x1600000 (has no name): ()  1x1+-1+-1  +-1+-1
     0xa00004 (has no name): ()  1x1+-1+-1  +-1+-1
     0xe00004 "picom": ("picom" "picom")  1x1+0+0  +0+0
     0x4000fe "[i3 con] bottom dockarea eDP-1": ("i3-frame" "i3-frame")  10x10+-15+-15  +-15+-15
     0x400129 "[i3 con] container around 0x5652bf754550": ("i3-frame" "i3-frame")  1352x707+1373+54  +1373+54
        1 child:
        0x2000002 "Alacritty": ("Alacritty" "Alacritty")  1352x707+0+0  +1373+54
     0x400108 "[i3 con] workspace 1": ("i3-frame" "i3-frame")  1366x721+1366+47  +1366+47
     0x4000fc "[i3 con] content eDP-1": ("i3-frame" "i3-frame")  1366x746+1366+22  +1366+22
     0x400119 "[i3 con] container around 0x5652bf7bc480": ("i3-frame" "i3-frame")  1366x22+1366+0  +1366+0
        1 child:
        0x1800002 "i3-wm": ("polybar" "Polybar")  1366x22+0+0  +1366+0
     0x4000fa "[i3 con] top dockarea eDP-1": ("i3-frame" "i3-frame")  1366x22+1366+0  +1366+0
     0x400106 "[i3 con] bottom dockarea HDMI-1": ("i3-frame" "i3-frame")  10x10+-15+-15  +-15+-15
     0x400123 "[i3 con] container around 0x5652bf74a6b0": ("i3-frame" "i3-frame")  1352x707+7+54  +7+54
        1 child:
        0x1a0002c "[Bug]: Action triggers button does not respond to clicks after polybar reloads · Issue #3007 · polybar/polybar — Mozilla Firefox": ("Navigator" "firefox")  1352x707+0+0  +7+54
           1 child:
           0x1a0002d (has no name): ()  1x1+-1+-1  +6+53
     0x40010a "[i3 con] workspace 6": ("i3-frame" "i3-frame")  1366x721+0+47  +0+47
     0x400104 "[i3 con] content HDMI-1": ("i3-frame" "i3-frame")  1366x746+0+22  +0+22
     0x40011b "[i3 con] container around 0x5652bf7b9810": ("i3-frame" "i3-frame")  1366x22+0+0  +0+0
        1 child:
        0x1600002 "i3-wm": ("polybar" "Polybar")  1366x22+0+0  +0+0
     0x400102 "[i3 con] top dockarea HDMI-1": ("i3-frame" "i3-frame")  1366x22+0+0  +0+0
     0x400100 "[i3 con] output HDMI-1": ("i3-frame" "i3-frame")  1366x768+0+0  +0+0
     0x4000f8 "[i3 con] output eDP-1": ("i3-frame" "i3-frame")  1366x768+1366+0  +1366+0
     0x4000f6 "[i3 con] workspace __i3_scratch": ("i3-frame" "i3-frame")  10x10+-15+-15  +-15+-15
     0x4000f4 "[i3 con] content __i3": ("i3-frame" "i3-frame")  10x10+-15+-15  +-15+-15
     0x4000f2 "[i3 con] pseudo-output __i3": ("i3-frame" "i3-frame")  1366x768+0+0  +0+0
     0x4000f0 (has no name): ("i3-frame" "i3-frame")  2732x768+0+0  +0+0
     0x400002 (has no name): ("i3-WM_Sn" "i3-WM_Sn")  1x1+-1+-1  +-1+-1
     0x4000ef "i3": ()  1x1+-1+-1  +-1+-1

Case: 1.2 Output when external monitor is unplugged after performing case 1.1:

xwininfo: Window id: 0x68e (the root window) "i3"

  Root window id: 0x68e (the root window) "i3"
  Parent window id: 0x0 (none)
     33 children:
     0xa00002 "Dunst": ("Dunst" "Dunst")  303x58+1053+50  +1053+50
     0x2a00000 (has no name): ()  1x1+-1+-1  +-1+-1
     0x1a00062 "[Bug]: Action triggers button does not respond to clicks after polybar reloads · Issue #3007 · polybar/polybar": ("Firefox" "firefox")  587x70+663+133  +663+133
        1 child:
        0x1a00063 (has no name): ()  1x1+-1+-1  +662+132
     0x1a000aa "Feb 11, 2022, 11:23 PM GMT+5:30": ("Firefox" "firefox")  244x49+448+409  +448+409
        1 child:
        0x1a000ab (has no name): ()  1x1+-1+-1  +447+408
     0x1a00070 "Firefox": ("Firefox" "firefox")  306x316+463+360  +463+360
        1 child:
        0x1a00099 (has no name): ()  1x1+-1+-1  +462+359
     0x1a00066 "Firefox": ("firefox" "firefox")  200x200+0+0  +0+0
        1 child:
        0x1a0006d (has no name): ()  1x1+-1+-1  +-1+-1
     0x2800000 (has no name): ()  1x1+0+0  +0+0
     0x2600000 (has no name): ()  1x1+0+0  +0+0
     0x2400000 (has no name): ()  1x1+0+0  +0+0
     0x2200000 (has no name): ()  1x1+0+0  +0+0
     0x1a0005a "Firefox": ("firefox" "firefox")  200x200+0+0  +0+0
        1 child:
        0x1a0005b (has no name): ()  1x1+-1+-1  +-1+-1
     0x1a00048 (has no name): ("Firefox" "firefox")  100x100+0+0  +0+0
        1 child:
        0x1a00049 (has no name): ()  1x1+-1+-1  +-1+-1
     0x1a00039 "Firefox": ()  10x10+-100+-100  +-100+-100
     0x1e00001 "xdg-desktop-portal-gtk": ("xdg-desktop-portal-gtk" "Xdg-desktop-portal-gtk")  10x10+10+10  +10+10
     0x1a00001 "Firefox": ("firefox" "Firefox")  10x10+10+10  +10+10
     0x800001 "polkit-gnome-authentication-agent-1": ("polkit-gnome-authentication-agent-1" "Polkit-gnome-authentication-agent-1")  10x10+10+10  +10+10
     0xa00004 (has no name): ()  1x1+-1+-1  +-1+-1
     0xe00004 "picom": ("picom" "picom")  1x1+0+0  +0+0
     0x4000fe "[i3 con] bottom dockarea eDP-1": ("i3-frame" "i3-frame")  10x10+-15+-15  +-15+-15
     0x400129 "[i3 con] container around 0x5652bf754550": ("i3-frame" "i3-frame")  1352x707+7+54  +7+54
        1 child:
        0x2000002 "Alacritty": ("Alacritty" "Alacritty")  1352x707+0+0  +7+54
     0x400108 "[i3 con] workspace 1": ("i3-frame" "i3-frame")  1366x721+0+47  +0+47
     0x4000fc "[i3 con] content eDP-1": ("i3-frame" "i3-frame")  1366x746+0+22  +0+22
     0x400147 "[i3 con] container around 0x5652bf7a7ba0": ("i3-frame" "i3-frame")  1366x22+0+0  +0+0
        1 child:
        0x2a00002 "i3-wm": ("polybar" "Polybar")  1366x22+0+0  +0+0
     0x4000fa "[i3 con] top dockarea eDP-1": ("i3-frame" "i3-frame")  1366x22+0+0  +0+0
     0x400123 "[i3 con] container around 0x5652bf74a6b0": ("i3-frame" "i3-frame")  1352x707+7+54  +7+54
        1 child:
        0x1a0002c "[Bug]: Action triggers button does not respond to clicks after polybar reloads · Issue #3007 · polybar/polybar — Mozilla Firefox": ("Navigator" "firefox")  1352x707+0+0  +7+54
           1 child:
           0x1a0002d (has no name): ()  1x1+-1+-1  +6+53
     0x40010a "[i3 con] workspace 6": ("i3-frame" "i3-frame")  1366x721+0+47  +0+47
     0x4000f8 "[i3 con] output eDP-1": ("i3-frame" "i3-frame")  1366x768+0+0  +0+0
     0x4000f6 "[i3 con] workspace __i3_scratch": ("i3-frame" "i3-frame")  10x10+-15+-15  +-15+-15
     0x4000f4 "[i3 con] content __i3": ("i3-frame" "i3-frame")  10x10+-15+-15  +-15+-15
     0x4000f2 "[i3 con] pseudo-output __i3": ("i3-frame" "i3-frame")  1366x768+0+0  +0+0
     0x4000f0 (has no name): ("i3-frame" "i3-frame")  1366x768+0+0  +0+0
     0x400002 (has no name): ("i3-WM_Sn" "i3-WM_Sn")  1x1+-1+-1  +-1+-1
     0x4000ef "i3": ()  1x1+-1+-1  +-1+-1

Case: 1.3 Output when external monitor is plugged in again after performing case 1.2:

xwininfo: Window id: 0x68e (the root window) "i3"

  Root window id: 0x68e (the root window) "i3"
  Parent window id: 0x0 (none)
     37 children:
     0xa00002 "Dunst": ("Dunst" "Dunst")  303x58+2419+50  +2419+50
     0x1800000 (has no name): ()  1x1+-1+-1  +-1+-1
     0x1a00062 "[Bug]: Action triggers button does not respond to clicks after polybar reloads · Issue #3007 · polybar/polybar": ("Firefox" "firefox")  587x70+663+133  +663+133
        1 child:
        0x1a00063 (has no name): ()  1x1+-1+-1  +662+132
     0x1a000aa "Feb 11, 2022, 11:23 PM GMT+5:30": ("Firefox" "firefox")  244x49+448+409  +448+409
        1 child:
        0x1a000ab (has no name): ()  1x1+-1+-1  +447+408
     0x1a00070 "Firefox": ("Firefox" "firefox")  306x316+463+360  +463+360
        1 child:
        0x1a00099 (has no name): ()  1x1+-1+-1  +462+359
     0x1a00066 "Firefox": ("firefox" "firefox")  200x200+0+0  +0+0
        1 child:
        0x1a0006d (has no name): ()  1x1+-1+-1  +-1+-1
     0x2800000 (has no name): ()  1x1+0+0  +0+0
     0x2600000 (has no name): ()  1x1+0+0  +0+0
     0x2400000 (has no name): ()  1x1+0+0  +0+0
     0x2200000 (has no name): ()  1x1+0+0  +0+0
     0x1a0005a "Firefox": ("firefox" "firefox")  200x200+0+0  +0+0
        1 child:
        0x1a0005b (has no name): ()  1x1+-1+-1  +-1+-1
     0x1a00048 (has no name): ("Firefox" "firefox")  100x100+0+0  +0+0
        1 child:
        0x1a00049 (has no name): ()  1x1+-1+-1  +-1+-1
     0x1a00039 "Firefox": ()  10x10+-100+-100  +-100+-100
     0x1e00001 "xdg-desktop-portal-gtk": ("xdg-desktop-portal-gtk" "Xdg-desktop-portal-gtk")  10x10+10+10  +10+10
     0x1a00001 "Firefox": ("firefox" "Firefox")  10x10+10+10  +10+10
     0x800001 "polkit-gnome-authentication-agent-1": ("polkit-gnome-authentication-agent-1" "Polkit-gnome-authentication-agent-1")  10x10+10+10  +10+10
     0xa00004 (has no name): ()  1x1+-1+-1  +-1+-1
     0xe00004 "picom": ("picom" "picom")  1x1+0+0  +0+0
     0x40016d "[i3 con] bottom dockarea HDMI-1": ("i3-frame" "i3-frame")  10x10+-15+-15  +-15+-15
     0x400123 "[i3 con] container around 0x5652bf74a6b0": ("i3-frame" "i3-frame")  1352x729+7+32  +7+32
        1 child:
        0x1a0002c "[Bug]: Action triggers button does not respond to clicks after polybar reloads · Issue #3007 · polybar/polybar — Mozilla Firefox": ("Navigator" "firefox")  1352x729+0+0  +7+32
           1 child:
           0x1a0002d (has no name): ()  1x1+-1+-1  +6+31
     0x40010a "[i3 con] workspace 6": ("i3-frame" "i3-frame")  1366x743+0+25  +0+25
     0x40016b "[i3 con] content HDMI-1": ("i3-frame" "i3-frame")  1366x768+0+0  +0+0
     0x400169 "[i3 con] top dockarea HDMI-1": ("i3-frame" "i3-frame")  10x10+-15+-15  +-15+-15
     0x4000fe "[i3 con] bottom dockarea eDP-1": ("i3-frame" "i3-frame")  10x10+-15+-15  +-15+-15
     0x400129 "[i3 con] container around 0x5652bf754550": ("i3-frame" "i3-frame")  1352x707+1373+54  +1373+54
        1 child:
        0x2000002 "Alacritty": ("Alacritty" "Alacritty")  1352x707+0+0  +1373+54
     0x400108 "[i3 con] workspace 1": ("i3-frame" "i3-frame")  1366x721+1366+47  +1366+47
     0x4000fc "[i3 con] content eDP-1": ("i3-frame" "i3-frame")  1366x746+1366+22  +1366+22
     0x40017e "[i3 con] container around 0x5652bf7b9810": ("i3-frame" "i3-frame")  1366x22+1366+0  +1366+0
        1 child:
        0x1800002 "i3-wm": ("polybar" "Polybar")  1366x22+0+0  +1366+0
     0x4000fa "[i3 con] top dockarea eDP-1": ("i3-frame" "i3-frame")  1366x22+1366+0  +1366+0
     0x400167 "[i3 con] output HDMI-1": ("i3-frame" "i3-frame")  1366x768+0+0  +0+0
     0x4000f8 "[i3 con] output eDP-1": ("i3-frame" "i3-frame")  1366x768+1366+0  +1366+0
     0x4000f6 "[i3 con] workspace __i3_scratch": ("i3-frame" "i3-frame")  10x10+-15+-15  +-15+-15
     0x4000f4 "[i3 con] content __i3": ("i3-frame" "i3-frame")  10x10+-15+-15  +-15+-15
     0x4000f2 "[i3 con] pseudo-output __i3": ("i3-frame" "i3-frame")  1366x768+0+0  +0+0
     0x4000f0 (has no name): ("i3-frame" "i3-frame")  2732x768+0+0  +0+0
     0x400002 (has no name): ("i3-WM_Sn" "i3-WM_Sn")  1x1+-1+-1  +-1+-1
     0x4000ef "i3": ()  1x1+-1+-1  +-1+-1

Points to note:-

  • When system is rebooted with external monitor plugged in, the polybar loads both the bar correctly at their respective monitors.
  • When the external monitor is unplugged, the polybar loads the main bar correctly on the primary monitor.
  • When the external monitor is plugged in again, the external monitor turns on but polybar only load the main bar on the primary monitor. There's no bar on external monitor.
  • I use autorandr to automate the xrandr.
  • In all these cases, screenchange-reload was set to true.
  • To fix the bar offset, I've set wm-restack = i3 and ovverride-redirect = true and again repeated the whole process of plugging and unplugging the external monitor. Same results occurs, i.e. polybar fails to load the bar on external monitor when the external monitor is replugged.

Below is my polybar launcher.sh script

#!/bin/sh

DIR="~/.config/polybar"

# Terminate already running bar instances
killall -q polybar

# Wait until the processes have been shut down
while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done

if type "xrandr" > /dev/null; then
	for monitor in $(xrandr --query | grep " connected" | cut -d" " -f1); do
		if [ $monitor == 'eDP-1' ]; then
			MONITOR=$monitor polybar --quiet --config="$DIR"/config.ini --reload main &
		elif [ $monitor == 'HDMI-1' ]; then
			MONITOR=$monitor polybar --quiet --config="$DIR"/config.ini --reload externalMonitor &
		fi
	done
else
	polybar --quiet --config="$DIR"/config.ini --reload main &
fi

Below is the autorandr postswitch.sh

#!/bin/sh
/home/rayshabh/.fehbg &
# Notify current monitor profile
sleep 1

XRANDR_STATUS=$(xrandr | awk '/HDMI/ {print $1, $2}')
AUTORANDR_CURRENT_PROFILE=$(autorandr | grep -i 'current' | cut -d ' ' -f1)

dunstify -a "autorandr" -i "~/.config/autorandr/icons/monitor.png" -t 4000 -u low "$XRANDR_STATUS" "Display profile: <b>$AUTORANDR_CURRENT_PROFILE</b>"

@patrick96
Copy link
Member

Thanks for the detailed rundown. Unfortunately, I don't see anything that would prevent polybar from receiving mouse clicks.

Just to clarify, you said your reboot and poweroff buttons no longer work after unplugging and screenchange-reload = true. To get to those buttons, you first need to press the menu's opening button. Does that still work?

When the external monitor is plugged in again, the external monitor turns on but polybar only load the main bar on the primary monitor. There's no bar on external monitor.

This is expected. Polybar doesn't start new instances by itself. At the moment before you plug in your external monitor, only a single polybar is running. That bar will restart itself because of screenchange-reload.

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

No branches or pull requests

2 participants