diff --git a/.vscode/tasks.json b/.vscode/tasks.json deleted file mode 100644 index 54231dc..0000000 --- a/.vscode/tasks.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "version": "2.0.0", - "tasks": [ - { - "label": "Build with cx_Freeze", - "type": "shell", - "command": "${command:python.interpreterPath}", - "args": [ - "src/setup.py", - "build" - ], - "group": { - "kind": "build", - "isDefault": true - }, - "presentation": { - "echo": true, - "reveal": "always", - "focus": false, - "panel": "shared" - }, - "problemMatcher": [] - } - ] -} diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 30e3f6a..0000000 Binary files a/requirements.txt and /dev/null differ diff --git a/src/BigPictureTV.py b/src/BigPictureTV.py deleted file mode 100644 index cb6a719..0000000 --- a/src/BigPictureTV.py +++ /dev/null @@ -1,310 +0,0 @@ -import os -import sys -import json -from PyQt6.QtWidgets import QApplication, QSystemTrayIcon, QMenu, QMainWindow, QMessageBox -from PyQt6.QtGui import QIcon, QAction -from PyQt6.QtCore import Qt, QTimer, QSharedMemory, QTranslator, QLocale -from settings_window import Ui_SettingsWindow -from tooltiped_slider import TooltipedSlider -import audio_manager as AudioManager -import mode_manager as ModeManager -import shortcut_manager as ShortcutManager -import color_utils as ColorUtils -import utils - -SETTINGS_FILE = os.path.join(os.environ["APPDATA"], "BigPictureTV", "settings.json") -ICONS_FOLDER = "icons" if getattr(sys, "frozen", False) else os.path.join(os.path.dirname(__file__), "icons") - - -class BigPictureTV(QMainWindow): - def __init__(self): - super().__init__() - self.ui = Ui_SettingsWindow() - self.ui.setupUi(self) - self.setWindowIcon(QIcon(os.path.join(ICONS_FOLDER, f"icon_desktop_{utils.get_theme()}.png"))) - self.current_mode = ModeManager.read_current_mode() - self.settings = {} - self.first_run = False - self.paused = False - self.set_fusion_frames() - self.init_checkrate_tooltipedslider() - self.populate_comboboxes() - self.load_settings() - self.setup_ui_connections() - self.get_audio_capabilities() - self.tray_icon = self.create_tray_icon() - self.timer = QTimer() - self.timer.timeout.connect(self.update_mode) - self.update_mode_timer_interval(self.ui.checkrate_slider.value()) - if self.first_run: - self.show() - self.first_run = False - - def set_fusion_frames(self): - if app.style().objectName() == "fusion": - ColorUtils.set_frame_color_based_on_window(self, self.ui.actions_frame) - ColorUtils.set_frame_color_based_on_window(self, self.ui.monitor_frame) - ColorUtils.set_frame_color_based_on_window(self, self.ui.audio_frame) - ColorUtils.set_frame_color_based_on_window(self, self.ui.settings_frame) - - def setup_ui_connections(self): - self.ui.disable_audio_checkbox.stateChanged.connect(self.handle_disableaudio_checkbox_state_changed) - self.ui.gamemode_audio_lineedit.textChanged.connect(self.save_settings) - self.ui.desktop_audio_lineedit.textChanged.connect(self.save_settings) - self.ui.startup_checkbox.setChecked(ShortcutManager.check_startup_shortcut()) - self.ui.close_discord_checkbox.stateChanged.connect(self.save_settings) - self.ui.performance_powerplan_checkbox.stateChanged.connect(self.save_settings) - self.ui.close_discord_checkbox.setEnabled(utils.is_discord_installed()) - self.ui.close_discord_label.setEnabled(utils.is_discord_installed()) - self.ui.startup_checkbox.stateChanged.connect(self.handle_startup_checkbox_state_changed) - self.ui.gamemode_monitor_combobox.currentIndexChanged.connect(self.save_settings) - self.ui.desktop_monitor_combobox.currentIndexChanged.connect(self.save_settings) - self.ui.checkrate_slider.valueChanged.connect(self.handle_checkrate_slider_value_changed) - self.ui.checkrate_slider.sliderReleased.connect(self.save_settings) - self.ui.install_audio_button.clicked.connect(self.handle_audio_button_clicked) - self.ui.disable_monitor_checkbox.stateChanged.connect(self.handle_disablemonitor_checkbox_state_changed) - - def populate_comboboxes(self): - self.ui.gamemode_monitor_combobox.addItem(self.tr("External")) - self.ui.gamemode_monitor_combobox.addItem(self.tr("Clone")) - self.ui.desktop_monitor_combobox.addItem(self.tr("Internal")) - self.ui.desktop_monitor_combobox.addItem(self.tr("Extend")) - - def init_checkrate_tooltipedslider(self): - self.checkrate_tooltipedslider = TooltipedSlider(Qt.Orientation.Horizontal, self.ui.centralwidget) - layout = self.ui.settings_layout - index = layout.indexOf(self.ui.checkrate_label) - position = layout.getItemPosition(index) - row = position[0] - column = position[1] - layout.addWidget(self.checkrate_tooltipedslider, row, column + 1) - self.ui.checkrate_slider.deleteLater() - self.ui.checkrate_slider = self.checkrate_tooltipedslider - self.ui.checkrate_slider.setTickInterval(100) - self.ui.checkrate_slider.setRange(100, 1000) - - def handle_startup_checkbox_state_changed(self, state): - ShortcutManager.manage_startup_shortcut(state) - - def handle_audio_button_clicked(self): - self.ui.install_audio_button.setEnabled(False) - status, message = utils.install_audio_module() - if status == "Success": - QMessageBox.information(self, status, message) - else: - QMessageBox.critical(self, status, message) - self.ui.install_audio_button.setEnabled(True) - - self.get_audio_capabilities() - - def handle_checkrate_slider_value_changed(self, value): - remainder = value % 100 - if remainder != 0: - if remainder < 50: - value -= remainder - else: - value += 100 - remainder - self.ui.checkrate_slider.setValue(value) - - self.update_mode_timer_interval(value) - - def handle_disableaudio_checkbox_state_changed(self, state): - self.toggle_audio_settings(not state) - self.save_settings() - - def handle_disablemonitor_checkbox_state_changed(self, state): - self.toggle_monitor_settings(not state) - self.save_settings() - - def toggle_audio_settings(self, enabled): - self.ui.desktop_audio_lineedit.setEnabled(enabled) - self.ui.desktop_audio_label.setEnabled(enabled) - self.ui.gamemode_audio_lineedit.setEnabled(enabled) - self.ui.gamemode_audio_label.setEnabled(enabled) - self.ui.audio_output_label.setEnabled(enabled) - - def toggle_monitor_settings(self, enabled): - self.ui.gamemode_monitor_combobox.setEnabled(enabled) - self.ui.desktop_monitor_combobox.setEnabled(enabled) - self.ui.gamemode_monitor_label.setEnabled(enabled) - self.ui.desktop_monitor_label.setEnabled(enabled) - self.ui.monitor_configuration_label.setEnabled(enabled) - - def create_default_settings(self): - self.settings = { - "gamemode_audio": "TV", - "desktop_audio": "Headset", - "disable_audio_switch": False, - "checkrate": 1000, - } - self.apply_settings() - self.save_settings() - self.first_run = True - - def load_settings(self): - if not os.path.exists(os.path.dirname(SETTINGS_FILE)): - os.makedirs(os.path.dirname(SETTINGS_FILE)) - if not os.path.exists(SETTINGS_FILE): - self.create_default_settings() - else: - with open(SETTINGS_FILE, "r") as f: - self.settings = json.load(f) - self.apply_settings() - - def apply_settings(self): - self.ui.gamemode_audio_lineedit.setText(self.settings.get("gamemode_audio", "")) - self.ui.desktop_audio_lineedit.setText(self.settings.get("desktop_audio", "")) - self.ui.disable_audio_checkbox.setChecked(self.settings.get("disable_audio_switch", False)) - self.ui.checkrate_slider.setValue(self.settings.get("checkrate", 1000)) - self.ui.close_discord_checkbox.setChecked(self.settings.get("discord_action", False)) - self.ui.performance_powerplan_checkbox.setChecked(self.settings.get("powerplan_action", False)) - self.ui.gamemode_monitor_combobox.setCurrentIndex(self.settings.get("gamemode_monitor", 0)) - self.ui.desktop_monitor_combobox.setCurrentIndex(self.settings.get("desktop_monitor", 0)) - self.ui.disable_monitor_checkbox.setChecked(self.settings.get("disable_monitor_switch", False)) - self.toggle_audio_settings(not self.ui.disable_audio_checkbox.isChecked()) - self.toggle_monitor_settings(not self.ui.disable_monitor_checkbox.isChecked()) - - def save_settings(self): - self.settings = { - "gamemode_audio": self.ui.gamemode_audio_lineedit.text(), - "desktop_audio": self.ui.desktop_audio_lineedit.text(), - "disable_audio_switch": self.ui.disable_audio_checkbox.isChecked(), - "checkrate": self.ui.checkrate_slider.value(), - "discord_action": self.ui.close_discord_checkbox.isChecked(), - "powerplan_action": self.ui.performance_powerplan_checkbox.isChecked(), - "gamemode_monitor": self.ui.gamemode_monitor_combobox.currentIndex(), - "desktop_monitor": self.ui.desktop_monitor_combobox.currentIndex(), - "disable_monitor_switch": self.ui.disable_monitor_checkbox.isChecked(), - } - os.makedirs(os.path.dirname(SETTINGS_FILE), exist_ok=True) - with open(SETTINGS_FILE, "w") as f: - json.dump(self.settings, f, indent=4) - - def switch_mode(self, mode): - if mode == self.current_mode: - return - - self.current_mode = mode - self.handle_monitor_changes(self.current_mode) - self.handle_actions(self.current_mode) - self.handle_audio_changes(self.current_mode) - ModeManager.write_current_mode(self.current_mode) - - if self.tray_icon: - variant = "gamemode" if self.current_mode == ModeManager.Mode.GAMEMODE else "desktop" - self.tray_icon.setIcon(QIcon(os.path.join(ICONS_FOLDER, f"icon_{variant}_{utils.get_theme()}.png"))) - self.tray_icon.setContextMenu(self.create_menu()) - - def handle_monitor_changes(self, mode): - if not self.ui.disable_monitor_checkbox.isChecked(): - if mode == ModeManager.Mode.GAMEMODE and self.ui.gamemode_monitor_combobox.currentIndex() == 0: - monitor_mode = "/external" - elif mode == ModeManager.Mode.GAMEMODE and self.ui.gamemode_monitor_combobox.currentIndex() == 1: - monitor_mode = "/clone" - elif mode == ModeManager.Mode.DESKTOP and self.ui.desktop_monitor_combobox.currentIndex() == 0: - monitor_mode = "/internal" - elif mode == ModeManager.Mode.DESKTOP and self.ui.desktop_monitor_combobox.currentIndex() == 1: - monitor_mode = "/extend" - utils.run_displayswitch(monitor_mode) - - def handle_actions(self, mode): - if self.ui.close_discord_checkbox.isChecked(): - utils.close_discord() if mode == ModeManager.Mode.GAMEMODE else utils.start_discord() - - if self.ui.performance_powerplan_checkbox.isChecked(): - if mode == ModeManager.Mode.GAMEMODE: - utils.switch_power_plan("8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c") # High Performance - else: - utils.switch_power_plan("381b4222-f694-41f0-9685-ff5bb260df2e") # Balanced - - def handle_audio_changes(self, mode): - if not self.ui.disable_audio_checkbox.isChecked(): - gamemode_audio = self.ui.gamemode_audio_lineedit.text() - desktop_audio = self.ui.desktop_audio_lineedit.text() - AudioManager.switch_audio(gamemode_audio if mode == ModeManager.Mode.GAMEMODE else desktop_audio) - - def get_audio_capabilities(self): - if not utils.is_audio_device_cmdlets_installed(): - self.ui.disable_audio_checkbox.setChecked(True) - self.ui.disable_audio_checkbox.setEnabled(False) - self.toggle_audio_settings(False) - else: - self.ui.disable_audio_checkbox.setEnabled(True) - self.ui.install_audio_button.setVisible(False) - if not self.ui.disable_audio_checkbox.isChecked(): - self.toggle_audio_settings(True) - self.adjustSize() - - def update_mode(self): - if ( - utils.is_bigpicture_running() - and self.current_mode != ModeManager.Mode.GAMEMODE - and not utils.is_sunshine_stream_active() - ): - self.switch_mode(ModeManager.Mode.GAMEMODE) - elif not utils.is_bigpicture_running() and self.current_mode != ModeManager.Mode.DESKTOP: - self.switch_mode(ModeManager.Mode.DESKTOP) - - def update_mode_timer_interval(self, check_rate): - self.timer.setInterval(check_rate) - self.timer.start() - - def create_tray_icon(self): - tray_icon = QSystemTrayIcon(QIcon(os.path.join(ICONS_FOLDER, f"icon_desktop_{utils.get_theme()}.png"))) - tray_icon.setToolTip("BigPictureTV") - tray_icon.setContextMenu(self.create_menu()) - tray_icon.show() - return tray_icon - - def create_menu(self): - menu = QMenu() - pause_resume_action = QAction(self.tr("Resume detection") if self.paused else self.tr("Pause detection"), menu) - pause_resume_action.triggered.connect(self.toggle_detection) - settings_action = QAction(self.tr("Settings"), menu) - settings_action.triggered.connect(self.show) - exit_action = QAction(self.tr("Exit"), menu) - exit_action.triggered.connect(QApplication.quit) - - menu.addAction(pause_resume_action) - menu.addAction(settings_action) - menu.addAction(exit_action) - - return menu - - def toggle_detection(self): - self.paused = not self.paused - if self.paused: - self.timer.stop() - self.tray_icon.setToolTip("BigPictureTV (Paused)") - else: - self.timer.start() - self.tray_icon.setToolTip("BigPictureTV") - self.tray_icon.setContextMenu(self.create_menu()) - - def closeEvent(self, event): - event.ignore() - self.hide() - - -if __name__ == "__main__": - shared_memory = QSharedMemory("BigPictureTVSharedMemory") - if shared_memory.attach() or not shared_memory.create(1): - sys.exit(0) - - app = QApplication(sys.argv) - if utils.is_windows_10(): - app.setStyle("Fusion") - - translator = QTranslator() - locale_name = QLocale.system().name() - locale = locale_name[:2] - if locale: - file_name = f"tr/bigpicturetv_{locale}.qm" - else: - file_name = None - - if file_name and translator.load(file_name): - app.installTranslator(translator) - - big_picture_tv = BigPictureTV() - sys.exit(app.exec()) diff --git a/src/audio_manager.py b/src/audio_manager.py deleted file mode 100644 index cb945f9..0000000 --- a/src/audio_manager.py +++ /dev/null @@ -1,34 +0,0 @@ -import subprocess -import re -import time - - -def get_audio_devices(): - cmd = "powershell Get-AudioDevice -list" - output = subprocess.check_output(cmd, shell=True, text=True) - devices = re.findall(r"Index\s+:\s+(\d+)\s+.*?Name\s+:\s+(.*?)\s+ID\s+:\s+{(.*?)}", output, re.DOTALL) - return devices - - -def set_audio_device(device_name, devices): - device_words = device_name.lower().split() - for index, name, _ in devices: - if all(word in name.lower() for word in device_words): - cmd = f"powershell set-audiodevice -index {index}" - result = subprocess.run(cmd, shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) - return result.returncode == 0 - return False - - -def switch_audio(audio_output): - devices = get_audio_devices() - success = set_audio_device(audio_output, devices) - retries = 0 - while not success and retries < 5: - print("Failed to switch audio, retrying...") - time.sleep(1) - devices = get_audio_devices() - success = set_audio_device(audio_output, devices) - retries += 1 - if not success: - print("Failed to switch audio after 10 attempts.") diff --git a/src/color_utils.py b/src/color_utils.py deleted file mode 100644 index a85c389..0000000 --- a/src/color_utils.py +++ /dev/null @@ -1,27 +0,0 @@ -from PyQt6.QtGui import QColor, QPalette, QBrush - - -def set_frame_color_based_on_window(window, frame): - def adjust_color(color, factor): - r, g, b, a = color.red(), color.green(), color.blue(), color.alpha() - r = min(max(int(r * factor), 0), 255) - g = min(max(int(g * factor), 0), 255) - b = min(max(int(b * factor), 0), 255) - return QColor(r, g, b, a) - - def is_dark_mode(color): - r, g, b = color.red(), color.green(), color.blue() - brightness = (r + g + b) / 3 - return brightness < 127 - - main_bg_color = window.palette().color(QPalette.ColorRole.Window) - - if is_dark_mode(main_bg_color): - frame_bg_color = adjust_color(main_bg_color, 1.5) - else: - frame_bg_color = adjust_color(main_bg_color, 0.95) - - palette = frame.palette() - palette.setBrush(QPalette.ColorRole.Window, QBrush(frame_bg_color)) - frame.setAutoFillBackground(True) - frame.setPalette(palette) diff --git a/src/icons/icon.ico b/src/icons/icon.ico deleted file mode 100644 index 6b33cd4..0000000 Binary files a/src/icons/icon.ico and /dev/null differ diff --git a/src/icons/icon_desktop_dark.png b/src/icons/icon_desktop_dark.png deleted file mode 100644 index b80620d..0000000 Binary files a/src/icons/icon_desktop_dark.png and /dev/null differ diff --git a/src/icons/icon_desktop_light.png b/src/icons/icon_desktop_light.png deleted file mode 100644 index 8c862fd..0000000 Binary files a/src/icons/icon_desktop_light.png and /dev/null differ diff --git a/src/icons/icon_gamemode_dark.png b/src/icons/icon_gamemode_dark.png deleted file mode 100644 index a4bd8dc..0000000 Binary files a/src/icons/icon_gamemode_dark.png and /dev/null differ diff --git a/src/icons/icon_gamemode_light.png b/src/icons/icon_gamemode_light.png deleted file mode 100644 index ab673cb..0000000 Binary files a/src/icons/icon_gamemode_light.png and /dev/null differ diff --git a/src/mode_manager.py b/src/mode_manager.py deleted file mode 100644 index 0466bad..0000000 --- a/src/mode_manager.py +++ /dev/null @@ -1,26 +0,0 @@ -import os -from enum import Enum - - -class Mode(Enum): - DESKTOP = 1 - GAMEMODE = 2 - - -def get_mode_file_path(): - app_data_folder = os.path.join(os.environ["APPDATA"], "BigPictureTV") - if not os.path.exists(app_data_folder): - os.makedirs(app_data_folder) - return os.path.join(app_data_folder, "current_mode.txt") - - -def read_current_mode(): - return Mode.GAMEMODE if os.path.exists(get_mode_file_path()) else Mode.DESKTOP - - -def write_current_mode(current_mode): - file_path = get_mode_file_path() - if current_mode == Mode.GAMEMODE: - open(file_path, "w").close() - elif current_mode == Mode.DESKTOP and os.path.exists(file_path): - os.remove(file_path) diff --git a/src/settings_window.py b/src/settings_window.py deleted file mode 100644 index 3877ed1..0000000 --- a/src/settings_window.py +++ /dev/null @@ -1,225 +0,0 @@ -# Form implementation generated from reading ui file '.\src\ui\settings_window.ui' -# -# Created by: PyQt6 UI code generator 6.7.0 -# -# WARNING: Any manual changes made to this file will be lost when pyuic6 is -# run again. Do not edit this file unless you know what you are doing. - - -from PyQt6 import QtCore, QtGui, QtWidgets - - -class Ui_SettingsWindow(object): - def setupUi(self, SettingsWindow): - SettingsWindow.setObjectName("SettingsWindow") - SettingsWindow.resize(452, 480) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.Preferred) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(SettingsWindow.sizePolicy().hasHeightForWidth()) - SettingsWindow.setSizePolicy(sizePolicy) - SettingsWindow.setMinimumSize(QtCore.QSize(452, 0)) - self.centralwidget = QtWidgets.QWidget(parent=SettingsWindow) - self.centralwidget.setObjectName("centralwidget") - self.gridLayout_2 = QtWidgets.QGridLayout(self.centralwidget) - self.gridLayout_2.setObjectName("gridLayout_2") - self.audio_output_label = QtWidgets.QLabel(parent=self.centralwidget) - self.audio_output_label.setMinimumSize(QtCore.QSize(0, 25)) - font = QtGui.QFont() - font.setBold(True) - self.audio_output_label.setFont(font) - self.audio_output_label.setObjectName("audio_output_label") - self.gridLayout_2.addWidget(self.audio_output_label, 2, 0, 1, 1) - self.label_3 = QtWidgets.QLabel(parent=self.centralwidget) - self.label_3.setMinimumSize(QtCore.QSize(0, 25)) - font = QtGui.QFont() - font.setBold(True) - self.label_3.setFont(font) - self.label_3.setObjectName("label_3") - self.gridLayout_2.addWidget(self.label_3, 4, 0, 1, 2) - self.actions_frame = QtWidgets.QFrame(parent=self.centralwidget) - self.actions_frame.setFrameShape(QtWidgets.QFrame.Shape.StyledPanel) - self.actions_frame.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken) - self.actions_frame.setObjectName("actions_frame") - self.gridLayout_3 = QtWidgets.QGridLayout(self.actions_frame) - self.gridLayout_3.setContentsMargins(9, 9, 9, 9) - self.gridLayout_3.setSpacing(12) - self.gridLayout_3.setObjectName("gridLayout_3") - self.close_discord_checkbox = QtWidgets.QCheckBox(parent=self.actions_frame) - self.close_discord_checkbox.setMinimumSize(QtCore.QSize(0, 25)) - self.close_discord_checkbox.setLayoutDirection(QtCore.Qt.LayoutDirection.RightToLeft) - self.close_discord_checkbox.setText("") - self.close_discord_checkbox.setObjectName("close_discord_checkbox") - self.gridLayout_3.addWidget(self.close_discord_checkbox, 0, 1, 1, 1) - self.close_discord_label = QtWidgets.QLabel(parent=self.actions_frame) - self.close_discord_label.setMinimumSize(QtCore.QSize(0, 25)) - self.close_discord_label.setObjectName("close_discord_label") - self.gridLayout_3.addWidget(self.close_discord_label, 0, 0, 1, 1) - self.performance_powerplan_label = QtWidgets.QLabel(parent=self.actions_frame) - self.performance_powerplan_label.setMinimumSize(QtCore.QSize(0, 25)) - self.performance_powerplan_label.setObjectName("performance_powerplan_label") - self.gridLayout_3.addWidget(self.performance_powerplan_label, 1, 0, 1, 1) - self.performance_powerplan_checkbox = QtWidgets.QCheckBox(parent=self.actions_frame) - self.performance_powerplan_checkbox.setMinimumSize(QtCore.QSize(0, 25)) - self.performance_powerplan_checkbox.setLayoutDirection(QtCore.Qt.LayoutDirection.RightToLeft) - self.performance_powerplan_checkbox.setText("") - self.performance_powerplan_checkbox.setObjectName("performance_powerplan_checkbox") - self.gridLayout_3.addWidget(self.performance_powerplan_checkbox, 1, 1, 1, 1) - self.gridLayout_2.addWidget(self.actions_frame, 5, 0, 1, 2) - self.monitor_frame = QtWidgets.QFrame(parent=self.centralwidget) - self.monitor_frame.setFrameShape(QtWidgets.QFrame.Shape.StyledPanel) - self.monitor_frame.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken) - self.monitor_frame.setObjectName("monitor_frame") - self.gridLayout_4 = QtWidgets.QGridLayout(self.monitor_frame) - self.gridLayout_4.setContentsMargins(9, 9, 9, 9) - self.gridLayout_4.setSpacing(12) - self.gridLayout_4.setObjectName("gridLayout_4") - self.gamemode_monitor_combobox = QtWidgets.QComboBox(parent=self.monitor_frame) - self.gamemode_monitor_combobox.setMinimumSize(QtCore.QSize(0, 25)) - self.gamemode_monitor_combobox.setSizeAdjustPolicy(QtWidgets.QComboBox.SizeAdjustPolicy.AdjustToContents) - self.gamemode_monitor_combobox.setObjectName("gamemode_monitor_combobox") - self.gridLayout_4.addWidget(self.gamemode_monitor_combobox, 0, 2, 1, 1) - self.desktop_monitor_combobox = QtWidgets.QComboBox(parent=self.monitor_frame) - self.desktop_monitor_combobox.setMinimumSize(QtCore.QSize(0, 25)) - self.desktop_monitor_combobox.setObjectName("desktop_monitor_combobox") - self.gridLayout_4.addWidget(self.desktop_monitor_combobox, 1, 2, 1, 1) - self.desktop_monitor_label = QtWidgets.QLabel(parent=self.monitor_frame) - self.desktop_monitor_label.setMinimumSize(QtCore.QSize(0, 25)) - self.desktop_monitor_label.setObjectName("desktop_monitor_label") - self.gridLayout_4.addWidget(self.desktop_monitor_label, 1, 0, 1, 1) - self.gamemode_monitor_label = QtWidgets.QLabel(parent=self.monitor_frame) - self.gamemode_monitor_label.setMinimumSize(QtCore.QSize(0, 25)) - self.gamemode_monitor_label.setObjectName("gamemode_monitor_label") - self.gridLayout_4.addWidget(self.gamemode_monitor_label, 0, 0, 1, 1) - spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum) - self.gridLayout_4.addItem(spacerItem, 0, 1, 1, 1) - self.gridLayout_2.addWidget(self.monitor_frame, 3, 1, 1, 1) - self.monitor_configuration_label = QtWidgets.QLabel(parent=self.centralwidget) - self.monitor_configuration_label.setMinimumSize(QtCore.QSize(0, 25)) - font = QtGui.QFont() - font.setBold(True) - self.monitor_configuration_label.setFont(font) - self.monitor_configuration_label.setObjectName("monitor_configuration_label") - self.gridLayout_2.addWidget(self.monitor_configuration_label, 2, 1, 1, 1) - self.audio_frame = QtWidgets.QFrame(parent=self.centralwidget) - self.audio_frame.setFrameShape(QtWidgets.QFrame.Shape.StyledPanel) - self.audio_frame.setObjectName("audio_frame") - self.gridLayout = QtWidgets.QGridLayout(self.audio_frame) - self.gridLayout.setContentsMargins(9, 9, 9, 9) - self.gridLayout.setSpacing(12) - self.gridLayout.setObjectName("gridLayout") - self.gamemode_audio_label = QtWidgets.QLabel(parent=self.audio_frame) - self.gamemode_audio_label.setMinimumSize(QtCore.QSize(0, 25)) - self.gamemode_audio_label.setObjectName("gamemode_audio_label") - self.gridLayout.addWidget(self.gamemode_audio_label, 0, 0, 1, 1) - self.desktop_audio_label = QtWidgets.QLabel(parent=self.audio_frame) - self.desktop_audio_label.setMinimumSize(QtCore.QSize(0, 25)) - self.desktop_audio_label.setObjectName("desktop_audio_label") - self.gridLayout.addWidget(self.desktop_audio_label, 1, 0, 1, 1) - self.desktop_audio_lineedit = QtWidgets.QLineEdit(parent=self.audio_frame) - self.desktop_audio_lineedit.setMinimumSize(QtCore.QSize(0, 25)) - self.desktop_audio_lineedit.setAutoFillBackground(False) - self.desktop_audio_lineedit.setFrame(True) - self.desktop_audio_lineedit.setObjectName("desktop_audio_lineedit") - self.gridLayout.addWidget(self.desktop_audio_lineedit, 1, 1, 1, 1) - self.gamemode_audio_lineedit = QtWidgets.QLineEdit(parent=self.audio_frame) - self.gamemode_audio_lineedit.setMinimumSize(QtCore.QSize(0, 25)) - self.gamemode_audio_lineedit.setAutoFillBackground(False) - self.gamemode_audio_lineedit.setFrame(True) - self.gamemode_audio_lineedit.setObjectName("gamemode_audio_lineedit") - self.gridLayout.addWidget(self.gamemode_audio_lineedit, 0, 1, 1, 1) - self.gridLayout_2.addWidget(self.audio_frame, 3, 0, 1, 1) - self.settings_frame = QtWidgets.QFrame(parent=self.centralwidget) - self.settings_frame.setFrameShape(QtWidgets.QFrame.Shape.StyledPanel) - self.settings_frame.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken) - self.settings_frame.setObjectName("settings_frame") - self.settings_layout = QtWidgets.QGridLayout(self.settings_frame) - self.settings_layout.setContentsMargins(9, 9, 9, 9) - self.settings_layout.setSpacing(12) - self.settings_layout.setObjectName("settings_layout") - self.install_audio_button = QtWidgets.QPushButton(parent=self.settings_frame) - self.install_audio_button.setMinimumSize(QtCore.QSize(0, 25)) - self.install_audio_button.setObjectName("install_audio_button") - self.settings_layout.addWidget(self.install_audio_button, 0, 0, 1, 2) - self.checkrate_label = QtWidgets.QLabel(parent=self.settings_frame) - self.checkrate_label.setMinimumSize(QtCore.QSize(0, 25)) - self.checkrate_label.setObjectName("checkrate_label") - self.settings_layout.addWidget(self.checkrate_label, 4, 0, 1, 1) - self.checkrate_slider = QtWidgets.QSlider(parent=self.settings_frame) - self.checkrate_slider.setMinimumSize(QtCore.QSize(0, 25)) - self.checkrate_slider.setMinimum(100) - self.checkrate_slider.setMaximum(1000) - self.checkrate_slider.setSingleStep(100) - self.checkrate_slider.setPageStep(100) - self.checkrate_slider.setProperty("value", 1000) - self.checkrate_slider.setOrientation(QtCore.Qt.Orientation.Horizontal) - self.checkrate_slider.setTickPosition(QtWidgets.QSlider.TickPosition.TicksBothSides) - self.checkrate_slider.setTickInterval(100) - self.checkrate_slider.setObjectName("checkrate_slider") - self.settings_layout.addWidget(self.checkrate_slider, 4, 1, 1, 1) - self.disable_audio_checkbox = QtWidgets.QCheckBox(parent=self.settings_frame) - self.disable_audio_checkbox.setMinimumSize(QtCore.QSize(0, 25)) - self.disable_audio_checkbox.setLayoutDirection(QtCore.Qt.LayoutDirection.RightToLeft) - self.disable_audio_checkbox.setText("") - self.disable_audio_checkbox.setObjectName("disable_audio_checkbox") - self.settings_layout.addWidget(self.disable_audio_checkbox, 2, 1, 1, 1) - self.label_6 = QtWidgets.QLabel(parent=self.settings_frame) - self.label_6.setMinimumSize(QtCore.QSize(0, 25)) - self.label_6.setObjectName("label_6") - self.settings_layout.addWidget(self.label_6, 2, 0, 1, 1) - self.startup_checkbox = QtWidgets.QCheckBox(parent=self.settings_frame) - self.startup_checkbox.setMinimumSize(QtCore.QSize(0, 25)) - self.startup_checkbox.setLayoutDirection(QtCore.Qt.LayoutDirection.RightToLeft) - self.startup_checkbox.setText("") - self.startup_checkbox.setObjectName("startup_checkbox") - self.settings_layout.addWidget(self.startup_checkbox, 1, 1, 1, 1) - self.label_5 = QtWidgets.QLabel(parent=self.settings_frame) - self.label_5.setMinimumSize(QtCore.QSize(0, 25)) - self.label_5.setObjectName("label_5") - self.settings_layout.addWidget(self.label_5, 1, 0, 1, 1) - self.label_4 = QtWidgets.QLabel(parent=self.settings_frame) - self.label_4.setMinimumSize(QtCore.QSize(0, 25)) - self.label_4.setObjectName("label_4") - self.settings_layout.addWidget(self.label_4, 3, 0, 1, 1) - self.disable_monitor_checkbox = QtWidgets.QCheckBox(parent=self.settings_frame) - self.disable_monitor_checkbox.setMinimumSize(QtCore.QSize(0, 25)) - self.disable_monitor_checkbox.setLayoutDirection(QtCore.Qt.LayoutDirection.RightToLeft) - self.disable_monitor_checkbox.setText("") - self.disable_monitor_checkbox.setObjectName("disable_monitor_checkbox") - self.settings_layout.addWidget(self.disable_monitor_checkbox, 3, 1, 1, 1) - self.gridLayout_2.addWidget(self.settings_frame, 1, 0, 1, 2) - self.label_2 = QtWidgets.QLabel(parent=self.centralwidget) - self.label_2.setMinimumSize(QtCore.QSize(0, 25)) - font = QtGui.QFont() - font.setBold(True) - self.label_2.setFont(font) - self.label_2.setObjectName("label_2") - self.gridLayout_2.addWidget(self.label_2, 0, 0, 1, 2) - self.gridLayout_2.setColumnStretch(0, 1) - self.gridLayout_2.setColumnStretch(1, 1) - SettingsWindow.setCentralWidget(self.centralwidget) - - self.retranslateUi(SettingsWindow) - QtCore.QMetaObject.connectSlotsByName(SettingsWindow) - SettingsWindow.setTabOrder(self.startup_checkbox, self.disable_audio_checkbox) - SettingsWindow.setTabOrder(self.disable_audio_checkbox, self.gamemode_audio_lineedit) - SettingsWindow.setTabOrder(self.gamemode_audio_lineedit, self.desktop_audio_lineedit) - - def retranslateUi(self, SettingsWindow): - _translate = QtCore.QCoreApplication.translate - SettingsWindow.setWindowTitle(_translate("SettingsWindow", "BigPictureTV - Settings")) - self.audio_output_label.setText(_translate("SettingsWindow", "Audio output configuration")) - self.label_3.setText(_translate("SettingsWindow", "Gamemode actions")) - self.close_discord_label.setText(_translate("SettingsWindow", "Close discord")) - self.performance_powerplan_label.setText(_translate("SettingsWindow", "Enable performance power plan")) - self.desktop_monitor_label.setText(_translate("SettingsWindow", "Desktop")) - self.gamemode_monitor_label.setText(_translate("SettingsWindow", "Gamemode")) - self.monitor_configuration_label.setText(_translate("SettingsWindow", "Monitor configuration")) - self.gamemode_audio_label.setText(_translate("SettingsWindow", "Gamemode")) - self.desktop_audio_label.setText(_translate("SettingsWindow", "Desktop")) - self.install_audio_button.setText(_translate("SettingsWindow", "Install audio module")) - self.checkrate_label.setText(_translate("SettingsWindow", "Window check rate")) - self.label_6.setText(_translate("SettingsWindow", "Disable audio switching")) - self.label_5.setText(_translate("SettingsWindow", "Run at startup")) - self.label_4.setText(_translate("SettingsWindow", "Disable monitor switching")) - self.label_2.setText(_translate("SettingsWindow", "Settings")) diff --git a/src/setup.py b/src/setup.py deleted file mode 100644 index dbc99ee..0000000 --- a/src/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -import os -from cx_Freeze import setup, Executable - -src_dir = os.path.dirname(os.path.abspath(__file__)) -build_dir = "build/BigPictureTV" - -include_files = [ - os.path.join(src_dir, "icons"), - os.path.join(src_dir, "tr"), -] - -zip_include_packages = ["PyQt6"] - -build_exe_options = { - "include_files": include_files, - "build_exe": build_dir, - "zip_include_packages": zip_include_packages, - "excludes": ["tkinter"], - "silent": True, - "include_msvcr": False, -} - -executables = [ - Executable( - script=os.path.join(src_dir, "bigpicturetv.py"), - base="Win32GUI", - icon=os.path.join(src_dir, "icons/icon.ico"), - target_name="BigPictureTV", - ) -] - -setup( - name="BigPictureTV", - version="1.0", - options={"build_exe": build_exe_options}, - executables=executables, -) diff --git a/src/shortcut_manager.py b/src/shortcut_manager.py deleted file mode 100644 index 8afab16..0000000 --- a/src/shortcut_manager.py +++ /dev/null @@ -1,22 +0,0 @@ -import os -import winshell - - -def manage_startup_shortcut(state): - target_path = os.path.join(os.getcwd(), "BigPictureTV.exe") - startup_folder = winshell.startup() - shortcut_path = os.path.join(startup_folder, "BigPictureTV.lnk") - if state: - winshell.CreateShortcut( - Path=shortcut_path, - Target=target_path, - Icon=(target_path, 0), - Description="Launch BigPictureTV", - StartIn=os.path.dirname(target_path), - ) - elif os.path.exists(shortcut_path): - os.remove(shortcut_path) - - -def check_startup_shortcut(): - return os.path.exists(os.path.join(winshell.startup(), "BigPictureTV.lnk")) diff --git a/src/steam_language_reader.py b/src/steam_language_reader.py deleted file mode 100644 index cbca421..0000000 --- a/src/steam_language_reader.py +++ /dev/null @@ -1,55 +0,0 @@ -import winreg - -BIG_PICTURE_WINDOW_TITLES = { - "schinese": "Steam 大屏幕模式", - "tchinese": "Steam Big Picture 模式", - "japanese": "Steam Big Pictureモード", - "koreana": "Steam Big Picture 모드", - "thai": "โหมด Big Picture บน Steam", - "bulgarian": "Steam режим „Голям екран“", - "czech": "Steam režim Big Picture", - "danish": "Steam Big Picture-tilstand", - "german": "Big-Picture-Modus", - "english": "Steam Big Picture mode", - "spanish": "Modo Big Picture de Steam", - "latam": "Modo Big Picture de Steam", - "greek": "Steam Λειτουργία Big Picture", - "french": "Steam mode Big Picture", - "indonesian": "Mode Big Picture Steam", - "italian": "Modalità Big Picture di Steam", - "hungarian": "Steam Nagy Kép mód", - "dutch": "Steam Big Picture-modus", - "norwegian": "Steam Big Picture-modus", - "polish": "Tryb Big Picture Steam", - "portuguese": "Steam Big Picture", - "brazilian": "Steam Modo Big Picture", - "romanian": "Steam modul Big Picture", - "russian": "Режим Big Picture", - "finnish": "Steamin televisiotila", - "swedish": "Steams Big Picture-läge", - "turkish": "Steam Geniş Ekran Modu", - "vietnamese": "Chế độ Big Picture trên Steam", - "ukrainian": "Steam у режимі Big Picture", -} - - -def get_steam_language(): - try: - key_path = r"Software\Valve\Steam\steamglobal" - - with winreg.OpenKey(winreg.HKEY_CURRENT_USER, key_path) as key: - language, reg_type = winreg.QueryValueEx(key, "Language") - return language - except FileNotFoundError: - return None - except Exception as e: - print(f"An error occurred while accessing the registry: {e}") - return None - - -def get_big_picture_window_title(): - language = get_steam_language() - if language: - return BIG_PICTURE_WINDOW_TITLES.get(language, BIG_PICTURE_WINDOW_TITLES["english"]) - else: - return BIG_PICTURE_WINDOW_TITLES["english"] diff --git a/src/tooltiped_slider.py b/src/tooltiped_slider.py deleted file mode 100644 index e8495e8..0000000 --- a/src/tooltiped_slider.py +++ /dev/null @@ -1,25 +0,0 @@ -from PyQt6.QtWidgets import QSlider, QToolTip -from PyQt6.QtCore import QPoint -from PyQt6.QtGui import QMouseEvent - - -class TooltipedSlider(QSlider): - def __init__(self, orientation, parent=None): - super().__init__(orientation, parent) - - def mousePressEvent(self, event: QMouseEvent): - super().mousePressEvent(event) - self.show_tooltip() - - def mouseMoveEvent(self, event: QMouseEvent): - super().mouseMoveEvent(event) - self.show_tooltip() - - def show_tooltip(self): - value = self.value() - position = QPoint(self.value_to_pixel_pos(value), -25) - QToolTip.showText(self.mapToGlobal(position), str(value), self) - - def value_to_pixel_pos(self, value): - """Convert slider value to pixel position along the slider""" - return int((value - self.minimum()) / (self.maximum() - self.minimum()) * self.width()) diff --git a/src/tr/bigpicturetv_de.qm b/src/tr/bigpicturetv_de.qm deleted file mode 100644 index be651ee..0000000 --- a/src/tr/bigpicturetv_de.qm +++ /dev/null @@ -1 +0,0 @@ - - - - - BigPictureTV - - - External - - - - - Clone - - - - - Internal - - - - - Extend - - - - - Resume detection - - - - - Pause detection - - - - - Settings - - - - - Exit - - - - - SettingsWindow - - - BigPictureTV - Settings - - - - - Audio output configuration - - - - - Gamemode actions - - - - - Close discord - - - - - Enable performance power plan - - - - - - Desktop - - - - - - Gamemode - - - - - Monitor configuration - - - - - Install audio module - - - - - Window check rate - - - - - Disable audio switching - - - - - Run at startup - - - - - Disable monitor switching - - - - - Settings - - - - diff --git a/src/tr/bigpicturetv_en.qm b/src/tr/bigpicturetv_en.qm deleted file mode 100644 index ad7187e..0000000 Binary files a/src/tr/bigpicturetv_en.qm and /dev/null differ diff --git a/src/tr/bigpicturetv_en.ts b/src/tr/bigpicturetv_en.ts deleted file mode 100644 index 44f4ebc..0000000 --- a/src/tr/bigpicturetv_en.ts +++ /dev/null @@ -1,122 +0,0 @@ - - - - - BigPictureTV - - - External - - - - - Clone - - - - - Internal - - - - - Extend - - - - - Resume detection - - - - - Pause detection - - - - - Settings - - - - - Exit - - - - - SettingsWindow - - - BigPictureTV - Settings - - - - - Audio output configuration - - - - - Gamemode actions - - - - - Close discord - - - - - Enable performance power plan - - - - - - Desktop - - - - - - Gamemode - - - - - Monitor configuration - - - - - Install audio module - - - - - Window check rate - - - - - Disable audio switching - - - - - Run at startup - - - - - Disable monitor switching - - - - - Settings - - - - diff --git a/src/tr/bigpicturetv_es.qm b/src/tr/bigpicturetv_es.qm deleted file mode 100644 index 4320da8..0000000 Binary files a/src/tr/bigpicturetv_es.qm and /dev/null differ diff --git a/src/tr/bigpicturetv_es.ts b/src/tr/bigpicturetv_es.ts deleted file mode 100644 index 5ef70ee..0000000 --- a/src/tr/bigpicturetv_es.ts +++ /dev/null @@ -1,122 +0,0 @@ - - - - - BigPictureTV - - - External - - - - - Clone - - - - - Internal - - - - - Extend - - - - - Resume detection - - - - - Pause detection - - - - - Settings - - - - - Exit - - - - - SettingsWindow - - - BigPictureTV - Settings - - - - - Audio output configuration - - - - - Gamemode actions - - - - - Close discord - - - - - Enable performance power plan - - - - - - Desktop - - - - - - Gamemode - - - - - Monitor configuration - - - - - Install audio module - - - - - Window check rate - - - - - Disable audio switching - - - - - Run at startup - - - - - Disable monitor switching - - - - - Settings - - - - diff --git a/src/tr/bigpicturetv_fr.qm b/src/tr/bigpicturetv_fr.qm deleted file mode 100644 index 1117a94..0000000 Binary files a/src/tr/bigpicturetv_fr.qm and /dev/null differ diff --git a/src/tr/bigpicturetv_fr.ts b/src/tr/bigpicturetv_fr.ts deleted file mode 100644 index 8179e78..0000000 --- a/src/tr/bigpicturetv_fr.ts +++ /dev/null @@ -1,122 +0,0 @@ - - - - - BigPictureTV - - - External - Externe - - - - Clone - Dupliquer - - - - Internal - Interne - - - - Extend - Etendre - - - - Resume detection - Stopper la detection - - - - Pause detection - Reprendre la detection - - - - Settings - Paramètres - - - - Exit - Quitter - - - - SettingsWindow - - - BigPictureTV - Settings - BigPictureTV - Paramètres - - - - Audio output configuration - Configuration audio - - - - Gamemode actions - Action en mode jeu - - - - Close discord - Feremr discord - - - - Enable performance power plan - Activer le mode performances élevées - - - - - Desktop - Mode bureau - - - - - Gamemode - Mode jeu - - - - Monitor configuration - Configuration écrans - - - - Install audio module - Installer le module de gestion audio - - - - Window check rate - Fréquence d'actualisation - - - - Disable audio switching - Désactiver la gestion de l'audio - - - - Run at startup - Lancer au démarrage - - - - Disable monitor switching - Désactiver la gestion des écrans - - - - Settings - Paramètres - - - diff --git a/src/ui/settings_window.ui b/src/ui/settings_window.ui deleted file mode 100644 index dfed9ff..0000000 --- a/src/ui/settings_window.ui +++ /dev/null @@ -1,543 +0,0 @@ - - - SettingsWindow - - - - 0 - 0 - 452 - 480 - - - - - 0 - 0 - - - - - 452 - 0 - - - - BigPictureTV - Settings - - - - - - - - 0 - 25 - - - - - true - - - - Audio output configuration - - - - - - - - 0 - 25 - - - - - true - - - - Gamemode actions - - - - - - - QFrame::Shape::StyledPanel - - - QFrame::Shadow::Sunken - - - - 9 - - - 9 - - - 9 - - - 9 - - - 12 - - - - - - 0 - 25 - - - - Qt::LayoutDirection::RightToLeft - - - - - - - - - - - 0 - 25 - - - - Close discord - - - - - - - - 0 - 25 - - - - Enable performance power plan - - - - - - - - 0 - 25 - - - - Qt::LayoutDirection::RightToLeft - - - - - - - - - - - - - QFrame::Shape::StyledPanel - - - QFrame::Shadow::Sunken - - - - 9 - - - 9 - - - 9 - - - 9 - - - 12 - - - - - - 0 - 25 - - - - QComboBox::SizeAdjustPolicy::AdjustToContents - - - - - - - - 0 - 25 - - - - - - - - - 0 - 25 - - - - Desktop - - - - - - - - 0 - 25 - - - - Gamemode - - - - - - - Qt::Orientation::Horizontal - - - - 40 - 20 - - - - - - - - - - - - 0 - 25 - - - - - true - - - - Monitor configuration - - - - - - - QFrame::Shape::StyledPanel - - - - 9 - - - 9 - - - 9 - - - 9 - - - 12 - - - - - - 0 - 25 - - - - Gamemode - - - - - - - - 0 - 25 - - - - Desktop - - - - - - - - 0 - 25 - - - - false - - - true - - - - - - - - 0 - 25 - - - - false - - - true - - - - - - - - - - QFrame::Shape::StyledPanel - - - QFrame::Shadow::Sunken - - - - 9 - - - 9 - - - 9 - - - 9 - - - 12 - - - - - - 0 - 25 - - - - Install audio module - - - - - - - - 0 - 25 - - - - Window check rate - - - - - - - - 0 - 25 - - - - 100 - - - 1000 - - - 100 - - - 100 - - - 1000 - - - Qt::Orientation::Horizontal - - - QSlider::TickPosition::TicksBothSides - - - 100 - - - - - - - - 0 - 25 - - - - Qt::LayoutDirection::RightToLeft - - - - - - - - - - - 0 - 25 - - - - Disable audio switching - - - - - - - - 0 - 25 - - - - Qt::LayoutDirection::RightToLeft - - - - - - - - - - - 0 - 25 - - - - Run at startup - - - - - - - - 0 - 25 - - - - Disable monitor switching - - - - - - - - 0 - 25 - - - - Qt::LayoutDirection::RightToLeft - - - - - - - - - - - - - - 0 - 25 - - - - - true - - - - Settings - - - - - - - - startup_checkbox - disable_audio_checkbox - gamemode_audio_lineedit - desktop_audio_lineedit - - - - diff --git a/src/utils.py b/src/utils.py deleted file mode 100644 index 8698660..0000000 --- a/src/utils.py +++ /dev/null @@ -1,111 +0,0 @@ -import os -import subprocess -import psutil -import platform -import winreg -import pygetwindow as gw -from steam_language_reader import get_big_picture_window_title - -SUNSHINE_STATUS_FILE = os.path.join(os.environ.get("APPDATA"), "sunshine-status", "status.txt") -DISCORD_EXE = os.path.join(os.environ.get("LOCALAPPDATA"), "Discord", "Update.exe") - - -def is_audio_device_cmdlets_installed(): - cmd = 'powershell "Get-Module -ListAvailable -Name AudioDeviceCmdlets"' - result = subprocess.run(cmd, shell=True, capture_output=True, text=True) - if "AudioDeviceCmdlets" in result.stdout: - return True - else: - return False - - -def install_audio_module(): - try: - audiodevicecmdlets_command = "Install-Module AudioDeviceCmdlets -Force -Scope CurrentUser" - command = ["powershell", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", audiodevicecmdlets_command] - subprocess.run(command, check=True) - return ("Success", "AudioDeviceCmdlets module installed successfully.\nYou can now use audio settings.") - except Exception: - return ( - "Error", - "Failed to install AudioDeviceCmdlets module.\n" - "Please install it manually by running this command in PowerShell: " - f"{audiodevicecmdlets_command}\n" - "You should then restart BigPictureTV.", - ) - - -def is_bigpicture_running(): - big_picture_title = get_big_picture_window_title().lower() - big_picture_words = big_picture_title.split() - current_window_titles = [title.lower() for title in gw.getAllTitles()] - - for window_title in current_window_titles: - if all(word in window_title for word in big_picture_words): - return True - - return False - - -def is_sunshine_stream_active(): - """ - To be used with https://github.com/Odizinne/Sunshine-Toolbox - """ - return os.path.exists(SUNSHINE_STATUS_FILE) - - -def close_discord(): - for proc in psutil.process_iter(): - try: - if "discord" in proc.name().lower(): - proc.kill() - except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess): - pass - - -def start_discord(): - try: - subprocess.Popen([DISCORD_EXE, "--processStart", "Discord.exe", "--process-start-args", "--start-minimized"]) - except FileNotFoundError: - pass - - -def is_discord_installed(): - return os.path.exists(DISCORD_EXE) - - -def switch_power_plan(plan_guid): - subprocess.run(["powercfg", "/s", plan_guid]) - - -def get_theme(): - """ - Returns windows current theme. - If the value is 1, the theme is light; if 0, it's dark. - This function returns the opposite to match icon names. - """ - registry_key = winreg.OpenKey( - winreg.HKEY_CURRENT_USER, r"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize" - ) - value, regtype = winreg.QueryValueEx(registry_key, "AppsUseLightTheme") - winreg.CloseKey(registry_key) - - theme = "light" if value == 0 else "dark" - return theme - - -def run_displayswitch(command): - """ - To be used with https://github.com/Odizinne/QMS-QuickMonitorSwitcher - """ - subprocess.run(["DisplaySwitch.exe", command]) - - os.makedirs(os.path.join(os.environ.get("APPDATA"), "displayswitch_history"), exist_ok=True) - with open(os.path.join(os.environ.get("APPDATA"), "displayswitch_history", "displayswitch.txt"), "w") as f: - f.write(command.lstrip("/")) - - -def is_windows_10(): - os_name = platform.system() - os_release = platform.release() - return os_name == "Windows" and os_release == "10" diff --git a/tr_script.py b/tr_script.py deleted file mode 100644 index 9a94f9f..0000000 --- a/tr_script.py +++ /dev/null @@ -1,63 +0,0 @@ -import argparse -import subprocess - - -PROJECT = "bigpicturetv" - - -def run_pylupdate(): - try: - subprocess.run( - [ - "pylupdate6.exe", - "./src/bigpicturetv.py", - "./src/ui/settings_window.ui", - "-ts", - f"./src/tr/{PROJECT}_fr.ts", - "-ts", - f"./src/tr/{PROJECT}_de.ts", - "-ts", - f"./src/tr/{PROJECT}_es.ts", - "-ts", - f"./src/tr/{PROJECT}_en.ts", - ], - check=True, - ) - print("pylupdate6 executed successfully.") - except subprocess.CalledProcessError as e: - print(f"Error running pylupdate6: {e}") - - -def run_lrelease(): - try: - subprocess.run( - [ - "lrelease.exe", - f"./src/tr/{PROJECT}_de.ts", - f"./src/tr/{PROJECT}_en.ts", - f"./src/tr/{PROJECT}_es.ts", - f"./src/tr/{PROJECT}_fr.ts", - ], - check=True, - ) - print("lrelease executed successfully.") - except subprocess.CalledProcessError as e: - print(f"Error running lrelease: {e}") - - -def main(): - parser = argparse.ArgumentParser(description="Run pylupdate6 or lrelease.") - group = parser.add_mutually_exclusive_group(required=True) - group.add_argument("--generate", "-g", action="store_true", help="Run pylupdate6") - group.add_argument("--compile", "-c", action="store_true", help="Run lrelease") - - args = parser.parse_args() - - if args.generate: - run_pylupdate() - elif args.compile: - run_lrelease() - - -if __name__ == "__main__": - main()