diff -Nru brightness-controller-2.4/debian/changelog brightness-controller-2.3.4/debian/changelog --- brightness-controller-2.4/debian/changelog 2023-02-12 14:31:33.000000000 +0000 +++ brightness-controller-2.3.4/debian/changelog 2022-05-05 07:06:10.000000000 +0000 @@ -1,14 +1,14 @@ -brightness-controller (2.4-3~ubuntu23.04.1) lunar; urgency=low +brightness-controller (2.3.4-3~ubuntu22.10.1) kinetic; urgency=low * Auto build. - -- Archisman Panigrahi Sun, 12 Feb 2023 14:31:33 +0000 + -- Archisman Panigrahi Thu, 05 May 2022 07:06:10 +0000 -brightness-controller (2.4) focal; urgency=medium +brightness-controller (2.3.4-3) focal; urgency=medium - * New version with lots of features + * add startupwmclass - -- Archisman Panigrahi Thu, 22 Sep 2022 13:08:12 -0500 + -- Archisman Panigrahi Fri, 3 Sep 2021 19:54:20 +0530 brightness-controller (2.3.4-2) focal; urgency=medium diff -Nru brightness-controller-2.4/debian/git-build-recipe.manifest brightness-controller-2.3.4/debian/git-build-recipe.manifest --- brightness-controller-2.4/debian/git-build-recipe.manifest 2023-02-12 14:31:33.000000000 +0000 +++ brightness-controller-2.3.4/debian/git-build-recipe.manifest 2022-05-05 07:06:10.000000000 +0000 @@ -1,2 +1,2 @@ # git-build-recipe format 0.4 deb-version {debupstream}-3 -lp:brightness-controller git-commit:0153ce0566036768981ecddfdd33a5cc0a668e81 +lp:brightness-controller git-commit:c72a0b865c2ef11ffdc960840dd75bb1773bfe28 diff -Nru brightness-controller-2.4/usr/bin/brightness-controller brightness-controller-2.3.4/usr/bin/brightness-controller --- brightness-controller-2.4/usr/bin/brightness-controller 2023-02-12 14:31:33.000000000 +0000 +++ brightness-controller-2.3.4/usr/bin/brightness-controller 2022-05-05 07:06:10.000000000 +0000 @@ -1 +1 @@ -python3 /usr/share/brightness-controller/init.py \ No newline at end of file +python3 /usr/share/brightness-controller/init.py --name brightness-controller \ No newline at end of file diff -Nru brightness-controller-2.4/usr/share/applications/brightness-controller.desktop brightness-controller-2.3.4/usr/share/applications/brightness-controller.desktop --- brightness-controller-2.4/usr/share/applications/brightness-controller.desktop 2023-02-12 14:31:33.000000000 +0000 +++ brightness-controller-2.3.4/usr/share/applications/brightness-controller.desktop 2022-05-05 07:06:10.000000000 +0000 @@ -8,3 +8,4 @@ Categories=Utility StartupNotify=true Name[en_US]=Brightness Controller +StartupWMClass=brightness-controller \ No newline at end of file diff -Nru brightness-controller-2.4/usr/share/brightness-controller/init.py brightness-controller-2.3.4/usr/share/brightness-controller/init.py --- brightness-controller-2.4/usr/share/brightness-controller/init.py 2023-02-12 14:31:33.000000000 +0000 +++ brightness-controller-2.3.4/usr/share/brightness-controller/init.py 2022-05-05 07:06:10.000000000 +0000 @@ -16,34 +16,25 @@ # You should have received a copy of the GNU General Public License # along with Brightness Controller. If not, see # . - import sys import getpass from os import path, remove, makedirs from qtpy import QtGui, QtCore, QtWidgets -from qtpy.QtCore import QSize, Qt +from qtpy.QtCore import QSize from qtpy.QtGui import QIcon -from brightness_controller_linux.util.QtSingleApplication import QtSingleApplication -from brightness_controller_linux.ui.mainwindow import Ui_MainWindow -from brightness_controller_linux.ui.license import Ui_Form as License_Ui_Form -from brightness_controller_linux.ui.about import Ui_Form as About_Ui_Form -from brightness_controller_linux.ui.help import Ui_Form as Help_Ui_Form -from brightness_controller_linux.util import executor as Executor -from brightness_controller_linux.util import check_displays as CDisplay -from brightness_controller_linux.util import write_config as WriteConfig -from brightness_controller_linux.util import read_config as ReadConfig -from brightness_controller_linux.util import resource_provider as rp -# import util.filepath_handler as Filepath_handler -import subprocess -import threading +from util.QtSingleApplication import QtSingleApplication +from ui.mainwindow import Ui_MainWindow +from ui.license import Ui_Form as License_Ui_Form +from ui.about import Ui_Form as About_Ui_Form +from ui.help import Ui_Form as Help_Ui_Form +import util.executor as Executor +import util.check_displays as CDisplay +import util.write_config as WriteConfig +import util.read_config as ReadConfig +import util.filepath_handler as Filepath_handler class MyApplication(QtWidgets.QMainWindow): - ddcutil_Installed = False - - displayMaxes = [] - displayValues = [] - displayNames = [] def __assign_displays(self): """assigns display name """ @@ -53,67 +44,15 @@ if self.no_of_displays == 1: self.display1 = self.displays[0] - elif self.no_of_displays >= 2: + elif self.no_of_displays == 2: + self.display1 = self.displays[0] self.display2 = self.displays[1] - def directlySetMaxBrightness(self, displayNum, percentage): - - percentage = round(percentage) / 100 - - subprocess.run(["ddcutil", "setvcp", "10", str(int( - self.displayMaxes[displayNum - 1] * percentage)), "-d", - str(displayNum)]) - def __init__(self, parent=None): """Initializes""" QtWidgets.QMainWindow.__init__(self, parent) - # check if ddcutil is installed - try: - if "ddcutil" in str( - subprocess.check_output(["ddcutil", "--version"]), 'utf-8'): - if "sudo modprobe" in str( - subprocess.check_output(["ddcutil", "environment"]), - 'utf-8'): - self.ui.ddcutilsNotInstalled.setText( - "add i2c-dev to etc/modules-load.d") - else: - self.ddcutil_Installed = True - except: - self.ddcutil_Installed = False - - try: - getNames = str(subprocess.check_output(["ddcutil", "detect"]), - 'utf-8').split("\n") - - for i in range(len(getNames)): - if "Model:" in getNames[i]: - - if not getNames[i].split(":")[1].strip() == "": - self.displayNames.append( - getNames[i].split(":")[1].strip()) - - if "Invalid display" in getNames[i]: - self.displayNames.append(getNames[i].strip()) - - for i in range(len(self.displayNames)): - if not self.displayNames[i] == "Invalid display": - brightnessValue = str(subprocess.check_output( - ["ddcutil", "getvcp", "10", "-d", str(i + 1)]), 'utf-8') - - self.displayMaxes.append(int( - brightnessValue.split(",")[1].split("=")[1].strip())) - - self.displayValues.append(int( - brightnessValue.split(',')[0].split('=')[1].strip())) - else: - self.displayMaxes.append(1) - self.displayValues.append(1) - - except Exception as e: - print("error: " + str(e)) - self.tray_menu = None self.tray_icon = None self.display1 = None @@ -125,11 +64,8 @@ self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui_icon = QIcon() - self.APP = None - - # self.ui_icon.addFile(Filepath_handler.get_icon_path(), - # QSize(), QIcon.Normal, QIcon.Off) - self.ui_icon.addFile(rp.icon_path(), QSize(), QIcon.Normal, QIcon.Off) + self.ui_icon.addFile(Filepath_handler.get_icon_path(), + QSize(), QIcon.Normal, QIcon.Off) # icon.addFile("../../../../../../usr/share/icons/hicolor/scalable/apps/brightness-controller.svg", QSize(), QIcon.Normal, QIcon.Off) self.setWindowIcon(self.ui_icon) self.temperature = 'Default' @@ -151,24 +87,11 @@ if path.exists(self.default_config): self.load_settings(self.default_config) - if self.ddcutil_Installed: - res = all(ele == "Invalid display" for ele in self.displayNames) - if not res: - self.ui.directControlBox.setEnabled(True) - self.ui.ddcutilsNotInstalled.setVisible(False) - else: - self.ui.ddcutilsNotInstalled.setText( - "Laptop Displays Not Supported") - - print(self.displayNames) - - print(self.ddcutil_Installed) - - self.canCloseToTray = False - - if QtWidgets.QSystemTrayIcon.isSystemTrayAvailable(): - self.canCloseToTray = True - self.setup_tray(parent) + # self.canCloseToTray = False + + # if QtWidgets.QSystemTrayIcon.isSystemTrayAvailable(): + # self.canCloseToTray = True + # self.setup_tray(parent) def setup_default_directory(self): """ Create default settings directory if it doesnt exist """ @@ -181,70 +104,71 @@ except OSError as e: self._show_error(str(e)) - def closeEvent(self, event): - """ Override CloseEvent for system tray """ - if not self.isVisible(): - reply = QtWidgets.QMessageBox.question(self, 'Message', - "Are you sure to quit?", - QtWidgets.QMessageBox.Yes | - QtWidgets.QMessageBox.No, - QtWidgets.QMessageBox.No) - if reply == QtWidgets.QMessageBox.Yes: - event.accept() - sys.exit(self.APP.exec_()) - else: - event.ignore() - return - else: - # fixes an odd event bug, the app never shows but prevents closing - self.show() - self.hide() - event.ignore() - - def trayClose(self): - reply = QtWidgets.QMessageBox.question(self, 'Message', - "Are you sure to quit?", - QtWidgets.QMessageBox.Yes | - QtWidgets.QMessageBox.No, - QtWidgets.QMessageBox.No) - if reply == QtWidgets.QMessageBox.Yes: - sys.exit(self.APP.exec_()) - - def setup_tray(self, parent): - # Setup system tray - self.tray_menu = QtWidgets.QMenu(parent) - - show_action = QtWidgets.QAction("Show", self, - statusTip="Show", - triggered=self.show) - quit_action = QtWidgets.QAction("Quit", self, - statusTip="Quit", - triggered=self.trayClose) - self.tray_menu.addAction(show_action) - self.tray_menu.addAction(quit_action) - - icon = QtGui.QIcon() - # icon_path = "icons/brightness-controller.svg" - icon_path = rp.icon_path() - # # icon_path = Filepath_handler.find_data_file(icon_path) - # # icon_path = - # # "/usr/share/icons/hicolor/scalable/apps/brightness-controller.svg" - # icon_path = Filepath_handler.get_icon_path() - # # print(icon_path) - icon.addPixmap(QtGui.QPixmap(icon_path), QtGui.QIcon.Normal, - QtGui.QIcon.Off) - - self.tray_icon = QtWidgets.QSystemTrayIcon(icon, self) - self.tray_icon.activated.connect(self._icon_activated) - self.tray_icon.setContextMenu(self.tray_menu) - self.tray_icon.show() - - def _icon_activated(self, reason): - # can't seem to get double click? - if reason in (QtWidgets.QSystemTrayIcon.Trigger, - QtWidgets.QSystemTrayIcon.DoubleClick): - print(reason, QtWidgets.QSystemTrayIcon.DoubleClick) - self.show() + # def closeEvent(self, event): + # """ Override CloseEvent for system tray """ + # if not self.canCloseToTray: + # reply = QtWidgets.QMessageBox.question(self, 'Message', "Are you sure to quit?", + # QtWidgets.QMessageBox.Yes, + # # QtWidgets.QMessageBox.Yes | + # # QtWidgets.QMessageBox.No, + # QtWidgets.QMessageBox.No) + # if reply == QtWidgets.QMessageBox.Yes: + # event.accept() + # sys.exit(APP.exec_()) + # else: + # event.ignore() + # return + # else: + # if self.isVisible() is True: + # self.hide() + # event.ignore() + # else: + # reply = QtWidgets.QMessageBox.question(self, 'Message', "Are you sure to quit?", + # # QtWidgets.QMessageBox.Yes | + # # QtWidgets.QMessageBox.No, + # QtWidgets.QMessageBox.Yes, + # QtWidgets.QMessageBox.No) + # if reply == QtWidgets.QMessageBox.Yes: + # event.accept() + # sys.exit(APP.exec_()) + # else: + # # fixes an odd event bug, the app never shows but prevents closing + # self.show() + # self.hide() + # event.ignore() + + # def setup_tray(self, parent): + # """ Setup system tray """ + # self.tray_menu = QtWidgets.QMenu(parent) + # + # show_action = QtWidgets.QAction("Show", self, + # statusTip="Show", + # triggered=self.show) + # quit_action = QtWidgets.QAction("Quit", self, + # statusTip="Quit", + # triggered=self.close) + # self.tray_menu.addAction(show_action) + # self.tray_menu.addAction(quit_action) + # + # icon = QtGui.QIcon() + # # icon_path = "icons/brightness-controller.svg" + # # icon_path = Filepath_handler.find_data_file(icon_path) + # # icon_path = + # # "/usr/share/icons/hicolor/scalable/apps/brightness-controller.svg" + # icon_path = Filepath_handler.get_icon_path() + # # print(icon_path) + # icon.addPixmap(QtGui.QPixmap(icon_path), + # QtGui.QIcon.Normal, QtGui.QIcon.Off) + # + # self.tray_icon = QtWidgets.QSystemTrayIcon(icon, self) + # self.tray_icon.connect( + # QtCore.SIGNAL("activated(QSystemTrayIcon::ActivationReason)"), self._icon_activated) + # self.tray_icon.setContextMenu(self.tray_menu) + # self.tray_icon.show() + + # def _icon_activated(self, reason): + # if reason in (QtWidgets.QSystemTrayIcon.Trigger, QtWidgets.QSystemTrayIcon.DoubleClick): + # self.show() def setup_widgets(self): """connects the form widgets with functions""" @@ -268,7 +192,7 @@ def generate_brightness_sources(self): """ - generates and assigns display sources to combo boxes + generates assigns display sources to combo boxes """ if self.no_of_connected_dev < 2: self.ui.secondary_combo.addItem("Disabled") @@ -277,34 +201,25 @@ self.ui.primary_combobox.setEnabled(False) return - if self.ddcutil_Installed: - for i in range(self.no_of_connected_dev): - self.ui.secondary_combo.addItem(self.displayNames[i]) - self.ui.primary_combobox.addItem(self.displayNames[i]) - pass - else: - for display in self.displays: - self.ui.secondary_combo.addItem(display) - self.ui.primary_combobox.addItem(display) + for display in self.displays: + self.ui.secondary_combo.addItem(display) + self.ui.primary_combobox.addItem(display) def connect_handlers(self): """Connects the handlers of GUI widgets""" - self.ui.primary_brightness.setTracking(False) - self.ui.primary_brightness.valueChanged[int].connect( - self.change_value_pbr) + self.ui.primary_brightness.valueChanged[int]. \ + connect(self.change_value_pbr) self.ui.primary_red.valueChanged[int]. \ connect(self.change_value_pr) self.ui.primary_blue.valueChanged[int]. \ connect(self.change_value_pb) self.ui.primary_green.valueChanged[int]. \ connect(self.change_value_pg) - self.ui.directControlBox.stateChanged.connect(self.directControlUpdate) self.enable_secondary_widgets(False) if self.no_of_connected_dev >= 2: self.enable_secondary_widgets(True) self.connect_secondary_widgets() - self.ui.secondary_combo.setCurrentIndex(1) if path.exists(self.default_config): self.ui.actionClearDefault.setVisible(True) @@ -326,45 +241,6 @@ self.ui.actionSave.triggered.connect(self.save_settings) self.ui.actionLoad.triggered.connect(self.load_settings) - def directControlUpdate(self, value): - if self.ui.directControlBox.isChecked(): - self.ui.primary_brightness.setMaximum(100) - self.ui.primary_brightness.setValue(int(round( - (self.displayValues[0] / self.displayMaxes[0]) * 100))) - self.ui.primary_brightness.setFocusPolicy(Qt.NoFocus) - self.ui.primary_brightness.setTracking(False) - - print("Update: " + self.ui.primary_combobox.currentText()) - - if self.ui.primary_combobox.currentText() == "Invalid display": - self.ui.primary_brightness.setEnabled(False) - - if self.no_of_displays > 1: - self.ui.secondary_brightness.setMaximum(100) - self.ui.secondary_brightness.setValue(int(round( - (self.displayValues[1] / self.displayMaxes[1]) * 100))) - self.ui.secondary_brightness.setFocusPolicy(Qt.NoFocus) - self.ui.secondary_brightness.setTracking(False) - - if self.ui.secondary_combo.currentText() == "Invalid display": - self.ui.secondary_brightness.setEnabled(False) - - else: - self.ui.primary_brightness.setMaximum(99) - self.ui.secondary_brightness.setMaximum(99) - self.ui.primary_brightness.setValue(99) - self.ui.secondary_brightness.setValue(99) - self.ui.primary_brightness.setFocusPolicy(Qt.StrongFocus) - self.ui.primary_brightness.setTracking(True) - self.ui.secondary_brightness.setFocusPolicy(Qt.StrongFocus) - self.ui.secondary_brightness.setTracking(True) - - if self.no_of_displays == 1: - self.ui.primary_brightness.setEnabled(True) - else: - self.ui.primary_brightness.setEnabled(True) - self.ui.secondary_brightness.setEnabled(True) - def enable_secondary_widgets(self, boolean): """ boolean - assigns boolean value to setEnabled(boolean) @@ -378,7 +254,6 @@ """ connects the secondary widgets with functions """ - self.ui.secondary_brightness.setTracking(False) self.ui.secondary_brightness.valueChanged[int]. \ connect(self.change_value_sbr) self.ui.secondary_red.valueChanged[int]. \ @@ -388,43 +263,27 @@ self.ui.secondary_green.valueChanged[int]. \ connect(self.change_value_sg) - def change_value_pbr(self): + def change_value_pbr(self, value): """Changes Primary Display Brightness""" - if self.ui.directControlBox.isChecked(): - - setValue = threading.Thread(target=self.directlySetMaxBrightness, - args=( - self.ui.primary_combobox.currentIndex() + 1, - self.ui.primary_brightness.value())) - - setValue.start() - - self.displayValues[self.ui.primary_combobox.currentIndex()] = int( - round(self.ui.primary_brightness.value() / 100 * - self.displayMaxes[ - self.ui.primary_combobox.currentIndex()])) - - else: - value = self.ui.primary_brightness.value() - cmd_value = "xrandr\ - --output %s \ - --brightness %s\ - --gamma %s:%s:%s" % \ - (self.display1, - self.values[value], - self.values[self.ui.primary_red.value()], - self.values[self.ui.primary_green.value()], - self.values[self.ui.primary_blue.value()]) - Executor.execute_command(cmd_value) + cmd_value = "xrandr\ + --output %s \ + --brightness %s\ + --gamma %s:%s:%s" % \ + (self.display1, + self.values[value], + self.values[self.ui.primary_red.value()], + self.values[self.ui.primary_green.value()], + self.values[self.ui.primary_blue.value()]) + Executor.execute_command(cmd_value) def change_value_pr(self, value): """Changes Primary Display Red ratio""" cmd_value = "xrandr\ - --output %s \ - --brightness %s\ - --gamma %s:%s:%s" % \ + --output %s \ + --brightness %s\ + --gamma %s:%s:%s" % \ (self.display1, - self.values[self.ui.primary_brightness.value() - 1], + self.values[self.ui.primary_brightness.value()], self.values[value], self.values[self.ui.primary_green.value()], self.values[self.ui.primary_blue.value()]) @@ -433,11 +292,11 @@ def change_value_pg(self, value): """Changes Primary Display Green ratio""" cmd_value = "xrandr\ - --output %s \ - --brightness %s\ - --gamma %s:%s:%s" % \ + --output %s \ + --brightness %s\ + --gamma %s:%s:%s" % \ (self.display1, - self.values[self.ui.primary_brightness.value() - 1], + self.values[self.ui.primary_brightness.value()], self.values[self.ui.primary_red.value()], self.values[value], self.values[self.ui.primary_blue.value()]) @@ -447,57 +306,39 @@ def change_value_pb(self, value): """Changes Primary Display Blue ratio""" cmd_value = "xrandr\ - --output %s \ - --brightness %s\ - --gamma %s:%s:%s" % \ + --output %s \ + --brightness %s\ + --gamma %s:%s:%s" % \ (self.display1, - self.values[self.ui.primary_brightness.value() - 1], + self.values[self.ui.primary_brightness.value()], self.values[self.ui.primary_red.value()], self.values[self.ui.primary_green.value()], self.values[value]) Executor.execute_command(cmd_value) - def change_value_sbr(self): + def change_value_sbr(self, value): """ Changes Secondary Display Brightness """ - - if self.ui.directControlBox.isChecked(): - - setValue = threading.Thread(target=self.directlySetMaxBrightness, - args=( - self.ui.secondary_combo.currentIndex() + 1, - self.ui.secondary_brightness.value())) - - setValue.start() - - self.displayValues[self.ui.secondary_combo.currentIndex()] = int( - round((self.ui.secondary_brightness.value() / 100 * - self.displayMaxes[ - self.ui.secondary_combo.currentIndex()]))) - - - else: - value = self.ui.secondary_brightness.value() - cmd_value = "xrandr\ - --output %s \ - --brightness %s\ - --gamma %s:%s:%s" % \ - (self.display2, - self.values[value - 1], - self.values[self.ui.secondary_red.value()], - self.values[self.ui.secondary_green.value()], - self.values[self.ui.secondary_blue.value()]) - Executor.execute_command(cmd_value) + cmd_value = "xrandr\ + --output %s \ + --brightness %s\ + --gamma %s:%s:%s" % \ + (self.display2, + self.values[value], + self.values[self.ui.secondary_red.value()], + self.values[self.ui.secondary_green.value()], + self.values[self.ui.secondary_blue.value()]) + Executor.execute_command(cmd_value) def change_value_sr(self, value): """Changes Secondary Display Red ratio""" cmd_value = "xrandr\ - --output %s \ - --brightness %s\ - --gamma %s:%s:%s" % \ + --output %s \ + --brightness %s\ + --gamma %s:%s:%s" % \ (self.display2, - self.values[self.ui.secondary_brightness.value() - 1], + self.values[self.ui.secondary_brightness.value()], self.values[value], self.values[self.ui.secondary_green.value()], self.values[self.ui.secondary_blue.value()]) @@ -506,11 +347,11 @@ def change_value_sg(self, value): """Changes Secondary Display Green ratio""" cmd_value = "xrandr\ - --output %s \ - --brightness %s\ - --gamma %s:%s:%s" % \ + --output %s \ + --brightness %s\ + --gamma %s:%s:%s" % \ (self.display2, - self.values[self.ui.secondary_brightness.value() - 1], + self.values[self.ui.secondary_brightness.value()], self.values[self.ui.secondary_red.value()], self.values[value], self.values[self.ui.secondary_blue.value()]) @@ -520,11 +361,11 @@ def change_value_sb(self, value): """Changes Primary Display Blue ratio""" cmd_value = "xrandr\ - --output %s \ - --brightness %s\ - --gamma %s:%s:%s" % \ + --output %s \ + --brightness %s\ + --gamma %s:%s:%s" % \ (self.display2, - self.values[self.ui.secondary_brightness.value() - 1], + self.values[self.ui.secondary_brightness.value()], self.values[self.ui.secondary_red.value()], self.values[self.ui.secondary_green.value()], self.values[value]) @@ -544,34 +385,11 @@ """ assigns combo value to display """ - self.display2 = self.displays[ - self.ui.secondary_combo.currentIndex()] # text - print(self.ui.secondary_combo.currentText()) - if self.ui.directControlBox.isChecked(): - if self.ui.secondary_combo.currentText() == "Invalid display": - self.ui.secondary_brightness.setEnabled(False) - print("secondary disabled") - else: - self.ui.secondary_brightness.setEnabled(True) - print("secondary enabled") - else: - self.ui.secondary_brightness.setEnabled(True) + self.display2 = text def primary_source_combo_activated(self, text): """assigns combo value to display""" - self.display1 = self.displays[ - self.ui.primary_combobox.currentIndex()] # text - - print(self.ui.primary_combobox.currentText()) - if self.ui.directControlBox.isChecked(): - if self.ui.primary_combobox.currentText() == "Invalid display": - self.ui.primary_brightness.setEnabled(False) - print("primary disabled") - else: - self.ui.primary_brightness.setEnabled(True) - print("primary enabled") - else: - self.ui.secondary_brightness.setEnabled(True) + self.display1 = text def combo_activated(self, text): """ Designates values to display and to sliders """ @@ -579,53 +397,53 @@ if text == 'Default': rgb = [255, 255, 255] self.change_primary_sliders(rgb) - if self.no_of_connected_dev >= 2: + if self.no_of_connected_dev == 2: self.change_secondary_sliders(rgb) elif text == '1900K Candle': rgb = [255, 147, 41] self.change_primary_sliders(rgb) - if self.no_of_connected_dev >= 2: + if self.no_of_connected_dev == 2: self.change_secondary_sliders(rgb) elif text == '2600K 40W Tungsten': rgb = [255, 197, 143] self.change_primary_sliders(rgb) - if self.no_of_connected_dev >= 2: + if self.no_of_connected_dev == 2: self.change_secondary_sliders(rgb) elif text == '2850K 100W Tungsten': rgb = [255, 214, 170] self.change_primary_sliders(rgb) - if self.no_of_connected_dev >= 2: + if self.no_of_connected_dev == 2: self.change_secondary_sliders(rgb) elif text == '3200K Halogen': rgb = [255, 241, 224] self.change_primary_sliders(rgb) - if self.no_of_connected_dev >= 2: + if self.no_of_connected_dev == 2: self.change_secondary_sliders(rgb) elif text == '5200K Carbon Arc': rgb = [255, 250, 244] self.change_primary_sliders(rgb) - if self.no_of_connected_dev >= 2: + if self.no_of_connected_dev == 2: self.change_secondary_sliders(rgb) elif text == '5400K High Noon': rgb = [255, 255, 251] self.change_primary_sliders(rgb) - if self.no_of_connected_dev >= 2: + if self.no_of_connected_dev == 2: self.change_secondary_sliders(rgb) elif text == '6000K Direct Sun': rgb = [255, 255, 255] self.change_primary_sliders(rgb) - if self.no_of_connected_dev >= 2: + if self.no_of_connected_dev == 2: self.change_secondary_sliders(rgb) elif text == '7000K Overcast Sky': rgb = [201, 226, 255] self.change_primary_sliders(rgb) - if self.no_of_connected_dev >= 2: + if self.no_of_connected_dev == 2: self.change_secondary_sliders(rgb) elif text == '20000K Clear Blue Sky': rgb = [64, 156, 255] self.change_primary_sliders(rgb) - if self.no_of_connected_dev >= 2: + if self.no_of_connected_dev == 2: self.change_secondary_sliders(rgb) def change_primary_sliders(self, rgb): @@ -699,31 +517,24 @@ def save_settings(self, default=False): """ save current primary and secondary display settings""" - file_path = self.default_config if default else \ - QtWidgets.QFileDialog.getSaveFileName()[ - 0] + file_path = self.default_config if default else QtWidgets.QFileDialog.getSaveFileName()[ + 0] # just a number. path.exists won't work in case it is a new file. if len(file_path) > 5: if default: self.ui.actionClearDefault.setVisible(True) - try: - if self.no_of_connected_dev == 1: - WriteConfig.write_primary_display( - self.return_current_primary_settings(), - file_path - ) - elif self.no_of_connected_dev >= 2: - WriteConfig.write_both_display( - self.return_current_primary_settings(), - self.return_current_secondary_settings(), - file_path - ) - except PermissionError: - self._show_error( - "Does not have permission to write file at " + file_path) - except OSError: - self._show_error( - "Does not have permission to write file at " + file_path) + if self.no_of_connected_dev == 1: + WriteConfig.write_primary_display( + self.return_current_primary_settings(), + file_path + ) + elif self.no_of_connected_dev >= 2: + WriteConfig.write_both_display( + self.return_current_primary_settings(), + self.return_current_secondary_settings(), + file_path + + ) def _show_error(self, message): """ Shows an Error Message""" @@ -895,16 +706,13 @@ """assigns main_win as main_window""" self.main_window = main_win -def main(): + +if __name__ == "__main__": UUID = 'PHIR-HWOH-MEIZ-AHTA' APP = QtSingleApplication(UUID, sys.argv) if APP.isRunning(): sys.exit(0) WINDOW = MyApplication() - WINDOW.APP = APP APP.setActivationWindow(WINDOW) WINDOW.show() - sys.exit(APP.exec_()) - -if __name__ == "__main__": - main() + sys.exit(APP.exec_()) \ No newline at end of file diff -Nru brightness-controller-2.4/usr/share/brightness-controller/ui/about.py brightness-controller-2.3.4/usr/share/brightness-controller/ui/about.py --- brightness-controller-2.4/usr/share/brightness-controller/ui/about.py 2023-02-12 14:31:33.000000000 +0000 +++ brightness-controller-2.3.4/usr/share/brightness-controller/ui/about.py 2022-05-05 07:06:10.000000000 +0000 @@ -1,52 +1,63 @@ # -*- coding: utf-8 -*- -# Form implementation generated from reading ui file 'about.ui' -# -# Created by: PyQt5 UI code generator 5.15.7 -# -# WARNING: Any manual changes made to this file will be lost when pyuic5 is -# run again. Do not edit this file unless you know what you are doing. - - -from PyQt5 import QtCore, QtGui, QtWidgets +################################################################################ +## Form generated from reading UI file 'about.ui' +## +## Created by: Qt User Interface Compiler version 5.14.2 +## +## WARNING! All changes made in this file will be lost when recompiling UI file! +################################################################################ + +from qtpy.QtCore import (QCoreApplication, QDate, QDateTime, QMetaObject, + QObject, QPoint, QRect, QSize, QTime, QUrl, Qt) +from qtpy.QtGui import (QBrush, QColor, QConicalGradient, QCursor, QFont, + QFontDatabase, QIcon, QKeySequence, QLinearGradient, QPalette, QPainter, + QPixmap, QRadialGradient) +from qtpy.QtWidgets import * class Ui_Form(object): def setupUi(self, Form): - Form.setObjectName("Form") + if not Form.objectName(): + Form.setObjectName(u"Form") Form.resize(400, 300) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) + sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(Form.sizePolicy().hasHeightForWidth()) Form.setSizePolicy(sizePolicy) - Form.setMinimumSize(QtCore.QSize(400, 300)) - Form.setMaximumSize(QtCore.QSize(400, 300)) - self.textBrowser = QtWidgets.QTextBrowser(Form) - self.textBrowser.setGeometry(QtCore.QRect(0, 0, 401, 301)) - self.textBrowser.setObjectName("textBrowser") + Form.setMinimumSize(QSize(400, 300)) + Form.setMaximumSize(QSize(400, 300)) + self.textBrowser = QTextBrowser(Form) + self.textBrowser.setObjectName(u"textBrowser") + self.textBrowser.setGeometry(QRect(0, 0, 401, 301)) self.retranslateUi(Form) - QtCore.QMetaObject.connectSlotsByName(Form) + + QMetaObject.connectSlotsByName(Form) + # setupUi def retranslateUi(self, Form): - _translate = QtCore.QCoreApplication.translate - Form.setWindowTitle(_translate("Form", "About")) - self.textBrowser.setHtml(_translate("Form", "\n" + Form.setWindowTitle(QCoreApplication.translate("Form", u"About", None)) + self.textBrowser.setHtml(QCoreApplication.translate("Form", u"\n" "\n" -"

Brightness Controller v2.4

\n" -"

Author: Amit Seal Ami,

\n" -"

Bangladesh,

\n" -"

amitsealami@gmail.com

\n" -"

Contributors

\n" -"

Significant contributors are listed in arbitrary order:

\n" -"

- Archisman Panigrahi

\n" -"

- Jahan Addison

\n" -"

- Zlatan Vasović

\n" -"

- Soggy-Pancake

\n" -"

Special thanks to:

\n" -"

- 2to3 tool for porting to Python 3

\n" -"

- Numerous Stack Overflow users

\n" -"

For full list of contributors and other details, please check https://github.com/lordamit/Brightness

")) +"\n" +"

Brightness Controller v2.3.4

\n" +"

Author: Amit Seal Ami,

\n" +"

Bangladesh,

\n" +"

amitsealami@gmail.com

\n" +"

Contributors

\n" +"

Significant contributors are listed alphabetically.

\n" +"

- Archisman Panigrahi

\n" +"

- Jahan Addison

\n" +"

- Zlatan Vasovi\u0107

\n" +"

Special thanks to:

\n" +"

- 2to3 tool for porting to Python 3

\n" +"

- Numerous Stack Overflow users

\n" +"

For full list of authors and details, please check https://github.com/lordamit/Brightness

", None)) + # retranslateUi + diff -Nru brightness-controller-2.4/usr/share/brightness-controller/ui/about.ui brightness-controller-2.3.4/usr/share/brightness-controller/ui/about.ui --- brightness-controller-2.4/usr/share/brightness-controller/ui/about.ui 2023-02-12 14:31:33.000000000 +0000 +++ brightness-controller-2.3.4/usr/share/brightness-controller/ui/about.ui 2022-05-05 07:06:10.000000000 +0000 @@ -44,21 +44,20 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'.AppleSystemUIFont'; font-size:13pt; font-weight:400; font-style:normal;"> -<p align="center" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans'; font-size:16pt;">Brightness Controller v2.4</span></p> +</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> +<p align="center" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans'; font-size:16pt;">Brightness Controller v2.3.4</span></p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans'; font-size:9pt; font-weight:600;">Author: </span><span style=" font-family:'Sans'; font-size:9pt;">Amit Seal Ami, </span></p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans'; font-size:9pt;">Bangladesh,</span></p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans'; font-size:9pt;">amitsealami@gmail.com</span></p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans'; font-size:9pt; font-weight:600;">Contributors</span></p> -<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans'; font-size:9pt;">Significant contributors are listed in arbitrary order:</span></p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans'; font-size:9pt;">Significant contributors are listed alphabetically.</span></p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans'; font-size:9pt;">- Archisman Panigrahi</span></p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans'; font-size:9pt;">- Jahan Addison</span></p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans'; font-size:9pt;">- Zlatan Vasović</span></p> -<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans'; font-size:9pt;">- Soggy-Pancake</span></p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans'; font-size:9pt; font-weight:600;">Special thanks to:</span></p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans'; font-size:9pt;">- 2to3 tool for porting to Python 3</span></p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans'; font-size:9pt;">- Numerous Stack Overflow users</span></p> -<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans'; font-size:9pt;">For full list of contributors and other details, please check </span><a href="https://github.com/lordamit/Brightness"><span style=" font-family:'Noto Sans'; font-size:10pt; text-decoration: underline; color:#3484e2;">https://github.com/lordamit/Brightness</span></a></p></body></html> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans'; font-size:9pt;">For full list of authors and details, please check </span><a href="https://github.com/lordamit/Brightness"><span style=" font-family:'Noto Sans'; font-size:10pt; text-decoration: underline; color:#3484e2;">https://github.com/lordamit/Brightness</span></a></p></body></html> diff -Nru brightness-controller-2.4/usr/share/brightness-controller/ui/mainwindow.py brightness-controller-2.3.4/usr/share/brightness-controller/ui/mainwindow.py --- brightness-controller-2.4/usr/share/brightness-controller/ui/mainwindow.py 2023-02-12 14:31:33.000000000 +0000 +++ brightness-controller-2.3.4/usr/share/brightness-controller/ui/mainwindow.py 2022-05-05 07:06:10.000000000 +0000 @@ -1,17 +1,13 @@ # -*- coding: utf-8 -*- ################################################################################ -## Form generated from reading UI file 'mainwindowlPqlsB.ui' +## Form generated from reading UI file 'mainwindow.ui' ## -## Created by: Qt User Interface Compiler version 5.15.5 +## Created by: Qt User Interface Compiler version 5.14.1 ## ## WARNING! All changes made in this file will be lost when recompiling UI file! ################################################################################ -#from PySide2.QtCore import * # type: ignore -#from PySide2.QtGui import * # type: ignore -#from PySide2.QtWidgets import * # type: ignore - from qtpy.QtCore import (QCoreApplication, QMetaObject, QObject, QPoint, QRect, QSize, QUrl, Qt) from qtpy.QtGui import (QBrush, QColor, QConicalGradient, QCursor, QFont, @@ -19,9 +15,10 @@ QRadialGradient) from qtpy.QtWidgets import * + class Ui_MainWindow(object): def setupUi(self, MainWindow): - if not MainWindow.objectName(): + if MainWindow.objectName(): MainWindow.setObjectName(u"MainWindow") MainWindow.resize(701, 340) MainWindow.setMinimumSize(QSize(701, 340)) @@ -168,7 +165,7 @@ self.label_8.setGeometry(QRect(470, 260, 16, 16)) self.verticalLayoutWidget = QWidget(self.centralWidget) self.verticalLayoutWidget.setObjectName(u"verticalLayoutWidget") - self.verticalLayoutWidget.setGeometry(QRect(529, 0, 218, 258)) + self.verticalLayoutWidget.setGeometry(QRect(529, 0, 213, 218)) self.verticalLayout = QVBoxLayout(self.verticalLayoutWidget) self.verticalLayout.setSpacing(6) self.verticalLayout.setContentsMargins(11, 11, 11, 11) @@ -233,21 +230,6 @@ self.verticalLayout.addWidget(self.comboBox) - self.ddcutilsNotInstalled = QLabel(self.verticalLayoutWidget) - self.ddcutilsNotInstalled.setObjectName(u"ddcutilsNotInstalled") - self.ddcutilsNotInstalled.setEnabled(True) - font = QFont() - font.setPointSize(8) - self.ddcutilsNotInstalled.setFont(font) - - self.verticalLayout.addWidget(self.ddcutilsNotInstalled) - - self.directControlBox = QCheckBox(self.verticalLayoutWidget) - self.directControlBox.setObjectName(u"directControlBox") - self.directControlBox.setEnabled(False) - - self.verticalLayout.addWidget(self.directControlBox) - MainWindow.setCentralWidget(self.centralWidget) self.statusBar = QStatusBar(MainWindow) self.statusBar.setObjectName(u"statusBar") @@ -318,8 +300,6 @@ self.comboBox.setItemText(8, QCoreApplication.translate("MainWindow", u"7000K Overcast Sky", None)) self.comboBox.setItemText(9, QCoreApplication.translate("MainWindow", u"20000K Clear Blue Sky", None)) - self.ddcutilsNotInstalled.setText(QCoreApplication.translate("MainWindow", u"Install ddcutil for direct control", None)) - self.directControlBox.setText(QCoreApplication.translate("MainWindow", u"Direct Control (DDC)", None)) self.menuFile.setTitle(QCoreApplication.translate("MainWindow", u"&File", None)) self.menuHelp.setTitle(QCoreApplication.translate("MainWindow", u"&Help", None)) # retranslateUi diff -Nru brightness-controller-2.4/usr/share/brightness-controller/ui/mainwindow.ui brightness-controller-2.3.4/usr/share/brightness-controller/ui/mainwindow.ui --- brightness-controller-2.4/usr/share/brightness-controller/ui/mainwindow.ui 2023-02-12 14:31:33.000000000 +0000 +++ brightness-controller-2.3.4/usr/share/brightness-controller/ui/mainwindow.ui 2022-05-05 07:06:10.000000000 +0000 @@ -56,9 +56,6 @@ - - 99 - 99 @@ -275,7 +272,7 @@ 529 0 213 - 258 + 218 @@ -411,25 +408,6 @@ - - - - - 8 - - - - install ddcutil for direct control - - - - - - - Direct Control (DDC) - - - diff -Nru brightness-controller-2.4/usr/share/brightness-controller/util/check_displays.py brightness-controller-2.3.4/usr/share/brightness-controller/util/check_displays.py --- brightness-controller-2.4/usr/share/brightness-controller/util/check_displays.py 2023-02-12 14:31:33.000000000 +0000 +++ brightness-controller-2.3.4/usr/share/brightness-controller/util/check_displays.py 2022-05-05 07:06:10.000000000 +0000 @@ -20,32 +20,35 @@ import shlex import re +def detect_display_devices(): + """ + Detects available displays. + returns connected_displays + This contains the available device names compatible with xrandr + """ + connected_displays = [] -def query_xrandr(): - query = "xrandr --query" - xrandr_output = subprocess.Popen(shlex.split(query), stdout=subprocess.PIPE, - stderr=subprocess.STDOUT) - stdout, stderr = xrandr_output.communicate() - return str(stdout, "utf-8") + # xrandr_output = subprocess.check_output('xrandr -q', shell=True) + # lines = xrandr_output.split('\n') + # for line in lines: + # words = line.split(' ') + # for word in words: + # if word == 'connected': + # connected_displays.append(words[0]) + # return connected_displays + query = "xrandr --query" -def extract_displays(output): pattern = re.compile(r'\b({0})\b'.format("connected"), flags=re.IGNORECASE) + + xrandr_output = subprocess.Popen(shlex.split(query), stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + stdout, stderr = xrandr_output.communicate() + output = str(stdout, "utf-8") lines = output.splitlines() connected = [line for line in lines if pattern.search(line)] - connected_displays = list( - map(lambda display: display.split()[0], connected)) + connected_displays = list(map(lambda display: display.split()[0], connected)) return connected_displays -def detect_display_devices(): - """ - Detects available displays. - returns connected_displays - This contains the available device names compatible with xrandr - """ - return extract_displays(query_xrandr()) - - if __name__ == '__main__': print(detect_display_devices()) diff -Nru brightness-controller-2.4/usr/share/brightness-controller/util/filepath_handler.py brightness-controller-2.3.4/usr/share/brightness-controller/util/filepath_handler.py --- brightness-controller-2.4/usr/share/brightness-controller/util/filepath_handler.py 2023-02-12 14:31:33.000000000 +0000 +++ brightness-controller-2.3.4/usr/share/brightness-controller/util/filepath_handler.py 2022-05-05 07:06:10.000000000 +0000 @@ -17,7 +17,7 @@ if os.path.exists('/usr/share/brightness-controller/util/debian_install'): return "/usr/share/icons/hicolor/scalable/apps/brightness-controller.svg" else: - return _find_data_file("src/brightness_controller_linux/icons/brightness-controller.svg") + return _find_data_file("icons/brightness-controller.svg") if __name__ == "__main__": diff -Nru brightness-controller-2.4/usr/share/brightness-controller/util/resource_provider.py brightness-controller-2.3.4/usr/share/brightness-controller/util/resource_provider.py --- brightness-controller-2.4/usr/share/brightness-controller/util/resource_provider.py 2023-02-12 14:31:33.000000000 +0000 +++ brightness-controller-2.3.4/usr/share/brightness-controller/util/resource_provider.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -from importlib import resources -from pathlib import Path - -import brightness_controller_linux.icons as icons - - -def icon_path(module_name=icons): - iconname = "brightness-controller.svg" - path_icon = "" - with resources.path(icons, iconname) as f: - path_icon = str(f) - return path_icon - # enable from python3.9 - # files = resources.files(icons) - # return str(files / iconname) diff -Nru brightness-controller-2.4/usr/share/brightness-controller/util/write_config.py brightness-controller-2.3.4/usr/share/brightness-controller/util/write_config.py --- brightness-controller-2.4/usr/share/brightness-controller/util/write_config.py 2023-02-12 14:31:33.000000000 +0000 +++ brightness-controller-2.3.4/usr/share/brightness-controller/util/write_config.py 2022-05-05 07:06:10.000000000 +0000 @@ -18,7 +18,7 @@ import configparser -def default_config(config, display_type='primary'): +def default_config(config, display_type = 'primary'): config[display_type]['brightness'] = 99 config[display_type]['red'] = 99 config[display_type]['green'] = 99 @@ -28,7 +28,7 @@ return config -def set_value_in_config(config, br_rgb, display_type='primary'): +def set_value_in_config(config, br_rgb, display_type = 'primary'): config[display_type]['brightness'] = str(br_rgb[0]) config[display_type]['red'] = str(br_rgb[1]) config[display_type]['green'] = str(br_rgb[2]) @@ -53,11 +53,8 @@ else: config = set_value_in_config(config, p_br_rgb) - try: - with open(file_path, 'w+') as configfile: - config.write(configfile) - except PermissionError as e: - raise e + with open(file_path, 'w+') as configfile: + config.write(configfile) def write_both_display(p_br_rgb, s_br_rgb, file_path): @@ -82,8 +79,5 @@ else: set_value_in_config(config, s_br_rgb, 'secondary') - try: - with open(file_path, 'w+') as configfile: - config.write(configfile) - except PermissionError as e: - raise e + with open(file_path, 'w+') as configfile: + config.write(configfile) \ No newline at end of file