qtile: Terminal apps open with wrong dimensions when launched with key bindings

Issue description

When launching terminal apps through keybindings, the dimensions of the output window aren’t determined correctly. I’ll use Ranger as an example but it’s the same for all my terminal apps (Newsboat, Neomutt etc.)

Current behaviour:

1611979751

Expected behaviour:

1611979773

I can only observe the expected behaviour when I launch the terminal app manually (without the use of keybindings).

Qtile version

> qtile --version

 0.16.2.dev209+gd5848931

This problem doesn’t seem to exist in the stable version of qtile (0.16.1) that was released in the August of last year. I didn’t make any changes to my config file when I switched from qtile to qtile-git, so I assume something must have changed between the two versions to cause this.

Stack traces

This is today’s log:

> .local/share/qtile/qtile.log

2021-01-30 08:08:52,292 WARNING libqtile floating.py:__init__():L108 Non-config.Match objects in float_rules are deprecated
2021-01-30 10:26:14,969 WARNING libqtile.widget.pulse_volume pulse_volume.py:on_connection_change():L97 Connection to pulseaudio has been terminated
2021-01-30 10:26:14,976 WARNING libqtile lifecycle.py:_atexit():L38 Qtile will now terminate
2021-01-30 10:28:07,362 ERROR libqtile hook.py:fire():L367 Error in hook client_new
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/libqtile/hook.py", line 365, in fire
    i(*args, **kwargs)
  File "/home/masacaai/.config/qtile/config.py", line 72, in transparent_window
    change_transparency(window)
  File "/home/masacaai/.config/qtile/config.py", line 50, in change_transparency
    kls = window.window.get_wm_class()[1].lower()
IndexError: tuple index out of range
2021-01-30 11:48:37,758 ERROR libqtile.widget.pulse_volume pulse_volume.py:on_connection_change():L104 Connection to pulseaudio has been terminated
2021-01-30 11:48:42,934 WARNING libqtile floating.py:__init__():L108 Non-config.Match objects in float_rules are deprecated
2021-01-30 17:15:00,569 ERROR libqtile hook.py:fire():L403 Error in hook client_new
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/libqtile/hook.py", line 401, in fire
    i(*args, **kwargs)
  File "/home/masacaai/.config/qtile/config.py", line 72, in transparent_window
    change_transparency(window)
  File "/home/masacaai/.config/qtile/config.py", line 50, in change_transparency
    kls = window.window.get_wm_class()[1].lower()
IndexError: tuple index out of range
2021-01-30 17:59:44,319 WARNING libqtile floating.py:__init__():L108 Non-config.Match objects in float_rules are deprecated
2021-01-30 17:59:44,324 WARNING libqtile.widget.pulse_volume pulse_volume.py:on_connection_change():L97 Connection to pulseaudio has been terminated
2021-01-30 17:59:44,331 ERROR libqtile base.py:_wrapper():L300 got exception from widget timer
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/libqtile/widget/base.py", line 298, in _wrapper
    method(*method_args)
  File "/usr/lib/python3.9/site-packages/libqtile/widget/base.py", line 463, in timer_setup
    update_interval = self.tick()
  File "/usr/lib/python3.9/site-packages/libqtile/widget/base.py", line 490, in tick
    self.update(text)
  File "/usr/lib/python3.9/site-packages/libqtile/widget/base.py", line 493, in update
    old_width = self.layout.width
  File "/usr/lib/python3.9/site-packages/libqtile/drawer.py", line 80, in width
    return self.layout.get_pixel_size()[0]
  File "/usr/lib/python3.9/site-packages/libqtile/pangocffi.py", line 132, in get_pixel_size
    pango.pango_layout_get_pixel_size(self._pointer, width, height)
TypeError: initializer for ctype 'PangoLayout *' must be a cdata pointer, not NoneType
2021-01-30 17:59:44,336 ERROR libqtile base.py:_wrapper():L300 got exception from widget timer
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/libqtile/widget/base.py", line 298, in _wrapper
    method(*method_args)
  File "/usr/lib/python3.9/site-packages/libqtile/widget/base.py", line 463, in timer_setup
    update_interval = self.tick()
  File "/usr/lib/python3.9/site-packages/libqtile/widget/base.py", line 490, in tick
    self.update(text)
  File "/usr/lib/python3.9/site-packages/libqtile/widget/base.py", line 493, in update
    old_width = self.layout.width
  File "/usr/lib/python3.9/site-packages/libqtile/drawer.py", line 80, in width
    return self.layout.get_pixel_size()[0]
  File "/usr/lib/python3.9/site-packages/libqtile/pangocffi.py", line 132, in get_pixel_size
    pango.pango_layout_get_pixel_size(self._pointer, width, height)
TypeError: initializer for ctype 'PangoLayout *' must be a cdata pointer, not NoneType
2021-01-30 17:59:44,338 ERROR libqtile base.py:on_done():L542 Failed to reschedule.
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/libqtile/widget/base.py", line 534, in on_done
    self.update(result)
  File "/usr/lib/python3.9/site-packages/libqtile/widget/base.py", line 550, in update
    old_width = self.layout.width
  File "/usr/lib/python3.9/site-packages/libqtile/drawer.py", line 80, in width
    return self.layout.get_pixel_size()[0]
  File "/usr/lib/python3.9/site-packages/libqtile/pangocffi.py", line 132, in get_pixel_size
    pango.pango_layout_get_pixel_size(self._pointer, width, height)
TypeError: initializer for ctype 'PangoLayout *' must be a cdata pointer, not NoneType
2021-01-30 17:59:44,340 WARNING libqtile lifecycle.py:_atexit():L34 Restarting Qtile with os.execv(...)
2021-01-30 17:59:44,947 WARNING libqtile floating.py:__init__():L108 Non-config.Match objects in float_rules are deprecated

The two biggest errors I can spot with my untrained eye is one regarding a function I had written to make sure mpv stays with the same opacity even when it loses focus and another TypeError regarding PangoLayout.

The transparency function works as intended and I wouldn’t have noticed anything had I not checked the log.

Configuration

I believe these are the relevant parts of my config. Let me know if I need to post more:

##############
# FUNCTIONS  #
##############

def change_transparency(window):
    """change window transparency based on his name/type."""    
    
    kls = window.window.get_wm_class()[1].lower()
    if window.window.get_wm_icon_name() == 'Picture-in-Picture' or 'mpv' in kls:
    	window.cmd_opacity(1)
    else:
    	window.cmd_opacity(opacity_var)

#########
# HOOKS #
#########

@hook.subscribe.client_new
def transparent_window(window):
    """Make new windows a little transparent."""
    change_transparency(window)
            
@hook.subscribe.client_focus
def client_focus(window):
    """Change transparency on focus."""
    global last_focus

    if last_focus is not None and last_focus != window:
        try:
            change_transparency(last_focus)
        except Exception:
            pass  # ignore if error

    if last_focus != window:
        last_focus = window
        window.cmd_opacity(1)  # current focused window: no transp

###############
# KEYBINDINGS #
###############

Key([mod], "r",
lazy.spawn("kitty -e ranger"),
desc="Launch ranger"),

Everything regarding the transparency of unfocused windows wasn’t written by me. I had taken it from someone else’s config. If that indeed seems to be the root of the problem, I’ll link the original post/issue somewhere here.

Links

I had initially opened this as a discussion, which can be found here #2164 This issue may be linked with this mailing list discussion : https://groups.google.com/g/qtile-dev/c/mjMKB533GNA/m/f0UGhBxpDgAJ

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 2
  • Comments: 18 (7 by maintainers)

Commits related to this issue

Most upvoted comments

for fish I added following Lines to config.fish

set --unexport COLUMNS
set --unexport LINES

fixes issue for me completly

edit: for bash using this lines in .bashrc fix this issue for me

export -n LINES
export -n COLUMNS

Hacky fix through python function UPDATE: Implement Tokariew’ solution in the way that works for me:

def fix_cli_app(app: 'Name of $PATH located application') -> str:
    '''Quick fix of github.com/qtile/qtile/issues/2167 bug'''
    fix_environment = 'export -n LINES; export -n COLUMNS; sleep 0.1 &&'
    return f'alacritty -t {app} -e sh -c "{fix_environment} {app}"'


keys = [
    Key([mod], 'r', lazy.spawn(fix_cli_app('ranger'))),
    Key([mod], 'n', lazy.spawn(fix_cli_app('newsboat'))),
]