Skip to content

Commit 2e40be2

Browse files
authored
Add bluetooth controls to the GUI, and fix bluetooth conf updates for commented lines (#917)
* Add bluetooth controls to the GUI, and fix bluetooth conf updates with commented lines * Show config file in use and move bluetooth options to advanced settings
1 parent 5b3b82f commit 2e40be2

File tree

4 files changed

+403
-28
lines changed

4 files changed

+403
-28
lines changed

auto_cpufreq/core.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,13 @@ def sysinfo():
870870
driver = getoutput("cpufreqctl.auto-cpufreq --driver")
871871
print("Driver: " + driver)
872872

873+
config_path = config.path if config.has_config() else None
874+
if config_path is None:
875+
from auto_cpufreq.config.config import find_config_file
876+
config_path = find_config_file(None)
877+
if os.path.isfile(config_path):
878+
print(f"\nUsing settings defined in {config_path}")
879+
873880
# get usage and freq info of cpus
874881
usage_per_cpu = psutil.cpu_percent(interval=1, percpu=True)
875882
# psutil current freq not used, gives wrong values with offline cpu's
@@ -936,9 +943,12 @@ def sysinfo():
936943

937944
if offline_cpus: print(f"\nDisabled CPUs: {','.join(offline_cpus)}")
938945

939-
# print current fan speed
946+
# print current fan speed (only if > 0)
940947
current_fans = list(psutil.sensors_fans())
941-
for current_fan in current_fans: print("\nCPU fan speed:", psutil.sensors_fans()[current_fan][0].current, "RPM")
948+
for current_fan in current_fans:
949+
fan_speed = psutil.sensors_fans()[current_fan][0].current
950+
if fan_speed:
951+
print(f"\nCPU fan speed: {fan_speed} RPM")
942952

943953
def read_stats():
944954
if os.path.isfile(auto_cpufreq_stats_path): call(["tail", "-n 50", "-f", str(auto_cpufreq_stats_path)], stderr=DEVNULL)

auto_cpufreq/gui/app.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99

1010
from auto_cpufreq.core import check_for_update, is_running
1111
from auto_cpufreq.globals import GITHUB, IS_INSTALLED_WITH_SNAP
12-
from auto_cpufreq.gui.objects import CPUFreqStatsLabel, CurrentGovernorBox, DaemonNotRunningView, DropDownMenu, MonitorModeView, RadioButtonView, CPUTurboOverride, SystemStatsLabel, UpdateDialog
12+
from auto_cpufreq.gui.objects import BatteryInfoBox, BluetoothBootControl, CPUFreqScalingBox, CurrentGovernorBox, DaemonNotRunningView, DropDownMenu, MonitorModeView, RadioButtonView, CPUTurboOverride, SystemStatsLabel, SystemStatisticsBox, UpdateDialog
1313
from auto_cpufreq.gui.objects import get_stats
14+
from auto_cpufreq.power_helper import bluetoothctl_exists
1415

1516
if IS_INSTALLED_WITH_SNAP:
1617
CSS_FILE = "/snap/auto-cpufreq/current/style.css"
@@ -40,7 +41,7 @@ def main(self):
4041
self.hbox.pack_start(self.systemstats, False, False, 0)
4142
self.add(self.hbox)
4243

43-
self.vbox_right = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=52)
44+
self.vbox_right = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=15)
4445

4546
self.menu = DropDownMenu(self)
4647
self.hbox.pack_end(self.menu, False, False, 0)
@@ -51,8 +52,17 @@ def main(self):
5152
if "Warning: CPU turbo is not available" not in get_stats():
5253
self.vbox_right.pack_start(CPUTurboOverride(), False, False, 0)
5354

54-
self.cpufreqstats = CPUFreqStatsLabel()
55-
self.vbox_right.pack_start(self.cpufreqstats, False, False, 0)
55+
self.batteryinfo = BatteryInfoBox()
56+
self.vbox_right.pack_start(self.batteryinfo, False, False, 0)
57+
58+
self.cpufreqscaling = CPUFreqScalingBox()
59+
self.vbox_right.pack_start(self.cpufreqscaling, False, False, 0)
60+
61+
self.systemstats_box = SystemStatisticsBox()
62+
self.vbox_right.pack_start(self.systemstats_box, False, False, 0)
63+
64+
if bluetoothctl_exists:
65+
self.vbox_right.pack_start(BluetoothBootControl(), False, False, 0)
5666

5767
self.hbox.pack_start(self.vbox_right, False, False, 0)
5868

@@ -121,4 +131,6 @@ def refresh_in_thread(self):
121131
def _refresh(self):
122132
self.systemstats.refresh()
123133
self.currentgovernor.refresh()
124-
self.cpufreqstats.refresh()
134+
self.batteryinfo.refresh()
135+
self.cpufreqscaling.refresh()
136+
self.systemstats_box.refresh()

0 commit comments

Comments
 (0)