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

Pympress (1.5.1+dfsg-3build1) is not loading when using i3 #282

Closed
Zar-rok opened this issue Mar 22, 2023 · 7 comments
Closed

Pympress (1.5.1+dfsg-3build1) is not loading when using i3 #282

Zar-rok opened this issue Mar 22, 2023 · 7 comments

Comments

@Zar-rok
Copy link

Zar-rok commented Mar 22, 2023

Problem

I use Ubuntu 20.04, hence I have installed pympress (1.5.1+dfsg-3build1) via apt.

I also use i3 (4.17.1) as my window manager.

When running pympress, the Content and Presenter windows are spawned, however the Content window stays blank and nothing is loading.

Debug

The problem occur when the Content window is set to full-screen, here:

self.c_win.fullscreen()

By checking the latest release of pympress (1.8.0), I see that the configuration file created in ~/.config/pympress contains the full-screen preferences for both windows. However, this file is not initialized for 1.5.1+dfsg-3build1.

Solution

This problem can be fixed by manually creating ~/.config/pympress with the following content:

[content]
start_fullscreen = off

[presenter]
start_fullscreen = off

Question

I think that the problem comes from i3 ignoring the command sent by pympress (based on #59 (comment)).

Maybe that this solution can be added here?

In any case, thank you for this really nice and useful software!

@Cimbali
Copy link
Owner

Cimbali commented Mar 22, 2023

Can you describe what happens on i3 when starting v1.8.0?

  • What are the symptomes: do you have a crash? Just a blank content window?
  • What is printed to the console?
  • Can you run pympress --log=debug and report what is displayed in ~/.cache/pympress.log ?

I think setting windows fullscreen does not really mean anything on i3, from what I remember from #59. I think a good way to handle this would be to disable the start_fullscreen functionality if we detect we’re on i3.

@Cimbali
Copy link
Owner

Cimbali commented Mar 22, 2023

As to 1.5.1, I think if you have specific needs like i3 support, you’ll need to update pympress with e.g. pip as I don’t have much control over which versions are shipped in each OS version.

@Zar-rok
Copy link
Author

Zar-rok commented Mar 23, 2023

As to 1.5.1, I think if you have specific needs like i3 support, you’ll need to update pympress with e.g. pip as I don’t have much control over which versions are shipped in each OS version.

The problem with the pip approach is that you need to install Python 3.9 to be able to run the latest pympress version. Because, using Python 3.8 (my default version for Ubuntu 20.04), you get the following error:

Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/opt/pympress/pympress/__main__.py", line 63, in <module>
    gettext.install('pympress', util.get_locale_dir())
  File "/opt/pympress/pympress/util.py", line 116, in get_locale_dir
    return __get_resource_path('share', 'locale')
  File "/opt/pympress/pympress/util.py", line 106, in __get_resource_path
    root = importlib_resources.files('pympress')
AttributeError: module 'importlib.resources' has no attribute 'files'

Hence, a simpler solution is just to create the ~/.config/pympress, as described in my first post.

That's why I think it could be useful to document this solution in case future users encounter the same problem.

Can you describe what happens on i3 when starting v1.8.0?

For 1.8.0, I don't have any bug.

However, the first time I ran pympress, without argument, the Content and Presenter windows have been placed in the same monitor and the Content window have been set to full-screen.

Hence, I end up with a black screen. Once I understood what was going on, typing F11 and disabling the startup full-screen options fixed this behavior.

I think setting windows fullscreen does not really mean anything on i3, from what I remember from #59. I think a good way to handle this would be to disable the start_fullscreen functionality if we detect we’re on i3.

I also think that it is a better behavior.

The simplest way could be to check if one of the running process is named i3, but maybe that on some systems, i3 is run as a service with another name.

On Ubuntu, there is external command such as wmctrl -m which gives the X window manager name. It relies on the EWMH spec, however I didn't find ways to retrieve this information using PyGi for instance.

So, I don't know what could be a reliable way to detect that i3 is running. Do you have any ideas?

@Cimbali
Copy link
Owner

Cimbali commented Mar 23, 2023

The problem with the pip approach is that you need to install Python 3.9 to be able to run the latest pympress version. Because, using Python 3.8 (my default version for Ubuntu 20.04), you get the following error:

We should support python 3.8. I’ll look into that.

Cimbali added a commit that referenced this issue Mar 23, 2023
@Cimbali
Copy link
Owner

Cimbali commented Mar 23, 2023

Current master should run fine on python 3.8, which solves that part of the issue. I’ll release 1.8.1 soon and you can just upgrade with pip.

To detect i3, if it is freedesktop-compliant it should set XDG_CURRENT_DESKTOP. Can you check the value it has? I’m guessing i3?

@Zar-rok
Copy link
Author

Zar-rok commented Mar 23, 2023

Current master should run fine on python 3.8, which solves that part of the issue. I’ll release 1.8.1 soon and you can just upgrade with pip.

Thanks, I will try that.

To detect i3, if it is freedesktop-compliant it should set XDG_CURRENT_DESKTOP. Can you check the value it has? I’m guessing i3?

For me, echo $XDG_CURRENT_DESKTOP returns XFCE.

I use Xfce 4.14 as my desktop environment and i3 as my window manager, instead of the default xfwm4.

From what I understand, XDG_CURRENT_DESKTOP returns the desktop environment, hence it cannot be used to check if i3 is used.

However, by checking the other environment variable defined in my shell, I see that this one exists: I3SOCK=/run/user/1000/i3/ipc-socket.2178. According to the documentation:

You can override the default path through the environment-variable I3SOCK or by specifying the ipc-socket directive. This is discouraged, though, since i3 does the right thing by default.

So, I guess that it is automatically defined when using i3. Thus, maybe that it can be used like that?

import os
...
if os.environ.get("I3SOCK"):
    ... # Disable the start_fullscreen functionality

@Zar-rok
Copy link
Author

Zar-rok commented Mar 23, 2023

To be more precise, my problem is fixed when replacing:

pympress/pympress/ui.py

Lines 498 to 499 in a3cf735

if not c_full and not p_full:
return

with:

if os.environ.get("I3SOCK"):
  c_full, p_full = False, False
elif not c_full and not p_full:
  return

Cimbali added a commit that referenced this issue Mar 24, 2023
Still leave the possibility to enable it manually if desired.
@Cimbali Cimbali closed this as completed Mar 24, 2023
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

2 participants