- Added RPC file, monitor for changes
- Added PID file and if it is already locked then write args to RPC file - open configuration from args - option to '--close' and '--configure' - Added PIL and pidfile as dependencies - Added desktop files for --configure and --close - Fixed #75 - Fixed 78
This commit is contained in:
parent
cda5bc0c81
commit
8c50d3c2cc
5 changed files with 75 additions and 5 deletions
|
|
@ -12,7 +12,7 @@
|
|||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
import gi
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, GLib
|
||||
from gi.repository import Gtk, GLib, Gio
|
||||
import select
|
||||
from .voice_settings import VoiceSettingsWindow
|
||||
from .text_settings import TextSettingsWindow
|
||||
|
|
@ -21,10 +21,18 @@ from .text_overlay import TextOverlayWindow
|
|||
from .discord_connector import DiscordConnector
|
||||
from .autostart import Autostart
|
||||
import logging
|
||||
import pidfile
|
||||
import os
|
||||
import sys
|
||||
|
||||
try:
|
||||
from xdg.BaseDirectory import xdg_config_home
|
||||
except ModuleNotFoundError:
|
||||
from xdg import XDG_CONFIG_HOME as xdg_config_home
|
||||
|
||||
|
||||
class Discover:
|
||||
def __init__(self):
|
||||
def __init__(self, rpc_file, args):
|
||||
self.a = Autostart("discover_overlay")
|
||||
# a.set_autostart(True)
|
||||
self.create_gui()
|
||||
|
|
@ -33,12 +41,39 @@ class Discover:
|
|||
self.text_overlay, self.voice_overlay)
|
||||
self.connection.connect()
|
||||
GLib.timeout_add((1000 / 60), self.connection.do_read)
|
||||
self.rpc_file = rpc_file
|
||||
rpc_file = Gio.File.new_for_path(rpc_file)
|
||||
monitor = rpc_file.monitor_file(0, None)
|
||||
monitor.connect("changed", self.rpc_changed)
|
||||
self.do_args(args)
|
||||
|
||||
try:
|
||||
Gtk.main()
|
||||
except:
|
||||
pass
|
||||
|
||||
def do_args(self, data):
|
||||
if "--help" in data:
|
||||
pass
|
||||
elif "--about" in data:
|
||||
pass
|
||||
elif "--configure-voice" in data:
|
||||
self.show_vsettings()
|
||||
elif "--configure-text" in data:
|
||||
self.show_tsettings()
|
||||
elif "--configure" in data:
|
||||
self.show_tsettings()
|
||||
self.show_vsettings()
|
||||
elif "--close" in data:
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
def rpc_changed(self, a=None, b=None, c=None,d=None):
|
||||
with open (self.rpc_file, "r") as tfile:
|
||||
data=tfile.readlines()
|
||||
if len(data)>=1:
|
||||
self.do_args(data[0])
|
||||
|
||||
def create_gui(self):
|
||||
self.voice_overlay = VoiceOverlayWindow(self)
|
||||
self.text_overlay = TextOverlayWindow(self)
|
||||
|
|
@ -104,5 +139,21 @@ class Discover:
|
|||
|
||||
|
||||
def entrypoint():
|
||||
logging.getLogger().setLevel(logging.INFO)
|
||||
discover = Discover()
|
||||
configDir = os.path.join(xdg_config_home, "discover_overlay")
|
||||
os.makedirs(configDir, exist_ok=True)
|
||||
line = ""
|
||||
for arg in sys.argv[1:]:
|
||||
line = "%s %s" % (line, arg)
|
||||
pid_file = os.path.join(configDir, "discover_overlay.pid")
|
||||
rpc_file = os.path.join(configDir, "discover_overlay.rpc")
|
||||
try:
|
||||
with pidfile.PIDFile(pid_file):
|
||||
logging.getLogger().setLevel(logging.INFO)
|
||||
discover = Discover(rpc_file, line)
|
||||
except pidfile.AlreadyRunningError:
|
||||
logging.warn("Discover overlay is currently running")
|
||||
|
||||
with open(rpc_file, "w") as tfile:
|
||||
tfile.write(line)
|
||||
logging.warn("Sent RPC command")
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ class TextSettingsWindow(SettingsWindow):
|
|||
self.placement_window = None
|
||||
self.init_config()
|
||||
self.list_channels_keys = []
|
||||
self.list_channels = {}
|
||||
self.ignore_channel_change = False
|
||||
self.create_gui()
|
||||
|
||||
|
|
|
|||
8
discover_overlay_close.desktop
Normal file
8
discover_overlay_close.desktop
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
[Desktop Entry]
|
||||
Name=Discover Overlay - Close
|
||||
Comment=Close Discover Overlay
|
||||
Exec=discover-overlay --close
|
||||
Icon=discover-overlay
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Catergories=Network;
|
||||
8
discover_overlay_conf.desktop
Normal file
8
discover_overlay_conf.desktop
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
[Desktop Entry]
|
||||
Name=Discover Overlay - Config
|
||||
Comment=Open configuration for Discover Overlay
|
||||
Exec=discover-overlay --configure
|
||||
Icon=discover-overlay
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Catergories=Network;
|
||||
4
setup.py
4
setup.py
|
|
@ -17,7 +17,7 @@ setup(
|
|||
packages=find_packages(),
|
||||
include_package_data=True,
|
||||
data_files=[
|
||||
('share/applications', ['discover_overlay.desktop']),
|
||||
('share/applications', ['discover_overlay.desktop','discover_overlay_conf.desktop','discover_overlay_close.desktop']),
|
||||
('share/icons', ['discover-overlay.png'])
|
||||
],
|
||||
install_requires=[
|
||||
|
|
@ -25,6 +25,8 @@ setup(
|
|||
'websocket-client',
|
||||
'pyxdg',
|
||||
'requests',
|
||||
'python-pidfile',
|
||||
'pillow',
|
||||
],
|
||||
entry_points={
|
||||
'console_scripts': [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue