Added dirty start check, added images to plugin buttons, cleanup
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
|
||||
# Python imports
|
||||
import argparse, faulthandler, traceback
|
||||
from setproctitle import setproctitle
|
||||
|
@@ -54,6 +54,7 @@ class Controller(UIMixin, KeyboardSignalsMixin, IPCSignalsMixin, ExceptionHookMi
|
||||
if not settings.is_trace_debug():
|
||||
self.fm_controller.save_state()
|
||||
|
||||
settings.clear_pid()
|
||||
time.sleep(event_sleep_time)
|
||||
Gtk.main_quit()
|
||||
|
||||
|
@@ -50,13 +50,8 @@ class DesktopIconMixin:
|
||||
return None
|
||||
|
||||
def traverse_icons_folder(self, path, icon):
|
||||
alt_icon_path = ""
|
||||
|
||||
for (dirpath, dirnames, filenames) in os.walk(path):
|
||||
for file in filenames:
|
||||
appNM = "application-x-" + icon
|
||||
if icon in file or appNM in file:
|
||||
alt_icon_path = dirpath + "/" + file
|
||||
break
|
||||
|
||||
return alt_icon_path
|
||||
return f"{dirpath}/{file}"
|
||||
|
@@ -1,5 +1,5 @@
|
||||
# System import
|
||||
import os, threading, subprocess, shlex
|
||||
import os, threading, subprocess
|
||||
|
||||
# Lib imports
|
||||
|
||||
|
@@ -25,7 +25,7 @@ class Settings:
|
||||
FFMPG_THUMBNLR = f"{CONFIG_PATH}/ffmpegthumbnailer" # Thumbnail generator binary
|
||||
REMUX_FOLDER = f"{USER_HOME}/.remuxs" # Remuxed files folder
|
||||
|
||||
ICON_DIRS = ["/usr/share/pixmaps", "/usr/share/icons", f"{USER_HOME}/.icons" ,]
|
||||
ICON_DIRS = ["/usr/share/icons", f"{USER_HOME}/.icons" "/usr/share/pixmaps"]
|
||||
BASE_THUMBS_PTH = f"{USER_HOME}/.thumbnails" # Used for thumbnail generation
|
||||
ABS_THUMBS_PTH = f"{BASE_THUMBS_PTH}/normal" # Used for thumbnail generation
|
||||
STEAM_ICONS_PTH = f"{BASE_THUMBS_PTH}/steam_icons"
|
||||
|
@@ -38,8 +38,8 @@ class IPCServer:
|
||||
@daemon_threaded
|
||||
def create_ipc_listener(self) -> None:
|
||||
if self._conn_type == "socket":
|
||||
if os.path.exists(self._ipc_address):
|
||||
return
|
||||
if os.path.exists(self._ipc_address) and settings.is_dirty_start():
|
||||
os.unlink(self._ipc_address)
|
||||
|
||||
listener = Listener(address=self._ipc_address, family="AF_UNIX", authkey=self._ipc_authkey)
|
||||
elif "unsecured" not in self._conn_type:
|
||||
|
@@ -31,6 +31,7 @@ class Settings:
|
||||
self._KEY_BINDINGS = f"{self._CONFIG_PATH}/key-bindings.json"
|
||||
self._DEFAULT_ICONS = f"{self._CONFIG_PATH}/icons"
|
||||
self._WINDOW_ICON = f"{self._DEFAULT_ICONS}/{app_name.lower()}.png"
|
||||
self._PID_FILE = f"{self._CONFIG_PATH}/solarfm.pid"
|
||||
self._ICON_THEME = Gtk.IconTheme.get_default()
|
||||
|
||||
if not os.path.exists(self._CONFIG_PATH):
|
||||
@@ -65,6 +66,44 @@ class Settings:
|
||||
|
||||
self._trace_debug = False
|
||||
self._debug = False
|
||||
self._dirty_start = False
|
||||
|
||||
self._check_for_dirty_state()
|
||||
|
||||
|
||||
def _check_for_dirty_state(self):
|
||||
if not os.path.exists(self._PID_FILE):
|
||||
self._write_new_pid()
|
||||
else:
|
||||
with open(self._PID_FILE, "r") as _pid:
|
||||
pid = _pid.readline().strip()
|
||||
if pid not in ("", None):
|
||||
self._check_alive_status(int(pid))
|
||||
else:
|
||||
self._write_new_pid()
|
||||
|
||||
""" Check For the existence of a unix pid. """
|
||||
def _check_alive_status(self, pid):
|
||||
print(f"PID Found: {pid}")
|
||||
try:
|
||||
os.kill(pid, 0)
|
||||
except OSError:
|
||||
print("SolarFM Is starting dirty...")
|
||||
self._dirty_start = True
|
||||
self._write_new_pid()
|
||||
|
||||
print("PID is alive... Let downstream errors handle app closure.")
|
||||
|
||||
def _write_new_pid(self):
|
||||
pid = os.getpid()
|
||||
self._write_pid(pid)
|
||||
|
||||
def _clean_pid(self):
|
||||
os.unlink(self._PID_FILE)
|
||||
|
||||
def _write_pid(self, pid):
|
||||
with open(self._PID_FILE, "w") as _pid:
|
||||
_pid.write(f"{pid}")
|
||||
|
||||
|
||||
def create_window(self) -> None:
|
||||
@@ -104,6 +143,7 @@ class Settings:
|
||||
|
||||
return monitors
|
||||
|
||||
|
||||
def get_main_window(self) -> Gtk.ApplicationWindow: return self._main_window
|
||||
def get_builder(self) -> Gtk.Builder: return self._builder
|
||||
def get_logger(self) -> Logger: return self._logger
|
||||
@@ -117,6 +157,8 @@ class Settings:
|
||||
|
||||
def is_trace_debug(self) -> str: return self._trace_debug
|
||||
def is_debug(self) -> str: return self._debug
|
||||
def is_dirty_start(self) -> bool: return self._dirty_start
|
||||
def clear_pid(self): self._clean_pid()
|
||||
|
||||
|
||||
def set_trace_debug(self, trace_debug):
|
||||
|
Reference in New Issue
Block a user