Skip to content

Commit

Permalink
allow only one instance
Browse files Browse the repository at this point in the history
  • Loading branch information
Odizinne authored and Flora committed Jun 28, 2024
1 parent fa497bc commit 2800a73
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/BigPictureTV.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from enum import Enum
from PyQt5.QtWidgets import QApplication, QMainWindow, QDialog, QMessageBox, QSystemTrayIcon, QMenu, QAction
from PyQt5.QtGui import QIcon, QCursor
from PyQt5.QtCore import Qt, QTimer, QPoint, pyqtSignal
from PyQt5.QtCore import Qt, QTimer, QPoint, pyqtSignal, QSharedMemory
from PyQt5 import uic

class Mode(Enum):
Expand Down Expand Up @@ -371,11 +371,16 @@ def __init__(self, stylesheet=None):
self.setFixedSize(self.size())

if __name__ == '__main__':
shared_memory = QSharedMemory('BigPictureTVSharedMemory')

if shared_memory.attach() or not shared_memory.create(1):
sys.exit(0)

app = QApplication(sys.argv)
current_mode = read_current_mode()
constants = load_constants()

style_file = os.path.join(os.path.join(UI_FOLDER, 'style.qss'))
style_file = os.path.join(UI_FOLDER, 'style.qss')
if os.path.exists(style_file):
with open(style_file, 'r') as f:
app.setStyleSheet(f.read())
Expand Down Expand Up @@ -407,4 +412,4 @@ def update_mode_timer_interval(check_rate):
settings_window.show()
first_run = False

sys.exit(app.exec_())
sys.exit(app.exec_())

0 comments on commit 2800a73

Please sign in to comment.