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

Can't run on session-less environment (non-systemd). #1618

Closed
ahmadraniri opened this issue Dec 28, 2023 · 4 comments
Closed

Can't run on session-less environment (non-systemd). #1618

ahmadraniri opened this issue Dec 28, 2023 · 4 comments
Labels

Comments

@ahmadraniri
Copy link

ahmadraniri commented Dec 28, 2023

Describe the bug
Bleachbit can't run on session-less environment (checked by loginctl), still need display manager or session creator in order to run (apparently, using display manager can't solve the issue).

To Reproduce
Steps to reproduce the behavior:

  1. Launch wayland compositor / x11 window manager directly via tty (not from display manager)
  2. Open terminal
  3. Running bleachbit.
  4. Getting this output :
Traceback (most recent call last):
  File "/usr/local/bin/bleachbit", line 40, in <module>
    bleachbit.Unix.is_display_protocol_wayland_and_root_not_allowed()
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'bleachbit.Unix' has no attribute 'is_display_protocol_wayland_and_root_not_allowed'

The error happens (every time).

Expected behavior
Bleachbit will run although we have no session (like bleachbit 4.4.2).

Desktop (please complete the following information):

  • OS: Alpine Linux.
  • Wayland compositor: swaywm
  • X11 window manager: cwm.
  • BleachBit version: Latest master.
@ahmadraniri
Copy link
Author

Comment some lines on bleachbit.py and bleachbit/Unix.py seems fix it. Bleachbit can be launched.

bleachbit.py

# if 'posix' == os.name:
#     if os.path.isdir('/usr/share/bleachbit'):
#         # This path contains bleachbit/{C,G}LI.py .  This section is
#         # unnecessary if installing BleachBit in site-packages.
#         sys.path.append('/usr/share/')
# 
#     # The two imports from bleachbit must come after sys.path.append(..)
#     import bleachbit.Unix
#     from bleachbit import _
# 
#     if (
#         bleachbit.Unix.is_display_protocol_wayland_and_root_not_allowed()
#     ):
#         print(_('To run a GUI application on Wayland with root, allow access with this command:\n'
#               'xhost si:localuser:root\n'
#                 'See more about xhost at https://docs.bleachbit.org/doc/frequently-asked-questions.html'))
#         sys.exit(1)

bleachbit/Unix.py

# def is_display_protocol_wayland_and_root_not_allowed():
#     try:
#         is_wayland = bleachbit.Unix.is_unix_display_protocol_wayland()
#     except Exception as e:
#         logger.exception(e)
#         return False
#     return (
#         is_wayland and
#         os.environ['USER'] == 'root' and
#         bleachbit.Unix.root_is_not_allowed_to_X_session()
#     )

@ahmadraniri
Copy link
Author

Using display manager doesn't fix the issue, apparently.

@ahmadraniri ahmadraniri changed the title Can't run on session-less environment (non-systemd + without display manager). Can't run on session-less environment (non-systemd). Dec 28, 2023
@ahmadraniri
Copy link
Author

ahmadraniri commented Jan 1, 2024

So, I try other alternative, I replace some lines in is_linux_display_protocol_wayland function. It works apparently, I don't know much about python though.

def is_linux_display_protocol_wayland():
    assert(sys.platform.startswith('linux'))
    result = General.run_external(['echo', '$XDG_SESSION_TYPE'])
    return 'wayland' in result[1].lower()

Edit : it works only when I run it using python bleachbit.py.

@ahmadraniri
Copy link
Author

Fixed and solved, turns out the older version (4.4.x) was still around at /usr/lib/python3.11/site-packages/bleachbit-4.4.2-py3.11.egg. Deleting directory fixs.

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

No branches or pull requests

1 participant