- Added Desktop file
- Added tickbox to allow autostart - Toggle symlink in ~/.config/autostart - Fixes #47
This commit is contained in:
parent
e3004b817d
commit
8d0f2671ab
4 changed files with 73 additions and 1 deletions
8
discover_overlay.desktop
Normal file
8
discover_overlay.desktop
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
[Desktop Entry]
|
||||
Name=Discover Overlay
|
||||
Comment=Voice chat overlay
|
||||
Exec=discover-overlay
|
||||
Icon=discover_overlay
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Catergories=Network;
|
||||
53
discover_overlay/autostart.py
Normal file
53
discover_overlay/autostart.py
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
import sys
|
||||
import os
|
||||
import logging
|
||||
try:
|
||||
from xdg.BaseDirectory import xdg_config_home, xdg_data_home
|
||||
except ModuleNotFoundError:
|
||||
from xdg import XDG_CONFIG_HOME as xdg_config_home
|
||||
from xdg import XDG_DATA_HOME as xdg_data_home
|
||||
|
||||
|
||||
class Autostart:
|
||||
def __init__(self, app_name):
|
||||
if not app_name.endswith(".desktop"):
|
||||
app_name = "%s.desktop" % (app_name)
|
||||
self.app_name = app_name
|
||||
self.auto_locations = [os.path.join(
|
||||
xdg_config_home, 'autostart/'), '/etc/xdg/autostart/']
|
||||
self.desktop_locations = [os.path.join(
|
||||
xdg_data_home, 'applications/'), '/usr/share/applications/']
|
||||
self.auto = self.find_auto()
|
||||
self.desktop = self.find_desktop()
|
||||
logging.info("Autostart info : desktop %s auto %s" %
|
||||
(self.desktop, self.auto))
|
||||
|
||||
def find_auto(self):
|
||||
for p in self.auto_locations:
|
||||
file = os.path.join(p, self.app_name)
|
||||
if os.path.exists(file):
|
||||
return file
|
||||
return None
|
||||
|
||||
def find_desktop(self):
|
||||
for p in self.desktop_locations:
|
||||
file = os.path.join(p, self.app_name)
|
||||
if os.path.exists(file):
|
||||
return file
|
||||
return None
|
||||
|
||||
def set_autostart(self, b):
|
||||
if b and not self.auto:
|
||||
# Enable
|
||||
d = os.path.join(xdg_config_home, 'autostart')
|
||||
self.auto = os.path.join(d, self.app_name)
|
||||
os.symlink(self.desktop, self.auto)
|
||||
pass
|
||||
elif not b and self.auto:
|
||||
# Disable
|
||||
if os.path.islink(self.auto):
|
||||
os.remove(self.auto)
|
||||
pass
|
||||
|
||||
def is_auto(self):
|
||||
return True if self.auto else None
|
||||
|
|
@ -32,6 +32,7 @@ from .text_settings import TextSettingsWindow
|
|||
from .voice_overlay import VoiceOverlayWindow
|
||||
from .text_overlay import TextOverlayWindow
|
||||
from .discord_connector import DiscordConnector
|
||||
from .autostart import Autostart
|
||||
import logging
|
||||
|
||||
|
||||
|
|
@ -69,18 +70,25 @@ class Discover:
|
|||
menu = Gtk.Menu()
|
||||
vsettings_opt = Gtk.MenuItem.new_with_label("Voice Settings")
|
||||
tsettings_opt = Gtk.MenuItem.new_with_label("Text Settings")
|
||||
autostart_opt = Gtk.CheckMenuItem("Start on boot")
|
||||
autostart_opt.set_active(self.a.is_auto())
|
||||
close_opt = Gtk.MenuItem.new_with_label("Close")
|
||||
|
||||
menu.append(vsettings_opt)
|
||||
menu.append(tsettings_opt)
|
||||
menu.append(autostart_opt)
|
||||
menu.append(close_opt)
|
||||
|
||||
vsettings_opt.connect("activate", self.show_vsettings)
|
||||
tsettings_opt.connect("activate", self.show_tsettings)
|
||||
autostart_opt.connect("toggled", self.toggle_auto)
|
||||
close_opt.connect("activate", self.close)
|
||||
menu.show_all()
|
||||
return menu
|
||||
|
||||
def toggle_auto(self, button):
|
||||
self.a.set_autostart(button.get_active())
|
||||
|
||||
def show_menu(self, obj, button, time):
|
||||
self.menu.show_all()
|
||||
self.menu.popup(
|
||||
|
|
@ -96,6 +104,8 @@ class Discover:
|
|||
Gtk.main_quit()
|
||||
|
||||
def main(self):
|
||||
self.a = Autostart("discover_overlay")
|
||||
# a.set_autostart(True)
|
||||
self.create_gui()
|
||||
self.connection = DiscordConnector(
|
||||
self.text_settings, self.voice_settings,
|
||||
|
|
|
|||
3
setup.py
3
setup.py
|
|
@ -9,7 +9,7 @@ setup(
|
|||
name='discover-overlay',
|
||||
author='trigg',
|
||||
author_email='',
|
||||
version='0.1.1',
|
||||
version='0.2',
|
||||
description='Voice chat overlay',
|
||||
long_description=readme(),
|
||||
long_description_content_type='text/markdown',
|
||||
|
|
@ -17,6 +17,7 @@ setup(
|
|||
packages=find_packages(),
|
||||
include_package_data=True,
|
||||
data_files=[
|
||||
('share/applications', ['discover_overlay.desktop']),
|
||||
('share/icons', ['discover_overlay.png'])
|
||||
],
|
||||
install_requires=[
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue