Skip to content

Commit 44e3e93

Browse files
authored
make xlib optional for wayland (slgobinath#765)
* refactor(break_screen): make Xlib not required for Wayland * refactor(donotdisturb): make Xlib not required for Wayland * move dependency on Xlib to optional/recommended
1 parent 23a9efc commit 44e3e93

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,10 @@ Ensure to meet the following dependencies:
122122
- `ffmpeg` or `pipewire` (any of them works)
123123
- `python3` (>= 3.10.0)
124124
- `python3-gi`
125-
- `python3-xlib`
126125
- `python3-babel`
127126
- `python3-croniter`
128127
- `python3-packaging`
128+
- `python3-xlib` (required on x11)
129129
- **Optional**: Either `python3-pywayland` (provides smartpause in Wayland) or `xprintidle` (provides smartpause in x11).
130130

131131
**To install Safe Eyes from PyPI:**

debian/control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ Architecture: all
1212
Depends: ${misc:Depends}, ${python3:Depends},
1313
python3 (>= 3.10.0),
1414
python3-gi,
15-
python3-xlib,
1615
python3-babel,
1716
python3-croniter,
1817
python3-packaging,
1918
gir1.2-notify-0.7,
2019
gir1.2-gtk-4.0,
2120
ffmpeg | pipewire
2221
Recommends:
22+
python3-xlib,
2323
python3-pywayland
2424
Suggests:
2525
xprintidle

safeeyes/plugins/donotdisturb/plugin.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
gi.require_version("Gio", "2.0")
2828
from gi.repository import Gio
29-
import Xlib
3029
from safeeyes import utility
3130

3231
context = None
@@ -63,6 +62,8 @@ def is_active_window_skipped_xorg(pre_break):
6362
"""
6463
logging.info("Searching for full-screen application")
6564

65+
import Xlib
66+
6667
def get_window_property(window, prop, proptype):
6768
result = window.get_full_property(prop, proptype)
6869
if result:

safeeyes/ui/break_screen.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
from safeeyes.context import Context
2828
from safeeyes.model import Break, Config, TrayAction
2929
from safeeyes.translations import translate as _
30-
import Xlib
31-
from Xlib.display import Display
32-
from Xlib import X
3330

3431
gi.require_version("Gtk", "4.0")
3532
from gi.repository import Gdk
@@ -71,7 +68,9 @@ def __init__(
7168
self.show_postpone_button = False
7269

7370
if not self.context.is_wayland:
74-
self.x11_display = Display()
71+
import Xlib.display
72+
73+
self.x11_display = Xlib.display.Display()
7574

7675
def initialize(self, config: Config) -> None:
7776
"""Initialize the internal properties from configuration."""
@@ -231,6 +230,8 @@ def __window_set_keep_above_x11(self, window: "BreakScreenWindow") -> None:
231230
if self.x11_display is None:
232231
return
233232

233+
import Xlib
234+
234235
NET_WM_STATE = self.x11_display.intern_atom("_NET_WM_STATE")
235236
NET_WM_STATE_ABOVE = self.x11_display.intern_atom("_NET_WM_STATE_ABOVE")
236237
NET_WM_STATE_STICKY = self.x11_display.intern_atom("_NET_WM_STATE_STICKY")
@@ -277,6 +278,8 @@ def __lock_keyboard_x11(self) -> None:
277278
if self.x11_display is None:
278279
return
279280

281+
from Xlib import X
282+
280283
logging.info("Lock the keyboard")
281284
self.lock_keyboard = True
282285

0 commit comments

Comments
 (0)