- Add desktop actions for some RPC commands

- Add detection and special handling of bazzite autostart
- Detect running in a container and disable the autostart buttons
This commit is contained in:
trigg 2023-09-28 12:07:27 +01:00
parent 7e3d5cb9ac
commit 02f60e70b2
3 changed files with 83 additions and 2 deletions

View file

@ -68,3 +68,41 @@ class Autostart:
def is_auto(self):
"""Check if it's already set to auto-start"""
return True if self.auto else False
class BazziteAutostart:
"""A class to assist auto-start"""
def __init__(self):
self.auto= False
with open("/etc/default/discover-overlay") as f:
content = f.readlines()
for line in content:
if line.startswith("AUTO_LAUNCH_DISCOVER_OVERLAY="):
self.auto = int(line.split("=")[1]) > 0
log.info("Bazzite Autostart info : %s",
self.auto)
def set_autostart(self, enable):
"""Set or Unset auto-start state"""
if enable and not self.auto:
self.change_file("1")
elif not enable and self.auto:
self.change_file("0")
self.auto = enable
def change_file(self, value):
newcontent = []
with open("/etc/default/discover-overlay") as f:
content = f.readlines()
for line in content:
if line.startswith("AUTO_LAUNCH_DISCOVER_OVERLAY="):
newcontent.append( "AUTO_LAUNCH_DISCOVER_OVERLAY=%s\n" % value)
elif len(line)<2:
pass
else:
newcontent.append(line)
with open("/etc/default/discover-overlay", 'w') as f:
f.writelines(newcontent)
def is_auto(self):
"""Check if it's already set to auto-start"""
return self.auto

View file

@ -18,7 +18,7 @@ import pkg_resources
import sys
import os
import json
from .autostart import Autostart
from .autostart import Autostart, BazziteAutostart
from .draggable_window import DraggableWindow
from .draggable_window_wayland import DraggableWindowWayland
@ -38,13 +38,21 @@ class MainSettingsWindow():
def __init__(self, config_file, rpc_file, channel_file, args):
self.args = args
# Detect Bazzite autostart
self.alternative_autostart = os.path.exists("/etc/default/discover-overlay")
# Detect flatpak en
self.disable_autostart = 'container' in os.environ
self.steamos = False
self.voice_placement_window = None
self.text_placement_window = None
self.voice_advanced = False
self.tray = None # Systemtray as fallback
self.ind = None # AppIndicator
self.autostart_helper = Autostart("discover_overlay")
if self.alternative_autostart:
self.autostart_helper = BazziteAutostart()
else:
self.autostart_helper = Autostart("discover_overlay")
self.autostart_helper_conf = Autostart("discover_overlay_configure")
self.ind = None
self.guild_ids = []
@ -515,6 +523,10 @@ class MainSettingsWindow():
self.widget['core_run_conf_on_startup'].set_active(
self.autostart_helper_conf.is_auto())
if self.disable_autostart:
self.widget['core_run_on_startup'].set_sensitive(False)
self.widget['core_run_conf_on_startup'].set_sensitive(False)
self.widget['core_force_xshape'].set_active(
config.getboolean("general", "xshape", fallback=False))

View file

@ -7,3 +7,34 @@ Terminal=false
Type=Application
Categories=Utility;TelephonyTools
Keywords=Discord
Actions=Show;Hide;Mute;Unmute;Deaf;Undeaf
[Destkop Action Mute]
Exec=discover-overlay --rpc --mute
Name=Mute Self
StartupNotify=false
[Desktop Action Unmute]
Exec=discover-overlay --rpc --unmute
Name=Unmute Self
StartupNotify=false
[Desktop Action Hide]
Exec=discover-overlay --rpc --hide
Name=Hide Overlay
StartupNotify=false
[Desktop Action Show]
Exec=discover-overlay --rpc --show
Name=Show Overlay
StartupNotify=false
[Desktop Action Deaf]
Exec=discover-overlay --rpc --deaf
Name=Deafen Self
StartupNotify=false
[Desktop Action Undeaf]
Exec=discover-overlay --rpc --undeaf
Name=Undeafen Self
StartupNotify=false