Ankit404butfound / PyWhatKit

Send WhatsApp message at certain time and many other things.
MIT License
1.33k stars 293 forks source link

Xlib.error.DisplayConnectionError: Can't connect to display ":0": b'Authorization required, but no authorization protocol specified\n' on Wayland #280

Open george72 opened 1 year ago

george72 commented 1 year ago

Description

Can not send whatsapp text message in Fedora 38 with Wayland

To Reproduce

import pywhatkit pywhatkit.sendwhatmsg(phone_no="520000000001", message="Hi", wait_time=15, time_min=33)

Same config in Windows 10 works fine. It seems to be a problem with Wayland.

Version Information

techbyds commented 1 year ago

Description:

Xlib.error.DisplayConnectionError: Can't connect to display ":0": b'Authorization required, but no authorization protocol specified\n'

Reproduce:

import pywhatkit pywhatkit.sendwhatmsg("+34xxxxx", "test py", 13,22,8)

Version:

OS: Ubuntu 23.04 (Luna Lobster) browser: chrome python: 3.11.2 pywhatkit: 5.4

george72 commented 1 year ago

This error is exclusively on Wayland OS.

I can confirm that if you run it on a KDE with X11 like Fedora 38 KDE it just works as designed (be sure to log in with X11 not Wayland).

Pywhatkit needs a Wayland update, not sure if it is a small task but since all linux seems to move to Wayland it needs to get fixed.

techbyds commented 1 year ago

@george72 Or Wayland needs an update ;)

Wayland is still under development, and there are still applications and behaviours that don’t work as expected, you may find that some applications have not been updated to work properly in Wayland and currently the only way these applications will run is using Xorg instead of Wayland. source

george72 commented 1 year ago

I had to change Fedora 38 from Wayland to Xorg to be able to run Pywhatkit.

Expecting a Wayland compatibility update does not look like the way to go. It's better to have Pywhatkit running natively on Wayland.

Steps to change Fedora Wayland to Xorg: Changing the default GNOME session via configuration file

As an alternative, this change can be made by editing a configuration file /etc/gdm/custom.conf.

Open /etc/gdm/custom.conf and uncomment the line:

WaylandEnable=false

Add the following line to the [daemon] section:

DefaultSession=gnome-xorg.desktop

Save the custom.conf file.

Logout or reboot to enter the new session.

Link to change Fedora Wayland Default to Xorg so it can run Pywhatkit: https://docs.fedoraproject.org/en-US/quick-docs/configuring-xorg-as-default-gnome-session/

spinder commented 3 weeks ago

Still broken in Wayland on FC 40... :-(

spinder commented 3 weeks ago

Hey, So there is a fix that can be applied locally... and it seems to be working. xhost +local:$USER For the user that will be running the python code. Source: https://stackoverflow.com/questions/31902846/how-to-fix-error-xlib-error-displayconnectionerror-cant-connect-to-display-0