diff -Nru juno-fan-indicator-0.3.16/Makefile juno-fan-indicator-0.3.18/Makefile --- juno-fan-indicator-0.3.16/Makefile 2024-01-23 08:01:52.000000000 +0000 +++ juno-fan-indicator-0.3.18/Makefile 2024-03-29 08:01:52.000000000 +0000 @@ -14,14 +14,15 @@ install -dm755 $(DESTDIR)/usr/share/metainfo/ install -dm755 $(DESTDIR)/etc/systemd/system/juno-fancontrol.service.d/ cp -R juno-fan-indicator $(DESTDIR)/usr/share/juno-fan-indicator - install -Dpm 0755 juno-fan-indicator/juno-fan-indicator.svg $(DESTDIR)/usr/share/icons/juno-fan-indicator.svg + install -Dpm 0644 juno-fan-indicator/juno-fan-indicator.svg $(DESTDIR)/usr/share/icons/juno-fan-indicator.svg install -Dpm 0755 juno-fan-indicator-app $(DESTDIR)/usr/bin/juno-fan-indicator - install -Dpm 0755 juno-fan-indicator.desktop $(DESTDIR)/etc/xdg/autostart/juno-fan-indicator.desktop - install -Dpm 0755 juno-fan-indicator.desktop $(DESTDIR)/usr/share/applications/juno-fan-indicator.desktop + install -Dpm 0644 juno-fan-indicator.desktop $(DESTDIR)/etc/xdg/autostart/juno-fan-indicator.desktop + install -Dpm 0644 clevo-fan-indicator.desktop $(DESTDIR)/etc/xdg/autostart/clevo-fan-indicator.desktop + install -Dpm 0644 juno-fan-indicator.desktop $(DESTDIR)/usr/share/applications/juno-fan-indicator.desktop install -Dpm 0644 juno-fan-indicator.metainfo.xml $(DESTDIR)/usr/share/metainfo/juno-fan-indicator.metainfo.xml install -Dpm 0644 fancontrol/juno-fancontrol.service $(DESTDIR)/etc/systemd/system/juno-fancontrol.service install -Dpm 0644 fancontrol/periodic-restart.conf $(DESTDIR)/etc/systemd/system/juno-fancontrol.service.d/periodic-restart.conf - install -Dpm 0644 fancontrol/suspend-juno-fancontrol.service $(DESTDIR)/etc/systemd/system/suspend-juno-fancontrol.service + install -Dpm 0644 fancontrol/juno-fancontrol-suspend.service $(DESTDIR)/etc/systemd/system/juno-fancontrol-suspend.service @-if test -z $(DESTDIR); then gtk-update-icon-cache -f -t $(DESTDIR)/usr/share/icons/hicolor; fi install: install-core @@ -37,5 +38,5 @@ rm -f $(DESTDIR)/usr/share/metainfo/juno-fan-indicator.metainfo.xml rm -f $(DESTDIR)/etc/systemd/system/juno-fancontrol.service rm -R $(DESTDIR)/etc/systemd/system/juno-fancontrol.service.d - rm -f $(DESTDIR)/etc/systemd/system/suspend-juno-fancontrol.service + rm -f $(DESTDIR)/etc/systemd/system/juno-fancontrol-suspend.service @-if test -z $(DESTDIR); then gtk-update-icon-cache -f -t $(DESTDIR)/usr/share/icons/hicolor; fi diff -Nru juno-fan-indicator-0.3.16/clevo-fan-indicator.desktop juno-fan-indicator-0.3.18/clevo-fan-indicator.desktop --- juno-fan-indicator-0.3.16/clevo-fan-indicator.desktop 1970-01-01 00:00:00.000000000 +0000 +++ juno-fan-indicator-0.3.18/clevo-fan-indicator.desktop 2024-03-29 08:01:52.000000000 +0000 @@ -0,0 +1,10 @@ +[Desktop Entry] +Icon=generic-fan-symbolic +Type=Application +Exec=python3 /usr/share/juno-fan-indicator/clevofan.py +Hidden=false +NoDisplay=false +X-GNOME-Autostart-enabled=false +X-GNOME-Autostart-Delay=2 +Name=Clevo Fan Indicator +Comment=Juno Driver for Clevo Fans diff -Nru juno-fan-indicator-0.3.16/debian/changelog juno-fan-indicator-0.3.18/debian/changelog --- juno-fan-indicator-0.3.16/debian/changelog 2024-01-23 08:01:52.000000000 +0000 +++ juno-fan-indicator-0.3.18/debian/changelog 2024-03-29 08:01:52.000000000 +0000 @@ -1,5 +1,6 @@ -juno-fan-indicator (0.3.16-2) jammy; urgency=low +juno-fan-indicator (0.3.18-2) jammy; urgency=low * Added initial support for clevofan-dkms + * Added: fancontrol dependency - -- Juno Tue, 23 Jan 2024 08:01:52 +0000 + -- Juno Fri, 29 Mar 2024 08:01:52 +0000 diff -Nru juno-fan-indicator-0.3.16/debian/control juno-fan-indicator-0.3.18/debian/control --- juno-fan-indicator-0.3.16/debian/control 2023-12-10 17:54:27.000000000 +0000 +++ juno-fan-indicator-0.3.18/debian/control 2024-03-29 08:01:52.000000000 +0000 @@ -9,7 +9,7 @@ Priority: optional Architecture: amd64 Replaces: clevo-fan-control-indicator -Depends: libayatana-appindicator3-dev, libgtk-3-dev, members, make, gcc +Depends: libayatana-appindicator3-dev, libgtk-3-dev, members, make, gcc, fancontrol, gir1.2-appindicator3-0.1 Homepage: https://github.com/SkyLandTW/clevo-indicator Description: This program is an Ubuntu indicator to control the fan of Clevo laptops, using reversed-engineering port information from ECView. Forked by Juno Computers Juno Fan Indicator for Ubuntu diff -Nru juno-fan-indicator-0.3.16/fancontrol/juno-fancontrol-suspend.service juno-fan-indicator-0.3.18/fancontrol/juno-fancontrol-suspend.service --- juno-fan-indicator-0.3.16/fancontrol/juno-fancontrol-suspend.service 1970-01-01 00:00:00.000000000 +0000 +++ juno-fan-indicator-0.3.18/fancontrol/juno-fancontrol-suspend.service 2024-01-23 19:43:54.000000000 +0000 @@ -0,0 +1,10 @@ +[Unit] +Description=Restart of fancontrol.service after suspend +After=hibernate.target suspend.target + +[Service] +Type=simple +ExecStart=systemctl restart juno-fancontrol.service + +[Install] +WantedBy=hibernate.target suspend.target diff -Nru juno-fan-indicator-0.3.16/fancontrol/juno-fancontrol.service juno-fan-indicator-0.3.18/fancontrol/juno-fancontrol.service --- juno-fan-indicator-0.3.16/fancontrol/juno-fancontrol.service 2024-01-23 08:01:52.000000000 +0000 +++ juno-fan-indicator-0.3.18/fancontrol/juno-fancontrol.service 2024-01-28 01:03:37.000000000 +0000 @@ -10,7 +10,6 @@ ExecStart=/usr/sbin/fancontrol /etc/fancontrol.d/juno-fancontrol PIDFile=/run/fancontrol.pid Restart=on-failure -RestartSec=5s [Install] WantedBy=multi-user.target diff -Nru juno-fan-indicator-0.3.16/fancontrol/periodic-restart.conf juno-fan-indicator-0.3.18/fancontrol/periodic-restart.conf --- juno-fan-indicator-0.3.16/fancontrol/periodic-restart.conf 2024-01-23 08:01:52.000000000 +0000 +++ juno-fan-indicator-0.3.18/fancontrol/periodic-restart.conf 2024-01-28 01:03:44.000000000 +0000 @@ -1,3 +1,3 @@ [Service] Restart=always -RuntimeMaxSec=3600 +RuntimeMaxSec=1800 diff -Nru juno-fan-indicator-0.3.16/fancontrol/suspend-juno-fancontrol.service juno-fan-indicator-0.3.18/fancontrol/suspend-juno-fancontrol.service --- juno-fan-indicator-0.3.16/fancontrol/suspend-juno-fancontrol.service 2024-01-23 08:01:52.000000000 +0000 +++ juno-fan-indicator-0.3.18/fancontrol/suspend-juno-fancontrol.service 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -[Unit] -Description=Restart of fancontrol.service after suspend -After=hibernate.target suspend.target - -[Service] -Type=simple -ExecStart=systemctl restart juno-fancontrol.service - -[Install] -WantedBy=hibernate.target suspend.target diff -Nru juno-fan-indicator-0.3.16/juno-fan-indicator/clevofan.py juno-fan-indicator-0.3.18/juno-fan-indicator/clevofan.py --- juno-fan-indicator-0.3.16/juno-fan-indicator/clevofan.py 1970-01-01 00:00:00.000000000 +0000 +++ juno-fan-indicator-0.3.18/juno-fan-indicator/clevofan.py 2024-03-29 08:01:52.000000000 +0000 @@ -0,0 +1,188 @@ +import gi +import os +import configparser + +gi.require_version('Gtk', '3.0') +gi.require_version('AppIndicator3', '0.1') + +from gi.repository import Gtk, AppIndicator3, GLib + +# Configuration file path +CONFIG_FILE_PATH = os.path.join(os.path.expanduser('~/.config'), 'fan_indicator_config') + +# Default temperature unit (True -> Celsius, False -> Fahrenheit) +DEFAULT_TEMPERATURE_UNIT_CELSIUS = True + +# ------------------------- Configuration Handling ------------------------- + +# Function to load configuration +def load_configuration(): + config = configparser.ConfigParser() + if not os.path.exists(CONFIG_FILE_PATH): + # If the config file doesn't exist, create it with default values + config['Preferences'] = {'TemperatureUnit': 'True'} # Default to Celsius + save_configuration(config) + else: + config.read(CONFIG_FILE_PATH) + return config + + +# Function to save configuration +def save_configuration(config): + with open(CONFIG_FILE_PATH, 'w') as configfile: + config.write(configfile) + +# ------------------------- Hardware Information ------------------------- + +# Function to find the directory containing CPU temperature sensor +def find_cpu_temp_sensor_directory(): + hwmon_base_path = '/sys/devices/platform/coretemp.0/hwmon/' + cpu_temp_sensor_directory = None + + # Iterate over subdirectories to find the one with 'temp1_input' + for directory in os.listdir(hwmon_base_path): + if os.path.exists(os.path.join(hwmon_base_path, directory, 'temp1_input')): + cpu_temp_sensor_directory = os.path.join(hwmon_base_path, directory) + break + + if cpu_temp_sensor_directory is None: + raise FileNotFoundError("Could not find the directory with 'temp1_input'") + + return cpu_temp_sensor_directory + + +# Function to find the directory containing fan speed sensor +def find_fan_speed_sensor_directory(): + fan_base_path = '/sys/devices/platform/clevofan/hwmon/' + fan_speed_sensor_directory = None + + # Iterate over subdirectories to find the one with 'fan1_input' + for directory in os.listdir(fan_base_path): + if os.path.exists(os.path.join(fan_base_path, directory, 'fan1_input')): + fan_speed_sensor_directory = os.path.join(fan_base_path, directory) + break + + if fan_speed_sensor_directory is None: + raise FileNotFoundError("Could not find the directory with 'fan1_input'") + + return fan_speed_sensor_directory + +# ------------------------- Temperature Conversion ------------------------- + +# Function to convert Celsius to Fahrenheit +def convert_celsius_to_fahrenheit(celsius): + return (celsius * 9 / 5) + 32 + +# ------------------------- Application Management ------------------------- + +# Function to handle quitting the application +def quit_application(source): + Gtk.main_quit() + +# ------------------------- Tray Indicator Class ------------------------- + +# Class for the tray indicator +class FanTrayIndicator: + def __init__(self): + # Load configuration + self.config = load_configuration() + self.cpu_temp_sensor_path = find_cpu_temp_sensor_directory() + '/temp1_input' + + # Retrieve temperature unit preference from configuration + self.is_temp_unit_celsius = self.config.getboolean('Preferences', 'TemperatureUnit', fallback=True) + + # Initialize the indicator + self.APP_NAME = 'Fan Indicator' + self.ICON_PATH = 'temperature-symbolic' # icon in tray + self.cpu_speed_rpm_path = find_fan_speed_sensor_directory() + '/fan1_input' + self.cpu_speed_pwm_path = find_fan_speed_sensor_directory() + '/pwm1' + self.max_fan_speed = 255 # maximum fan speed + + self.indicator = AppIndicator3.Indicator.new( + self.APP_NAME, + self.ICON_PATH, + AppIndicator3.IndicatorCategory.APPLICATION_STATUS) + self.indicator.set_status(AppIndicator3.IndicatorStatus.ACTIVE) + self.indicator.set_menu(self.build_menu()) + + # Update the tooltip and menu periodically + GLib.timeout_add_seconds(5, self.update_cpu_temp_tooltip) + GLib.timeout_add_seconds(5, self.update_fan_speed_menu) + + # Function to build the menu + def build_menu(self): + menu = Gtk.Menu() + + # Add a menu item to display CPU temperature and RPM + self.item_fan_speed = Gtk.MenuItem(label="") + menu.append(self.item_fan_speed) + + # Add a menu item to toggle temperature unit + item_toggle_temp_unit = Gtk.MenuItem(label="Toggle Temperature Unit") + item_toggle_temp_unit.connect('activate', self.toggle_temperature_unit) + menu.append(item_toggle_temp_unit) + + # Add a quit option to the menu + item_quit = Gtk.MenuItem(label='Quit') + item_quit.connect('activate', quit_application) + menu.append(item_quit) + + menu.show_all() + return menu + + # Function to update the tooltip + def update_cpu_temp_tooltip(self): + try: + with open(self.cpu_temp_sensor_path, 'r') as file: + value = file.read().strip() + cpu_temp_celsius = float(value) / 1000 + # Parse the temperature value and format it + if not self.is_temp_unit_celsius: + cpu_temp_fahrenheit = convert_celsius_to_fahrenheit(cpu_temp_celsius) + temperature = "{:.0f}°F".format(cpu_temp_fahrenheit) + else: + temperature = "{:.0f}°C".format(cpu_temp_celsius) + + # Display formatted temperature value as label + self.indicator.set_label(" " + temperature, self.APP_NAME) + except FileNotFoundError: + self.indicator.set_label('File not found', self.APP_NAME) + + # Returning True ensures the function is called again after the specified interval + return True + + # Function to update the menu + def update_fan_speed_menu(self): + with open(self.cpu_speed_pwm_path, 'r') as f1, open(self.cpu_speed_rpm_path, 'r') as f2: + cpu_pwm_value = f1.read().strip() + cpu_rpm_value = f2.read().strip() + # Calculate percentage + + cpu_speed_percentage = "{:.0f}".format((float(cpu_pwm_value) / self.max_fan_speed) * 100) + # Format the label with CPU temperature and RPM + menu_label = "CPU FAN: {}% | {} RPM".format(cpu_speed_percentage, cpu_rpm_value) + # Update the label of the menu item + self.item_fan_speed.set_label(menu_label) + return True + + # Function to toggle temperature unit + def toggle_temperature_unit(self, source): + self.is_temp_unit_celsius = not self.is_temp_unit_celsius + # Save updated preference to configuration + self.config['Preferences']['TemperatureUnit'] = str(self.is_temp_unit_celsius) + save_configuration(self.config) + # Call update_cpu_temp_tooltip to reflect the change immediately + self.update_cpu_temp_tooltip() + +# ------------------------- Main ------------------------- + +# Main function +def main(): + Gtk.init([]) + indicator = FanTrayIndicator() + Gtk.main() + + +# Entry point of the script +if __name__ == "__main__": + main()