Fixes startup on Wayland because Keybinder seems to be X11 only
This commit is contained in:
parent
7fac78f24d
commit
85c0518643
|
@ -337,3 +337,10 @@ def spawn_new_terminator(cwd, args):
|
||||||
|
|
||||||
dbg("Spawning: %s" % cmd)
|
dbg("Spawning: %s" % cmd)
|
||||||
subprocess.Popen([cmd]+args)
|
subprocess.Popen([cmd]+args)
|
||||||
|
|
||||||
|
def display_manager():
|
||||||
|
"""Try to detect which display manager we run under"""
|
||||||
|
if os.environ.get('WAYLAND_DISPLAY'):
|
||||||
|
return 'WAYLAND'
|
||||||
|
# Fallback assumption of X11
|
||||||
|
return 'X11'
|
||||||
|
|
|
@ -9,9 +9,8 @@ import uuid
|
||||||
import gi
|
import gi
|
||||||
from gi.repository import GObject
|
from gi.repository import GObject
|
||||||
from gi.repository import Gtk, Gdk
|
from gi.repository import Gtk, Gdk
|
||||||
from gi.repository import Keybinder
|
|
||||||
|
|
||||||
from util import dbg, err, make_uuid
|
from util import dbg, err, make_uuid, display_manager
|
||||||
import util
|
import util
|
||||||
from translation import _
|
from translation import _
|
||||||
from version import APP_NAME
|
from version import APP_NAME
|
||||||
|
@ -19,10 +18,13 @@ from container import Container
|
||||||
from factory import Factory
|
from factory import Factory
|
||||||
from terminator import Terminator
|
from terminator import Terminator
|
||||||
|
|
||||||
try:
|
if display_manager() == 'X11':
|
||||||
from gi.repository import Keybinder
|
try:
|
||||||
except ImportError:
|
gi.require_version('Keybinder', '3.0')
|
||||||
err('Warning: python-keybinder is not installed. This means the \
|
from gi.repository import Keybinder
|
||||||
|
Keybinder.init()
|
||||||
|
except ImportError:
|
||||||
|
err('Warning: python-keybinder is not installed. This means the \
|
||||||
hide_window shortcut will be unavailable')
|
hide_window shortcut will be unavailable')
|
||||||
|
|
||||||
# pylint: disable-msg=R0904
|
# pylint: disable-msg=R0904
|
||||||
|
@ -120,18 +122,19 @@ class Window(Container, Gtk.Window):
|
||||||
# Attempt to grab a global hotkey for hiding the window.
|
# Attempt to grab a global hotkey for hiding the window.
|
||||||
# If we fail, we'll never hide the window, iconifying instead.
|
# If we fail, we'll never hide the window, iconifying instead.
|
||||||
if self.config['keybindings']['hide_window'] != None:
|
if self.config['keybindings']['hide_window'] != None:
|
||||||
try:
|
if display_manager() == 'X11':
|
||||||
self.hidebound = Keybinder.bind(
|
try:
|
||||||
self.config['keybindings']['hide_window'],
|
self.hidebound = Keybinder.bind(
|
||||||
self.on_hide_window)
|
self.config['keybindings']['hide_window'],
|
||||||
except (KeyError, NameError):
|
self.on_hide_window)
|
||||||
pass
|
except (KeyError, NameError):
|
||||||
|
pass
|
||||||
|
|
||||||
if not self.hidebound:
|
if not self.hidebound:
|
||||||
err('Unable to bind hide_window key, another instance/window has it.')
|
err('Unable to bind hide_window key, another instance/window has it.')
|
||||||
self.hidefunc = self.iconify
|
self.hidefunc = self.iconify
|
||||||
else:
|
else:
|
||||||
self.hidefunc = self.hide
|
self.hidefunc = self.hide
|
||||||
|
|
||||||
def apply_config(self):
|
def apply_config(self):
|
||||||
"""Apply various configuration options"""
|
"""Apply various configuration options"""
|
||||||
|
|
Loading…
Reference in New Issue