- Switch to signal-exit for most exits

This commit is contained in:
trigg 2024-07-09 02:15:10 +01:00
parent 24e815b85e
commit debad09705
3 changed files with 9 additions and 8 deletions

View file

@ -23,7 +23,6 @@ CHANNEL - Often called 'Rooms'. Both voice and text channels are types of channe
import select
import time
import json
import sys
import logging
import calendar
import websocket
@ -110,7 +109,7 @@ class DiscordConnector:
log.error("No access token in json response")
log.error(response.text)
log.error("The user most likely denied permission for this app")
sys.exit(1)
self.discover.exit()
def set_channel(self, channel, guild, need_req=True):
"""
@ -280,7 +279,7 @@ class DiscordConnector:
self.get_access_token_stage2(j["data"]["code"])
else:
log.error("Authorization rejected")
sys.exit(0)
self.discover.exit()
return
elif j["cmd"] == "DISPATCH":
if j["evt"] == "READY":

View file

@ -125,7 +125,7 @@ class Discover:
if normal_close:
sys.exit(0)
if "--close" in data or "-x" in data:
os.kill(os.getpid(), signal.SIGTERM)
self.exit()
if "--steamos" in data or "-s" in data:
self.steamos = True
if "--hide" in data:
@ -156,6 +156,9 @@ class Discover:
if self.connection:
self.connection.request_text_rooms_for_guild(match.group(1))
def exit(self):
os.kill(os.getpid(), signal.SIGTERM)
def config_set(self, context, key, value):
"""Set a config value and save to disk"""
config = self.config()

View file

@ -15,7 +15,6 @@ Overlay parent class. Helpful if we need more overlay
types without copy-and-pasting too much code
"""
import os
import sys
import logging
import gi
import cairo
@ -75,7 +74,7 @@ class OverlayWindow(Gtk.Window):
if not self.get_display().supports_input_shapes():
log.info(
"Input shapes not available. Quitting")
sys.exit(1)
self.discover.exit()
if visual:
# Set the visual even if we can't use it right now
self.set_visual(visual)
@ -125,7 +124,7 @@ class OverlayWindow(Gtk.Window):
def window_exited(self, _window=None):
"""Window closed. Exit app"""
sys.exit(1)
self.discover.exit()
def set_gamescope_xatom(self, enabled):
"""Set Gamescope XAtom to identify self as an overlay candidate"""
@ -160,7 +159,7 @@ class OverlayWindow(Gtk.Window):
log.info(
"GTK Layer Shell is not supported on this wayland compositor")
log.info("Currently not possible: Gnome, Weston")
sys.exit(0)
self.discover.exit()
if not GtkLayerShell.is_layer_window(self):
GtkLayerShell.init_for_window(self)
GtkLayerShell.set_layer(self, GtkLayerShell.Layer.OVERLAY)