Skip to content

Commit

Permalink
Add a wrapper function to get the desktop session.
Browse files Browse the repository at this point in the history
  • Loading branch information
twa022 authored and flexiondotorg committed Apr 7, 2022
1 parent 111e801 commit 2087da2
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions usr/lib/mate-hud/mate-hud
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,20 @@ from dbus.mainloop.glib import DBusGMainLoop
from gi.repository import Gio, GLib, Gtk, Gdk, GObject
from Xlib import display, protocol, X, Xatom, error

if 'XFCE' in os.environ['XDG_CURRENT_DESKTOP']:
def get_desktop_env():
desktop_env = ''
try:
desktop_env = os.environ['XDG_CURRENT_DESKTOP']
except:
pass
if not desktop_env:
try:
desktop_env = os.environ['XDG_SESSION_DESKTOP']
except:
pass
return desktop_env

if 'XFCE' in get_desktop_env():
try:
gi.require_version("Xfconf", "0")
from gi.repository import Xfconf
Expand Down Expand Up @@ -139,7 +152,7 @@ def terminate_appmenu_registrar():
# TODO:
# - Use Dbus Quit method.
# - Add checks for other Desktop Environments.
if 'MATE' in os.environ['XDG_CURRENT_DESKTOP']:
if 'MATE' in get_desktop_env():
if process_running('appmenu-registrar') and not process_running('appmenu-mate'):
kill_process('appmenu-registrar')
elif process_running('xfce4-panel'):
Expand Down Expand Up @@ -193,7 +206,7 @@ def get_menu(menuKeys):
keyval, modifiers = Gtk.accelerator_parse(shortcut)
shortcut = '' if modifiers else ',' + shortcut

desktop_name = os.environ['XDG_CURRENT_DESKTOP']
desktop_name = get_desktop_env()

# Calculate display DPI value
screen = window.get_screen()
Expand Down

0 comments on commit 2087da2

Please # to comment.