This repository has been archived on 2024-12-15. You can view files and clone it, but cannot push or open issues or pull requests.
PyBitmessage-2024-12-15/src/plugins/desktop_xdg.py

34 lines
1004 B
Python

# -*- coding: utf-8 -*-
import os
from xdg import BaseDirectory, Menu, Exceptions
class DesktopXDG(object):
"""pyxdg Freedesktop desktop implementation"""
def __init__(self):
try:
self.desktop = Menu.parse().getMenu('Office').getMenuEntry(
'pybitmessage.desktop').DesktopEntry
except (AttributeError, Exceptions.ParsingError):
raise TypeError # TypeError disables startonlogon
appimage = os.getenv('APPIMAGE')
if appimage:
self.desktop.set('Exec', appimage)
def adjust_startonlogon(self, autostart=False):
"""Configure autostart according to settings"""
autostart_path = os.path.join(
BaseDirectory.xdg_config_home, 'autostart', 'pybitmessage.desktop')
if autostart:
self.desktop.write(autostart_path)
else:
try:
os.remove(autostart_path)
except OSError:
pass
connect_plugin = DesktopXDG