@@ -72,7 +72,7 @@ def getActiveWindow() -> Optional[LinuxWindow]:
7272 # https://discourse.gnome.org/t/get-window-id-of-a-window-object-window-get-xwindow-doesnt-exist/10956/3
7373 # https://www.reddit.com/r/gnome/comments/d8x27b/is_there_a_program_that_can_show_keypresses_on/
7474 win_id : Union [str , int ] = 0
75- if os .environ [ 'XDG_SESSION_TYPE' ] .lower () == "wayland" :
75+ if os .environ . get ( 'XDG_SESSION_TYPE' , '' ) .lower () == "wayland" :
7676 # swaymsg -t get_tree | jq '.. | select(.type?) | select(.focused==true).pid' -> Not working (socket issue)
7777 # pynput / mouse --> Not working (no global events allowed, only application events)
7878 _ , activeWindow = _WgetAllWindows ()
@@ -113,7 +113,7 @@ def getAllWindows():
113113
114114 :return: list of Window objects
115115 """
116- if os .environ [ 'XDG_SESSION_TYPE' ] .lower () == "wayland" :
116+ if os .environ . get ( 'XDG_SESSION_TYPE' , '' ) .lower () == "wayland" :
117117 windowsList , _ = _WgetAllWindows ()
118118 windows = [str (win ["id" ]) for win in windowsList if win and win .get ("id" , False )]
119119 else :
@@ -328,8 +328,8 @@ def __init__(self, hWnd: Union[XWindow, int, str]):
328328 self ._xWin : XWindow = self ._win .xWindow
329329 self .watchdog = _WatchDog (self )
330330
331- self ._currDesktop = os .environ [ 'XDG_CURRENT_DESKTOP' ] .lower ()
332- self ._currSessionType = os .environ [ 'XDG_SESSION_TYPE' ] .lower ()
331+ self ._currDesktop = os .environ . get ( 'XDG_CURRENT_DESKTOP' , '' ) .lower ()
332+ self ._currSessionType = os .environ . get ( 'XDG_SESSION_TYPE' , '' ) .lower ()
333333 self ._motifHints : List [int ] = []
334334
335335 def getExtraFrameSize (self , includeBorder : bool = True ) -> Tuple [int , int , int , int ]:
0 commit comments